0

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.

prasad_
  • 12,755
  • 2
  • 24
  • 36

1 Answers1

2

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

Kukeltje
  • 12,223
  • 4
  • 24
  • 47