PrimeFaces: conditional update during validation

Is it possible to conditionally update JSF components only after a successful check?

I would like to be able to do something like

<p:commandLink process="@form" listener="#{foo}" 
  update="something somethingElse"> 

where "something" is updated only if the check is successful.

Is there a way that may be performed or simply not supported in JSF?

I was able to fine tune the hack with hidden commands, but not completely satisfied:

<p:commandLink process="@form" listener="#{foo}" 
  update="somethingElse" oncomplete="if (!args.validationFailed) $("#link").click();">
<p:commandLink style="display:none" id="link"
  update="something">
+2
source share
2 answers

For this I intend <h:message>(or an analogue of PrimeFaces <p:message>). Or, in your case, it might be better <h:messages>(or <p:messages>).

public void submit() {
    // ...

    if (fail) {
        FacesContext.getCurrentInstance().addMessage(null, 
            new FacesMessage(FacesMessage.SEVERITY_ERROR, "Fail", null));
    }
}

with

<h:messages id="messages" />
<p:commandLink process="@form" action="#{bean.submit}" update="messages something" />

, Validator . ValidatorException, . - .

+2

, message . , - , message?

, , , - remotecommand.

<p:remoteCommand id='good' update='goodUpdates'/>  
<p:remoteCommand id='bad' update='badUpdate'/>  
<p:commandButton oncomplete='if (your-test) good() else bad()'/>  

, , , , .

+2

All Articles