You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by OrlandoJim <ji...@yahoo.com> on 2009/01/26 22:52:35 UTC

Unexpected Phases with CommandLink using immediate attrib

I am using <h:CommandLink> with an action, actionListener, and
immediate=true.

I was of the understanding that, after my actionListener and action finished
executing, processing would continue with the Process Validation, validating
non-immediate components, unless I called renderResponse() in the action
listener or returned a non-null String from the action or method.  

Instead, what I am seeing is that it goes to Render Response even though I
do not call renderResponse( ) in the action listener method and do return
null from the action.  (I have a PhaseListener to print which phases I'm
starting and ending). When I remove the immediate attribute, it does call
the other validator(s). Any ideas why?

<body onload="doOnload();">
	<h:form id="custSearchForm">
	<h:outputText id="pageHeader" value="Customer Search" />
	<h:messages styleClass="error" infoStyle="color:orange"
showDetail="#{true}" showSummary="#{false}" />
	<br/>
	  Name: 
	  <h:inputText id="name" value="#{customerSearchBean.name}" required="true"
onkeypress="return KeyPressed(event)" >
	     <f:converter converterId="jimdl.UpperNameConverter"/>
		 <f:validateLength minimum="2" maximum="25" />
	  </h:inputText>
	  <h:commandButton style="width:80px" value="Search"
action="#{customerSearchBean.loadCustomer}" />
	  </br>
	  <h:commandLink immediate="true" action="#{customerSearchBean.doNothing}"
actionListener="#{customerSearchBean.toggleHeader}"  value="ToggleHeader"/>
	</h:form>
	
	</f:view>
</body>

In CustomerSearchBean:

	public void toggleHeader(ActionEvent actionEvent) {
		System.out.println(((UIComponent)actionEvent.getSource()).getId());
	}
	
	public String doNothing() {
		return null;
	}

I am using MyFaces 1.1.6 on Apache Tomcat 5.5.

Incidentally, I downloaded the source for MyFaces, and the the
ActionListenerImpl class, which calls the action method calls
application.getNavigationHandler().handleNavigation(...), which does nothing
because my action method returned a null.  Then, the ActionListenerImpl
calls renderResponse()!

        navigationHandler.handleNavigation(facesContext, fromAction,
outcome);

        //Render Response if needed
        facesContext.renderResponse();

Any idea why?


-- 
View this message in context: http://www.nabble.com/Unexpected-Phases-with-CommandLink-using-immediate-attrib-tp21673991p21673991.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Unexpected Phases with CommandLink using immediate attrib

Posted by OrlandoJim <ji...@yahoo.com>.
Just a quote from the 1.1 specification:

If any of the decode() methods that were invoked, or an event listener that
processed a queued event, called renderResponse() on the FacesContext
instance for the current request, control must be transferred to the Render
Response phase of the request processing lifecycle. Otherwise, control must
proceed to the Process Validations phase.

As I mentioned, this is not happening in MyFaces 1.1.6.


OrlandoJim wrote:
> 
> I am using <h:CommandLink> with an action, actionListener, and
> immediate=true.
> 
> I was of the understanding that, after my actionListener and action
> finished executing, processing would continue with the Process Validation,
> validating non-immediate components, unless I called renderResponse() in
> the action listener or returned a non-null String from the action or
> method.  
> 
> Instead, what I am seeing is that it goes to Render Response even though I
> do not call renderResponse( ) in the action listener method and do return
> null from the action.  (I have a PhaseListener to print which phases I'm
> starting and ending). When I remove the immediate attribute, it does call
> the other validator(s). Any ideas why?
> 
> <body onload="doOnload();">
> 	<h:form id="custSearchForm">
> 	<h:outputText id="pageHeader" value="Customer Search" />
> 	<h:messages styleClass="error" infoStyle="color:orange"
> showDetail="#{true}" showSummary="#{false}" />
> 	<br/>
> 	  Name: 
> 	  <h:inputText id="name" value="#{customerSearchBean.name}"
> required="true" onkeypress="return KeyPressed(event)" >
> 	     <f:converter converterId="jimdl.UpperNameConverter"/>
> 		 <f:validateLength minimum="2" maximum="25" />
> 	  </h:inputText>
> 	  <h:commandButton style="width:80px" value="Search"
> action="#{customerSearchBean.loadCustomer}" />
> 	  </br>
> 	  <h:commandLink immediate="true"
> action="#{customerSearchBean.doNothing}"
> actionListener="#{customerSearchBean.toggleHeader}" 
> value="ToggleHeader"/>
> 	</h:form>
> 	
> 	</f:view>
> </body>
> 
> In CustomerSearchBean:
> 
> 	public void toggleHeader(ActionEvent actionEvent) {
> 		System.out.println(((UIComponent)actionEvent.getSource()).getId());
> 	}
> 	
> 	public String doNothing() {
> 		return null;
> 	}
> 
> I am using MyFaces 1.1.6 on Apache Tomcat 5.5.
> 
> Incidentally, I downloaded the source for MyFaces, and the the
> ActionListenerImpl class, which calls the action method calls
> application.getNavigationHandler().handleNavigation(...), which does
> nothing because my action method returned a null.  Then, the
> ActionListenerImpl calls renderResponse()!
> 
>         navigationHandler.handleNavigation(facesContext, fromAction,
> outcome);
>         //Render Response if needed
>         facesContext.renderResponse();
> 
> Any idea why?
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unexpected-Phases-with-CommandLink-using-immediate-attrib-tp21673991p21678256.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.