Reputation: 1478
I'm using JSF 2.2 with PrimeFaces 5.3 and I'm trying to work with the p:autoComplete
I think I'm doing some kind of syntax error, but I'm not able to find it
I've this piece of page
<h:selectOneMenu id="countryDropdown" value="#{myController.selectedCountryId}">
<f:selectItems value="#{myController.countries}" var="co" itemValue="#{co.id}" itemLabel="#{msg[co.name]}"/>
</h:selectOneMenu>
<p:autoComplete
dropdown="true"
value="#{myController.selectedAutocompleteId}"
completeMethod="#{myController.callMyAutocompleteMethod}">
<f:attribute name="selectedCountryId" value="#{carCountryDropdown}" />
</p:autoComplete>
In order to perform the auto-completion task I need the value of the "countryDropdown" also. Which syntax I need to use in order to retrieve inside the auto-completion method the value of the "countryDropdown" select item?
Inside the auto-completion method I can use the following code
UIComponent.getCurrentComponent(context).getAttributes().get("selectedCountryId");
but I get always null.
Can you help me?
Upvotes: 3
Views: 1091
Reputation: 3976
You can use ajax, < p:selectOneMenu> supports change event:
< p:selectOneMenu ..>
< p:ajax event="change" listener="#{myController.subjectSelectionChanged}" />
<!--...-->
< /p:selectOneMenu>
which triggers listener subjectSelectionChanged in which you can return the value of the "countryDropdown" in carCountryDropdown
Upvotes: 2