Problems with valueChageListener in <h:selectOneMenu>

The problem is here as follows:

I have a registration page with two Menu Lists i.e one MenuList (<h:selectOneMenu>) with countries. and the other MenuList is for states so that upon selecting a country in countries MenuList event should be generated and states menu list gets changed correspondingly. Upto here is fine now the problem is iam having the <h:commandButton > in the end .So I have to click two times to proceed for a action if country MenuList is untouched. So how to solve this problem. in the valueChangedListener method body I put this statement-> FacesContext.getCurrentInstace.renderResponse();

I was in the middle of the work. Please Help Me. Any Help is greatly appriciated

Thanks

Vijay

[753 byte] By [vijaycanaana] at [2007-11-26 23:52:41]
# 1
Put them in separate forms.
BalusCa at 2007-7-11 15:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hai Balus,

Thanking u for your reply. I have already tried what you suggested but my problem remained same. If possible do u have any code blocks to make me to get the solution here is my code

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>

<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<h:panelGrid columns="2" >

<h:outputText value="already a member? " styleClass="text2"/>

<h:commandLink value="click here to Login" style="color:yello" />

</h:panelGrid >

<h:panelGridcellspacing="20">

<h:outputText value=" New User Registration:"styleClass="textsidehead"/>

</h:panelGrid >

<h:panelGrid columns="2" style="align:right" >

<h:outputText value="mandatory" style="font-size:12px">

<h:outputText value="*" style="color: red">

<h:outputText id="output_text2"

style=" font-size: 12px; right:330px" value="Fields marked with">

</h:outputText>

</h:outputText>

</h:outputText>

</h:panelGrid>

<h:panelGrid columns="3" >

<h:outputText value="Login ID" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:inputText id="loginId" required="true" value="#{Registration.loginId}" size="40"/>

<h:message for="loginId" />

<h:outputText value="First Name" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:inputText id="firstName" value="#{Registration.firstName}" size="40"/>

<h:outputText value="#{Registration.errmsgfname}"/>

<h:outputText value="Last Name" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:inputText id="lastName" value="#{Registration.lastName}" size="40"/>

<h:outputText value="#{Registration.errmsglname}" />

<h:panelGroup id="email">

<h:outputText value="*" style="color: red"/><h:outputText value="Email ID" styleClass="text2"/></h:panelGroup>

<h:inputText id="emailId" value="#{Registration.emailId}" size="40"/>

<h:outputText value="#{Registration.errmsgemailid}"/>

<h:outputTextvalue="Password" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:inputSecret id="password" value="#{Registration.password}" size="40"/>

<h:outputText value="#{Registration.errmsgpass}"/>

<h:outputText value="Confirm Password" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:inputSecret id="confirmPassword" value="#{Registration.confirmPassword}" size="40"/>

<h:outputText value="#{Registration.errmsgcpass}" />

<h:outputText value="Gender" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:selectOneRadio id="gender" value="#{Registration.gender}">

<f:selectItem itemValue="Male" itemLabel="Male"/>

<f:selectItem itemValue="Female" itemLabel="Female"/>

</h:selectOneRadio>

<h:outputText value="#{Registration.errmsggender}" />

<h:outputText value="Country" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:form>

<h:selectOneMenu id="country" immediate="true" binding="#{Registration.compCountries}" onchange="this.form.submit();" valueChangeListener="#{EventHandler.valueChanged}" value="#{Registration.country}">

<f:selectItem itemValue="0" itemLabel="<--Select A Country-->"/>

<f:selectItems id="countries" value="#{Loadings.countries}" />

</h:selectOneMenu>

<h:outputText value="#{Registration.errmsgcountry}" />

</h:form>

<h:outputText value="State/province" styleClass="text2">

<h:outputText value="*" style="color: red"/>

</h:outputText>

<h:selectOneMenu id="state" disabled="#{!Registration.statesRendered}" binding="#{Registration.compStates}" value="#{Registration.state}">

<f:selectItems id="states" value="#{Loadings.states}" />

</h:selectOneMenu>

<h:outputText value="#{Registration.errmsgstate}" />

<h:outputText value="ZipCode" styleClass="text2">

<h:outputText value=" " />

</h:outputText>

<h:inputText id="zip" value="#{Registration.zip}" size="10"/>

<h:message for="zip" />

<h:outputText />

<h:outputText value="accept Quivus" styleClass="text2">

<h:selectBooleanCheckbox value="#{Registration.accept}">

</h:selectBooleanCheckbox>

<h:commandLink value="Terms of service " style="color:yello"/>

</h:outputText>

<h:outputText />

<h:outputText />

<h:commandButton value="Register" action="#{Registration.save}" />

</h:panelGrid >

this code is used in the subview as

<h:form>

<f:subview id="registration_login">

<jsp:include page="register.jsp" />

</f:subview>

</h:form>

thank u

Vijay

Message was edited by:

vijaycanaan

vijaycanaana at 2007-7-11 15:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...