Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajax Listener does not get called properly

 
Jussi Taimiaho
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic