I am going on a limb to answer this without first checking MyFaces
code and the spec, so feel free to correct any errors I am about to
post.

Calling render response on the faces context will not interrupt the
current phase, but instead just cause rendering to occur. According to
what I remember of the JSF spec, you need to call the
responseComplete() method of the context if you want to abort the
phase cycle of JSF. With that said, I know that will abort the phase
cycle, but I don't know if it will abort the current phase (execute
application or whatever it is called). You can give it a shot though:

public void actionListenerMethod(ActionEvent e) {
   //Shouldn't this bypass the action method???
   FacesContext.getCurrentInstance().renderResponse();
   FacesContext.getCurrentInstance().responseComplete();
}

public String actionMethod() {
   return null;
}

(note, this is all from memory, so I may have the method name wrong
and its location)
-Andrew

On 5/3/06, Matt Hughes <[EMAIL PROTECTED]> wrote:
Is there any way to prevent an action method from being invoked from the
action listener method?

For example...take the following commandButton:

<h:commandButton actionListener="#{backingBean.actionListenerMethod}"
action="#{backingBean.actionMethod}" value="Click Me" />

And the matching methods in your backing bean:

public void actionListenerMethod(ActionEvent e) {
    //Shouldn't this bypass the action method???
    FacesContext.getCurrentInstance().renderResponse();
}

public String actionMethod() {
    return null;
}


It was my understanding the *renderResponse()* would skip the context
into the render response phase, and any action methods would be
skipped.  In my tests, this is not true.  So...is there any way to
prevent an action method from being invoked from within an action
listener method?


Reply via email to