Dynamically change update attribute in Primefaces files

I was looking for a way to change the bean-based board command button refresh attribute after submitting the form. What I'm trying to achieve is update the identifier of the component based on the results of the bean method.

For example, I am trying to update the form and the lever message using the command button, now if some error occurred from the backup bean (not a validation error), I only need to update the growl message and the form should not be updated.

<p:commandButton value="Finish Editing"
        action="#{editBean.finish}" icon="ui-icon-check"
        style="width:200px;margin-left:60px;" update=":studentEditForm   :messageForm:applyMessages" />
0
source share
2 answers

You can use the software API through RequestContext#update().

public void finish() {
    // ...

    if (someCondition) {
         RequestContext.getCurrentInstance().update("someClientId");
    } else {
         RequestContext.getCurrentInstance().update("otherClientId");
    }
}             

Remember to remove the attribute updatefrom the command button.

+3
source

Change it

<p:commandButton value="Finish Editing"
        action="#{editBean.finish}" icon="ui-icon-check"
        style="width:200px;margin-left:60px;" update=":studentEditForm   :messageForm:applyMessages" />

to

<p:commandButton value="Finish Editing"
        action="#{editBean.finish}" icon="ui-icon-check"
        style="width:200px;margin-left:60px;" update="#{editBean.updateString}" />

EditBean .

-1

All Articles