JSF Request Parameter in AJAX Form
I have a Page that is 开发者_StackOverflow中文版called with a request parameter id that is used to select the drop down elements
<h:selectOneMenu value="#{bean.selectedService}">
<f:selectItems value="#{bean.getServices(param.id)}" var="_s"
itemLabel="#{_s.description}" itemValue="#{_s.value}" />
<f:ajax render="@all" />
</h:selectOneMenu>
Is there any simple possibility that I can keep the param.id in the AJAX request. Currently it is lost.
Make it a view param instead.
<f:metadata>
<f:viewParam name="id" value="#{bean.id}" required="true" />
<f:event type="preRenderView" listener="#{bean.preRenderView}" />
</f:metadata>
with
@ManagedBean
@ViewScoped
public class Bean {
private Long id;
private List<Service> services;
public void preRenderView() {
if (services == null) {
services = getServices(id);
}
}
// ...
}
and
<f:selectItems value="#{bean.services}" ... />
精彩评论