aspose file tools*
The moose likes JSF and the fly likes JSF 1.2 - ValueChangeEvent not picking up new selected value after submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 1.2 - ValueChangeEvent not picking up new selected value after submit" Watch "JSF 1.2 - ValueChangeEvent not picking up new selected value after submit" New topic
Author

JSF 1.2 - ValueChangeEvent not picking up new selected value after submit

Michael Tran
Greenhorn

Joined: Nov 27, 2009
Posts: 7
I have this bean:

The menuChange() method above does not return the newly selected value. I'm not sure why. Can anyone help?
Akaine Harga
Ranch Hand

Joined: Nov 03, 2009
Posts: 71

Please post the front form where you call for the method


Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
willCodeForFood("Java,PHP,C#,XML,VBS,XHTML,CSS,JavaScript,SQL"); //always looking for job opportunities in AU/NZ/US/CA/Europe :P
Michael Tran
Greenhorn

Joined: Nov 27, 2009
Posts: 7
Hi Akaine: Thank you for responding. The codes for the form:

The codes for pageChanged() JavaScript function:

Codes for the submit method:

The above codes return the first item in the h:selectOneMenu instead of the item selected prior to submit. This is the part where I can't figure out...
Vishal Chaudhry
Greenhorn

Joined: Dec 16, 2009
Posts: 7
Hi Michael,

I am trying to debug the code. I have duplicated the code in a project and have verified that the submit method is being called. I have verified this by sending text to the log file. Currently I am not aware of the class "FacesUtil" being used in your code and hence I am not able to replicate that piece of code for further testing. Is it a custom class built by you?

I have replaced that code with another way of retrieving the bean object and I notice that I am getting the value for selected page. Again I am testing this by sending output to the log file. I am getting value as 0 if 1 is selected, 20 if 2 is selected, 30 if 3 is selected, etc. A problem which I have noticed is that, to get the value in the log, I have to click the button to submit the form in the UI two times in case I change the value in the dropdown list.
Michael Tran
Greenhorn

Joined: Nov 27, 2009
Posts: 7
Thanks for responding, Vishal.

I solve this issue by using getters/setters for a HtmlSelectOne component and a h:inputHidden field - and I drop the menuChange() method as it's superfluous. FacesUtil is a custom class I wrote that pretty much have methods relating to the FacesContext.

I hope JSF 2.0 will have a "cleaner" approach for doing something similar. Fingers crossed!...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF 1.2 - ValueChangeEvent not picking up new selected value after submit
 
Similar Threads
PartialSubmit on inputText and selectOneChoice does not work...
selectManyCheckbox in dataTable returns only the last selected item rather the whole list.
how to use "h:selectOneMenu"
selectOneMenu valueChangeListener never fires!!
JSF v1.2: Pass total figure into bean for generation of pages