dev@javaserverfaces.java.net

Re: jsf immediate on action

From: Dmitry Kushner <Dmitry.Kushner_at_Sun.COM>
Date: Mon, 25 Jun 2007 19:07:18 -0600


richard ratta wrote:
"Immediate" on UICommand results in a couple of behaviors.

An ActionEvent is broadcast based on the value of its phaseId.
For an immediate UICommand (Button) that phase id is set to "APPLY_REQUEST_VALUES"
when the UICommand is immediate.
This means the event will be broadcast before "PROCESS_VALIDATIONS"
phase begins. Otherwise the event is broadcast after "INVOKE_APPLICATION".

In the immediate case, the lifecycle will terminate before "PROCESS_VALIDATIONS"
and go directly to RENDER_RESPONSE. This happens by way of the default
default ApplicationActionListener. I believe this is "spec'd" by the definition of an "ActionSource".

If the UICommand is not immediate then the lifecycle completes since INVOKE_APPLICATION
is effectively the end of the lifecycle, since the next phase is RENDER_RESPONSE.
yes, I can see all this in the JSF code. I just do not see where in the spec such behavior is specified. I  see events, which phase is used in immediate or other case, but I do not see where it says that such event should interrupt the cycle...( they may, but the way I read this is more for specializations of reference implementation, not for RI itself.) I must be missing something here...


Now any subclass of UICommand or any parent in the chain of "queueEvent" can
change the phase id of the ActionEvent that is bubbling up to the view root.

Our Button extends UICommand and I believe chose to follow the behavior of
UICommand and the behavior inherent in an ActionSource, which causes
the default ApplicationActionListener to be invoked.

in ActionSource docs for isImmediate() i read: "Return a flag indicating that the default ActionListener provided by the JavaServer Faces implementation should be executed immediately (that is, during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase."
no mention that cycle is ended there.

TLD docs for  webui.Button  are somewhat more confusing: " A button that is used to affect the input components on the page, such as providing initial default input, should be configured with immediate="true" and ..."If you want a button to submit a page, you should not set immediate,"

-rick

Dmitry Kushner wrote:

wrt https://woodstock.dev.java.net/issues/show_bug.cgi?id=84:

The reported issue deals with button that submits the form and the text field, where button's immediate == true

I have traced the lifecycle processing within LifecycleImpl.execute, and when immediate is true, it requests lifecycle processing to go to Render_Response ( context.getRenderResponse() == true, line 108)

Why immediate flag on the button   completes the lifecycle processing ? JSF specification says any component *can  *do that, but it does not specify that action *does or must  *complete lifecycle processing? I could not find anywhere in the specification where such behavior is described as prescribed....

-- 

thank you ,
~    dmitry


--

thank you ,
~    dmitry

ActionListener (JavaServer Faces API (1.2MR1))

javax.faces.event
Interface ActionListener

All Superinterfaces:
java.util.EventListener, FacesListener
All Known Implementing Classes:
MethodExpressionActionListener

public interface ActionListener
extends FacesListener

A listener interface for receiving ActionEvents. A class that is interested in receiving such events implements this interface, and then registers itself with the source UIComponent of interest, by calling addActionListener().


Method Summary
 void processAction(ActionEvent event)
          Invoked when the action described by the specified ActionEvent occurs.
 

Method Detail

processAction

void processAction(ActionEvent event)
                   throws AbortProcessingException

Invoked when the action described by the specified ActionEvent occurs.

Parameters:
event - The ActionEvent that has occurred
Throws:
AbortProcessingException - Signal the JavaServer Faces implementation that no further processing on the current event should be performed


Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.