This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSF and the fly likes Spurious valueChangeListener calls on same JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Spurious valueChangeListener calls on same JSP page" Watch "Spurious valueChangeListener calls on same JSP page" New topic
Author

Spurious valueChangeListener calls on same JSP page

jack catler
Greenhorn

Joined: Jan 04, 2006
Posts: 26
I have a number selectOneListbox items on the same JSP page.

They are logically connected in a tree type structure, selecting list A will fill list B, selecting list B will fill list C and so on. I also clear the lists as required.

Each list has a Listener handler valueChangeListener which performs a number of actions:
- Gets the new value.
- clears the current list.
- Updates the lists based on the selection.

Works OK 50% of the time but then depending on sequence (and luck/timing?), some selections of list items (up the tree) cause the valueChangeListener events of other lists to be fired with null/unselected values. I have done some searching and I believe it's a timing issue but thats all I can determine. I am quite new JSF...


Example of the list declerations follows...

<tr><td>List A</td></tr>
<tr><td>
<h:selectOneListbox immediate="true" onchange="submit()"valueChangeListener="#{myclass.listAChanged}">
<f:selectItems value="#{myclass.listA}" />
</h:selectOneListbox>
</td></tr>

<tr><td>List B</td></tr>
<tr><td>
<h:selectOneListbox immediate="true" onchange="submit()"
valueChangeListener=" {myclass.listBChanged}">
<f:selectItems value="#{myclass.listB}" />
</h:selectOneListbox>
</td></tr>

<tr><td>List C</td></tr>
<tr><td>
<h:selectOneListbox immediate="true" onchange="submit()"
valueChangeListener="#{myclass.listCChanged}">
<f:selectItems value="#{myclass.listC}" />
</h:selectOneListbox>
</td></tr>

Example of valueChangeListener follows...

public void listAChanged(ValueChangeEvent event){

FacesContext fc = getFacesContext();
String newAString = (String)event.getNewValue();

// listB is a Map object...
listB = getNewBList(newAString);
listC.clear();


fc.renderResponse();
}


When I play around with the list selection screen I get (without explanation) null events or events that refer to lower lists (say listC) without even having selected them...it is kinda driving me el nutso...

Any tips greatly appreciated.

Thanks
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Did you find a solution to your problem?
I have the same problem (i.e. several value change listener methods) and would be grateful for your help?
Julien.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Spurious valueChangeListener calls on same JSP page
 
Similar Threads
Problem using more than one listbox on a page?
JSF drop down problem
jsf ajax rerender inputText
Help - question on selectOneListbox and page reloads
how to force setter in jsf??