This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSF and the fly likes a4j:support listener event does not fire in myfaces/tomahawk application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "a4j:support listener event does not fire in myfaces/tomahawk application" Watch "a4j:support listener event does not fire in myfaces/tomahawk application" New topic
Author

a4j:support listener event does not fire in myfaces/tomahawk application

christi tyahur
Greenhorn

Joined: Feb 19, 2010
Posts: 2

We have an existing production application that uses the following technologies:
MyFaces 1.1.4
Tomahawk 1.1.5
Tomahawk-sandbox 1.1.4
We use the tomahawk sandbox to provide ajax filtering capability for selectOneMenus.
Our application servers are being upgraded and will not accept anything with the words Sandbox or Snapshot. The tomahawk jar file contains both.
I was trying to find the simplest way to incorporate ajax into the application without using the sandbox. I downloaded tomahawk 1.1.5, oscache-2.3 and ajaxjsf-1.06.
I’m am trying to use <a4j:support on a selectOneMenu and I’m encountering the following problems:
1. The actionListener does not fire and therefore can’t get the new value from the selectOneMenu
2. The <a4j:log shows: Have Event [object Object] with properties: target: undefined, srcElement: [object], type: change … (This isn’t the only message in the log, but it seems like the only one that might be causing a problem)

When an item is selected from the first selectOneMenu, the value changes to zero. The getter method for the select item is called. In this method I call another method to filter the 2nd selectOneMenu based on the value of the supervisor key in the first selectOneMenu. For testing purposes, I added an if statement to check the supervisorKey and if it is 0, I change it to a valid key which ten retrieves the correct list for the 2nd selectOneMenu and changes it on the screen.
The following snippet is from my jsp:
<h:panelGroup styleClass="leftField">
<h:selectOneMenu id="supervisor"
value="#{icrEmployeeBean.supervisorKey}"
onblur="changeVal(this.value);change(this)"
styleClass="inputStandard" tabindex="21">
<f:selectItems value="#{icrEmployeeBean.superList}"/>
<a4j:actionparam name="myKey" id="myKey" value="this.value" assignTo="#icrEmployeeBean.supervisorKey}"/>
<a4j:support event="onchange" id="supportMe" actionListener="#{icrEmployeeBean.supervisorListChange}"
requestDelay="500"
ignoreDupResponses="true" reRender="subs"/>
</h:selectOneMenu>
</h:panelGroup>
<h:panelGroup styleClass="rightField"> <t:inputHidden id="superKey" forceId="true" value=""/>
<hutputText value=" Subordinates:" />
</h:panelGroup>
<h:panelGroup styleClass="leftField">
<h:selectOneMenu id="subs" onblur="change(this)"
value="#{icrEmployeeBean.subordinateKey}"
styleClass="inputStandard">
<f:selectItems value="#{icrEmployeeBean.subList}"/>
</h:selectOneMenu>
</h:panelGroup>

I’ve searched various forums but haven’t come up with an answer. I gave RichFaces a cursory try on a small test application and ran into problems. I didn’t spend a lot of time on it because I really don’t want to go down that road…the application I need to change is quite large. I would be extremely grateful if someone out there can provide some assistance with this problem. Thanks very much to anyone that can help!
christi tyahur
Greenhorn

Joined: Feb 19, 2010
Posts: 2
I'm done banging my head against the wall!!
I was unable to get the actionListener event to fire, however I did get the reRender to work by doing the following:
In the backing bean I created UISelectOne binding attribute with associated getter and setter methods. On the jsp page for the SelectOneMenu I added a binding attribute that maps to the UISelectOne in the backing bean. In the getter method for the UISelectOne attribute I check if the submitted value is null, and if not I set the property of the SelectOneMenu value attribute to the UISelectOne submitted value.
Hope this will help someone else with a similar problem.
Tanya Ruttenberg
Ranch Hand

Joined: Jun 22, 2009
Posts: 40
I had this problem just recently. In order for the actionListener to fire, the a4j:support tag must be enclosed within an h:form.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: a4j:support listener event does not fire in myfaces/tomahawk application