aspose file tools*
The moose likes JSF and the fly likes doubt in value change event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "doubt in value change event" Watch "doubt in value change event" New topic
Author

doubt in value change event

Sylven Yip
Ranch Hand

Joined: Aug 30, 2007
Posts: 42
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

Joined: Feb 05, 2001
Posts: 17259
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sylven Yip
Ranch Hand

Joined: Aug 30, 2007
Posts: 42
thanks Mark.
that it.
Kumar Saravanan
Ranch Hand

Joined: Aug 25, 2004
Posts: 40
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

Joined: Feb 05, 2001
Posts: 17259
    
    6

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

Joined: Aug 25, 2004
Posts: 40
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
 
subject: doubt in value change event