This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSF and the fly likes onclick event of command button change the state of radio button but onchange doe not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "onclick event of command button change the state of radio button but onchange doe not" Watch "onclick event of command button change the state of radio button but onchange doe not" New topic
Author

onclick event of command button change the state of radio button but onchange doe not

MuthuKumaraSamy Raja
Greenhorn

Joined: Jan 24, 2008
Posts: 1
Hi,
I am using JSF 1.2, I have a list of items in SelectManyMenu and one SelectOneRadio button saying ascending/descending.
I want to change the state of this radio button based on the value of Selectitems.
When I try this with actionListener of command button, it changes the state of the Radio buttons.
The same thing when I try with valueChangeListener of selectManyMenu nothing works for me.
Please help me to find out the reason and the solution for how to achieve this effect.
Attached my sample code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<hutputText value="Test" />
<f:view contentType="text/html">
<h:form>
<h:selectManyMenu id="rightSelectBox" style="margin-left: 5px; margin-top:2px; width: 200px; height: 250px; overflow: auto; " onchange ="this.form.submit();" valueChangeListener ="#{tableLayoutController.changeDirection}"> <f:selectItem itemValue="A" itemLabel="A" /> <f:selectItem itemValue="B" itemLabel="B" /> <f:selectItem itemValue="C" itemLabel="C" /> <f:selectItem itemValue="D" itemLabel="D" /> </h:selectManyMenu> <div style="height: 10px;"></div>
<h:commandButton value="Test" actionListener="#{tableLayoutController.change}"/>
<h:selectOneRadio id="sortOrderAsc" value="#{tableLayoutController.sortOrder}"> <f:selectItem itemValue="ascending" itemLabel="Ascending" /> <f:selectItem itemValue="descending" itemLabel="Descending" /> </h:selectOneRadio>

</h:form>
</f:view>
</body>
</html>

And the Bean class is doing the following


public void changeDirection(ValueChangeEvent pActionEvent)
{
System.out.println(" Test name " + getName());
if ("A".equals(getName()) || "C".equals(getName())) {
System.out.println(" ASC ");
setSortOrder("ascending");
} else {
System.out.println(" DESC ");
setSortOrder("descending");
}
change(null);
}

public void change(ActionEvent pActionEvent)
{
System.out.println(" Test name " + getName());
if ("A".equals(getName()) || "C".equals(getName())) {
System.out.println(" ASC ");
setSortOrder("ascending");
} else {
System.out.println(" DESC ");
setSortOrder("descending");
}
}

Can anyone help me to solve this problem
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: onclick event of command button change the state of radio button but onchange doe not