• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 99
MyEclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!...
 
Do you pee on your compost? Does this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic