Hi all,
I'm still learning JSF, so please be patient with me. I have a form that
must accept both local (US and Canada) address and international address. I
have a country drop down list and once the focus changes (leave the box), I
want to run a method that will change the values of some fields.
Specifically, I want to change the telephone input fields to free format,
and the state/province from a drop down to free form. I'm a little confused
about what I need to do in order to show/hide fields dynamically via JSF
without writing my own javascript, as well as just populating the list. I
have the following form snippet.
<h:form>
<h:panelGrid columns="2" border="1">
<h:outputText value="Address 1:"></h:outputText>
<h:inputText value="#{address.address1}"
required="true"></h:inputText>
<h:outputText value="Address 2:"></h:outputText>
<h:inputText value="#{address.address2}"></h:inputText>
<h:outputText value="City:"></h:outputText>
<h:inputText value="#{address.city}"></h:inputText>
<h:outputText value="Country:" ></h:outputText>
<h:selectOneListbox value="#{address.country}"
valueChangeListener="#{address.checkCountry}></h:selectOneListbox>
<h:outputText value="State:"></h:outputText>
<h:inputText value="#{address.state}"></h:inputText>
<h:outputText value="State/Province:"></h:outputText>
<h:inputText value="#{address.stateIntl}"></h:inputText>
...
The country property is the one I want set and evaluated when they exit the
select. I have the a list of country items of the following type
private List<SelectItem> countries;
What do I use to set the "options" in the selectOneListbox? I can't seem to
find it in the docs. Also, when my method "checkCountry" is fired, how do I
hide my "state" label and input box and show my "State/Province" label and
input box?
Thanks for the help.
Todd