This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in value change event

 
Sylven Yip
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Mark.
that it.
 
Kumar Saravanan
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic