Reputation: 7392
Why after selecting an item in this code, the cities component does not get rendered?
<h:form prependId="false">
<h:panelGrid columns="1">
<h:selectOneMenu value="#{enumBeanStatus.selectedRegion}">
<f:selectItems id="selectItem" value="#{enumBean.regions}" var="region" itemLabel="#{region.label}"/>
<f:ajax listener="#{enumBean.loadCities}" render="cities"/>
</h:selectOneMenu>
<h:outputText id="cities" value="#{enumBean.cities}"/>
</h:panelGrid>
</h:form>
It does send a POST with the selected Region, model gets updated correctly, but the <h:outputText>
Component is not rendered.
One of the backing beans:
@Named
public class EnumBean {
private List<Region> regions;
private List<City> cities;
@Inject
EnumBeanStatus enumBeanStatus; //This one is CDI @ApplicationScoped & @Named
// Code...
public void loadCities(){
setCities(City.getCitiesByRegion(enumBeanStatus.getSelectedRegion()));
}
// Getters and Setters
}
Upvotes: 1
Views: 1238
Reputation: 1108632
Remove prependId="false"
from the <h:form>
. It prevents <f:ajax>
from resolving the right component based on a relative client ID.
Upvotes: 4