This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes Ajax Listener does not get called properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Ajax Listener does not get called properly" Watch "Ajax Listener does not get called properly" New topic
Author

Ajax Listener does not get called properly

Jussi Taimiaho
Ranch Hand

Joined: Mar 01, 2004
Posts: 40
I am trying to use ajax for populating some data to a drop-down based on contents of another dropdown. I have built one version, which works fine, but is against the SW integrity - and that is what I wish to fix.

My jsf:

My Bean:


Now this works just fine. When I change something in my form, my setDepartmentGroup gets called, the Listener gets a call, and my "department" -component is re-rendered with new values as per the call to "SelectItemUtil.departmentListByGroupCode".

However I have in my bean a reference to entity bean:
My Bean:

/The Decision -object has property "DepartmentGroup", where the data should go and stay. Now however, if I write my jsf:

<h:selectOneMenu label="#{msgs.mcd_department_group}" id="deptgroup" value="#{cc.attrs.decisionHandler.decision.departmentGroup}" >
<f:selectItems value="#{cc.attrs.decisionHandler.departmentGroupList}"/>
<f:ajax render="department" listener="#{cc.attrs.decisionHandler.departmentGroupListener}" />
</h:selectOneMenu>

My Listener -method does not get the call. Now can someone tell me why the Listener does not get called when I bind my form value to a property in another class? Any help is highly appreciated...



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

The fact that your property is in some other bean makes no difference. However, there is a validator restriction that says that if that bean's property is not in the selectItem list, you'll get a validation error and backing bean action methods (including AJAX ones) won't fire. You're even more likely to see that situation if the value expression for the listbox references a bean not yet assigned (that is, departmentGroup cannot be resolved because "department" is null).

Add an h:messages tag to the page with global message display enabled and you should see the error.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Ajax Listener does not get called properly
 
Similar Threads
How to auto-render a GUI using Ajax
ajax within a composite component
selectOneMenu and value in the backing Bean in JSF
Dynamically populating an inputTextArea with the values being selected from the UI
f:ajax to update h:selectOneMenu