This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSF and the fly likes Value Change Listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Value Change Listener" Watch "Value Change Listener" New topic

Value Change Listener

ramesh maredu
Ranch Hand

Joined: Mar 15, 2008
Posts: 210

Hi i am very new to JSF, i started learning it now, i found it interesting,but I stuck in one problem in my jsf i have one <h:selectOneRadio/> component and another <h:selectOneMenu/>, i want to change values of each component and want to read values in managed bean.
First Component is

<h:selectOneRadio disabledClass="selectOneRadio_Disabled" onchange="submit()" enabledClass="selectOneRadio_Enabled" id="radio1"
<f:selectItems value="#{pc_Ramesh.values}">

and second is

<h:selectOneMenu id="menu1" styleClass="selectOneMenu" onchange="submit()"
<f:selectItem itemValue="red" itemLabel="Red"/>
<f:selectItem itemValue="red1" itemLabel="Red1"/>

the only difference between them is f:selectItem and f:selectItems.

if i hard code data using f:selectItem then onchange of value data is going to valuechangelistener.

but if i use f:seletItems to populate data dynamically from managed bean on change of value, value chagne listener is not being invoked at all.

Please suggest me any solution.

SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
Andres Quinones
Ranch Hand

Joined: Oct 09, 2006
Posts: 57
I think that you should test the onclick event on the h:selectOneRadio because I think that the onchange is never called.

Hope this helps.
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66
Try removing the OnChange attribute.

Regards,<br />Joe<br /> <br />"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."<br />--Martin Golding
ramesh maredu
Ranch Hand

Joined: Mar 15, 2008
Posts: 210

Hi All,

Thanks for your replies, i modified the code according to your suggestions but problem remains same, If i use f:selectItem in selectOneRadio then it is working with on click event.
I agree. Here's the link:
subject: Value Change Listener
It's not a secret anymore!