I had forgotten to put my <h:selectonemenu>
inside <h:form>
.
Passing selected value in h:selectOneMenu to h:link
-
05-07-2023 - |
Domanda
I want to pass the selected value of a h:selectOneMenu
to h:link
as a view param. The selected value is always empty.
Here's my code:
<h:selectOneMenu value="#{countryLclController.selectedCountry}">
<f:selectItem itemLabel="#{text['select_country']}" itemValue=""/>
<f:selectItems value="#{countryLclController.getCountries(request.locale.language)}" var="country" itemLabel="#{country.countryName}" itemValue="#{country.countryName}"/>
<f:ajax render="visa"/>
</h:selectOneMenu>
<h:link id="visa" outcome="Visa_Guide" includeViewParams="true" value="#{text['visa_guide']}">
<f:param name="country" value="#{countryLclController.selectedCountry}"/>
</h:link>
the term country is added to outcome since I have the f:viewParam
in Visa_Guide.xhtml but country is empty; so the outcome becomes: Visa_Guide?country=
country
is a String field with getter and setter methods in countryLclController
managed bean.
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow