In my application I'm trying to set/update a SelectOneMenu if another SelectOneMenu is set. We're using primefaces, so I checked the primefaces showcase and found exactly what I was looking for. Unfortunately it's not working. The Event isn't fired and I don't know why. Hopefully you can help me
Link to the Example of the primefaces showcase
-> If the language is set, it should automatically reload the list with the salutations, but it doesn't. I have to press F5 to reload. Any ideas?
My xhtml code
<h:form id="addressBasicsForm">
<p:growl id="growl" sticky="true" showDetail="true"/>
<p:tabView id="tabView">
<p:tab id="stammdaten" title="#{msg.adr_basics_tabtitle}">
<table style="width:100%;">
<tr>
<td style="width: 50%;">
<p:panel toggleable="false">
<table style="margin-top:3px; width:100%;">
<tr style="height:26px;">
<td>
<p:selectOneMenu id="somLang" value="#AddressBasics_m.languageId}" style="margin-left:2px; width:90%;">
<f:selectItems value="#{AddressBasics_m.languageItems}"/>
<p:ajax update="somAnrede" listener="#{AdressBasics_m.handleLanguageChange}"/>
</p:selectOneMenu>
</td>
</tr>
<tr style="height:26px;">
<td>
<p:selectOneMenu id="somAnrede" value="#AddressBasics_m.salutationId}" style="margin-left:2px; width:90%;">
<f:selectItems value="#{AddressBasics_m.salutationItems}" />
</p:selectOneMenu>
</td>
My Bean
@Named("AddressBasics_m")
@ConversationScoped
public class AddressBasicsView implements Serializable{
private static final long serialVersionUID = -4034697810438325785L;
public List<SelectItem> getSalutationItems(){
if(firstrun)
languageId = 21L;
firstrun = false;
if(salutationItems == null || lastLanguageId != languageId){
salutationItems = addressService.getAllSalutationsByLangId(languageId);
setLastLanguageId(languageId);
}
return salutationItems;
}
public void handleLanguageChange(){
this.salutationItems = getSalutationItems();
}
I believe that the problem is on your Ajax call. Ajax could be very tricky, I would recommend 2 different approachs:
<p:ajax render="@form" listener="#{AdressBasics_m.handleLanguageChange}"/>
or
<p:ajax update=":addressBasicsForm:tabView:stammdaten:somAnrede" listener="#{AdressBasics_m.handleLanguageChange}"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With