• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

doubt in value change event

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i fail to change the backing-bean's property in a value change event.
it seem's some process invoke the property's set method and set the property to old value.


the jsf fragment:


the listener method:


the binding property and bean methods:



the code as above,i want to change the <h:inputText>'s value when i change the value of <selectOneMenu>.

but the output as follow:
event value:aaa
get from:aaa
set from:bbb
get from:bbb

can any one tell me how can i do this with value change event and who invoke the method set the property back to old value?
thanks!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your change method, at the very end, you need to forward JSF to the render phase. I forget the exact API call. But that is what I see missing, and something that everyone misses using value change event.

Mark
 
Sylven Yip
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Mark.
that it.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my listener method

value is an instance variable in my backing bean.

public void changeValue(ValueChangeEvent event) {
value = (String) event.getNewValue();
FacesContext.getCurrentInstance().renderResponse();
}

in my xhtml page,

<h:selectOneMenu valueChangeListener="#{mybean.changeValue}" immediate="true" onchange="submit();"
value="#{mybean.value}">
<f:selectItems value="#{mybean.options}"/>
</h:selectOneMenu>
<ui:include src="mypage.xhtml"/>

My problem here is before the value change listener is getting invoked the getter property which is referred in mypage.xhtml is getting invoked before the value change listener.

can anyone assist?

Thanks
Kumar
[ November 14, 2007: Message edited by: Kumar Saravanan ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kumar Saravanan:
This is my listener method

value is an instance variable in my backing bean.

public void changeValue(ValueChangeEvent event) {
value = (String) event.getNewValue();
FacesContext.getCurrentInstance().renderResponse();
}

in my xhtml page,

<h:selectOneMenu valueChangeListener="#{mybean.changeValue}" immediate="true" onchange="submit();"
value="#{mybean.value}">
<f:selectItems value="#{mybean.options}"/>
</h:selectOneMenu>
<ui:include src="mypage.xhtml"/>

My problem here is before the value change listener is getting invoked the getter property which is referred in mypage.xhtml is getting invoked before the value change listener.

can anyone assist?

Thanks
Kumar

[ November 14, 2007: Message edited by: Kumar Saravanan ]




I am confused why you need a value= in your h:selectOneMenu

Mark
 
Kumar Saravanan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

selected dropdown value needs to be selected once the page is refreshed (onsubmit()) and that is the reason i have value="" in h:selectOneMenu.

Thanks
Kumar
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic