Back Forum Reply New
Hello, I spent much time thinking and searching a solution.
The question is:

Is there a way to call a transition ID directly without using action components and without using javascript click() calls?

I need to change view when a combobox value is changed, but I don't want do this (or somthing similar) for call transition 'search':Code:
lt;h:selectOneMenu id=quot;pageSizequot; value=quot;#{searchCriteria.pageSize}quot;    onchange=quot;jQuery('#findHotels').click()quot;gt;   lt;f:selectItems value=quot;#{referenceData.pageSizeOptions}quot; /gt;
lt;/h:selectOneMenugt;
lt;p:commandButton id=quot;findHotelsquot; value=quot;Find Hotelsquot; action=quot;searchquot; update=quot;@formquot; /gt;
I'd like to write somthing likeCode:
lt;h:selectOneMenu id=quot;pageSizequot; value=quot;#{searchCriteria.pageSize}quot;gt;   lt;f:selectItems value=quot;#{referenceData.pageSizeOptions}quot; /gt;   lt;f:ajax listener=quot;searchquot; /gt;
lt;/h:selectOneMenugt;
lt;p:commandButton id=quot;findHotelsquot; value=quot;Find Hotelsquot; action=quot;searchquot; update=quot;@formquot; /gt;
If it's not possible, what is the best thing I can do?

Thank you all

If you look at FlowActionListener you will see how an event is raised in response to pressing a command button/link. Presumably you could do the same from your listener. The main question is knowing what event id to raise? With a command button/link this is specified in the action attribute. You'll have to find some other way to specify it instead.

I am able to trigger the transition using a4j:ajax tag through listener. I added entry in request parameter map with key as quot;JsfView.EVENT_KEYquot; and value as quot;transition namequot; to trigger. But my issue now is how to pass transition name from page to listener. Any ideas greatly appreciated.

Listener code:Code:
// TODO incomplete
public class WebflowActionEventGenerationListener implements AjaxBehaviorListener {
   @Override   public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException {       RequestContext requestContext = RequestContextHolder.getRequestContext();       String eventId =  quot;hardcodedNamequot;       if(StringUtils.isNotBlank(eventId)) {FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getRequestMap().put(JsfView.EVENT_KEY, eventId);        }   }
}
xhtml code:

Code:
lt;f:ajax event=quot;blurquot; listener=quot;#{webflowActionEventGenerationListener.processAjaxBehavior}quot; execute=quot;@formquot;render=quot;#{flowRenderFragments}quot;gt;
lt;/f:ajaxgt;
Thanks,
Anil.

The AjaxBehaviorEvent gives you access to the source component. So you may be able to derive some convention based on the component id or other attributes.

I can't understand exactly what you want. But you can check this code for it's that you need (this is used with JSF 1.2 and RichFaces):Code:
lt;h:selectOneMenu id=quot;pageSizequot; value=quot;#{searchCriteria.pageSize}quot;gt;   lt;f:selectItems value=quot;#{referenceData.pageSizeOptions}quot; /gt;   lt;a4j:support event=quot;onchangequot; action=quot;searchquot;   reRender=quot;#{flowRenderFragments}quot; /gt;
lt;/h:selectOneMenugt;
lt;p:commandButton id=quot;findHotelsquot; value=quot;Find Hotelsquot; action=quot;searchquot; update=quot;@formquot; /gt;Using richfaces I don't think it is a problem because a4j:support is an ActionListener, in fact it owns an action parameter for action calls. But using primefaces jsf2, there's no action parameter in f:ajax, in fact it is not an ActionListener.

I think this is the reason why your code works.
I'm right?

Hi migelct1983,

I am using JSF 2 - Richfaces 4 and primefaces. Richfaces 4 replaced the a4j:support with a4j:ajax. a4j:ajax don't have action attribute at all. As per Rossen suggestion, i added a behavior listener and added code that FlowActionListener is doing to generate the action event for webflow. That works. But my main concern was how to pass action from UI. I have fixed that with below code changes.
Code:
// TODO incomplete
public class WebflowActionEventGenerationListener implements AjaxBehaviorListener {
   @Override   public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException {       RequestContext requestContext = RequestContextHolder.getRequestContext();       String eventId =  FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(quot;actionValuequot;);       if(StringUtils.isNotBlank(eventId)) {FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(JsfView.EVENT_KEY, eventId);        }   }
}
xhtml code - Code:
lt;h:inputText value=quot;#{bean.value}quot;gt;

lt;f:param name=quot;actionValuequot; value=quot;changeBeanInfoquot;/gt;

lt;f:ajax event=quot;blurquot; listener=quot;#{webflowActionEventGenerationListener.processAjaxBehavior}quot; execute=quot;@formquot;render=quot;#{flowRenderFragments}quot;gt;
lt;/f:ajaxgt;

lt;/h:inputTextgt;

I am not sure if this better way to do it. It is serving my purpose. But there are limitations to this solution. I can't have more than one a4j:ajax now under same text field(ex: 'blur' and 'change' event).

Please suggest if there is a better solution for this.

Thanks,
Anil.

a4j:jsFunction did the trick for me - lt;a4j:jsFunction name=quot;fireAjaxForChangeBeanValuequot; action=quot;changeBeanInfoquot;/gt;

lt;h:inputText value=quot;#{bean.value}quot; onblur=quot;fireAjaxForChangeBeanValuequot;/gt;

Thanks Max for the solution (2010/04/lea...#comment-79873)

Anil.
¥
Back Forum Reply New