Conditional update in Primefaces/jsf
RequestContext.getCurrentInstance().update("clientId")
Helps for conditional updates.
For recaptcha try
RequestContext.getCurrentInstance().execute("Recaptcha.destroy()");
You can use a combination of JavaScript and RemoteCommand:
<p:commandLink action="#{bean.doIt()}" process="@form" update="@none" oncomplete="if(!args.validationFailed){updateMyImportantUI();}" />
<p:remoteCommand name="updateMyImportantUI" process="@this" update=":myImportantID" />
You can use a variable at the backing bean and use it on the xhtml part.
Like this:
update="#{backingMB.updateString}"
So, after the condition you can put the value for updateString
, but when you define it on the backingMB
, you need to put it as:
String updateString=""; // this will be id of the component to be updated
This way you won't get a NullPointerException.