• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Michael Tran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
Java MyEclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the front form where you call for the method
 
Michael Tran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic