简体   繁体   中英

primefaces selectonemenu ajax listener not working in Dialog Box

I am trying to retrieve the value of Dropdown/selectonemenu, which is in Dialog. But not getting it using listener/valueChangeListener.

My xhtml code:

<p:selectOneMenu id="test" value="#{report.location}" style="width:13% !important;">
<p:ajax listener="#{report.locationChange}" />
<f:selectItem itemLabel="All" itemValue="All" />
<f:selectItem itemLabel="INSHOP" itemValue="INSHOP" />
<f:selectItem itemLabel="INSTORAGE" itemValue="INSTORAGE" />
</p:selectOneMenu>

My Java code for listener to print the value for location:

public void locationChange() {
//location = (String) ((UIOutput) event.getSource()).getValue();
System.out.println("Location :: "+location);
}

Its not printing the location, just giving me NULL.

But when i am trying the same thing outside the DIALOG box, its showing the correct result.

Try using in p:selectOneMenu instead of p:ajax

<h:selectOneMenu value="#{qbaggageModel.deliveryAddrType}">
   <f:selectItem itemLabel="Select" itemValue=""> </f:selectItem>
   <f:selectItem itemLabel="Permanent" itemValue="Perm"> </f:selectItem>
   <f:selectItem itemLabel="Temporary" itemValue="Temp"> </f:selectItem>
   <f:ajax execute="@form" render="delDtlsDiv" listener="#{qbaggageHandler.copyAddress}" />
</h:selectOneMenu>

This code should be enclosed in a <h:form></h:form> 此代码应包含在<h:form> </ h:form>中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM