Reputation: 14287
JSF Page:
<p:commandButton>
<p:ajax process="@this" update="name desc msg"
listener="#{bean.deleteListener}"/>
</p:commandButton>
Bean:
public void deleteListener() {
if (data.size() == 0) {
// updates only "msg"
setMsg("There is no data to delete");
return;
}
setMsg("Data deleted.");
// and updates the bean values for "name" and "desc" also.
...
}
Is it possible to conditionally update for an ajax call based on ajax listener logic. I would like to update the client ids "name desc msg" conditionally as shown in the listener code below (note this is a sample scenario in a larger application). The application uses Primefaces 5. Thanks.
Upvotes: 0
Views: 2628
Reputation: 12337
Sure, use the PrimeFaces RequestContext in your listener
RequestContext context = RequestContext.getCurrentInstance();
//update panel
context.update("form:panel");
See also: - http://www.primefaces.org/showcase/ui/misc/requestContext.xhtml
Upvotes: 2