dynamic message from p: confirm - Primefaces

1

Can anyone tell me how I can change the message of <p:confirm> ? When I click the button I want the value of message to be returned by method messageCount() .

...

<p:outputLabel value="Teste:" />                        
<p:inputText value="#{testeController.campoTeste}" id="campoTeste"/>

...

<p:commandButton value="Ok" action="#{testeController.cadastrarTest()}">
    <p:confirm header="Confirmação" message="Confirmar?"/>
</p:commandButton>

 ...

<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
    <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
    <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>



...


public Integer messageCount() {
    return count++;
}
    
asked by anonymous 10.07.2015 / 21:26

1 answer

2

Declare a variable in your bean, String message = "Confirmar?"

Put an id in p: confirm, id="message" and also value="{{testeController.message}}"

This part of code {{testeController.message}} calls the method in its TestController class, getMessage() .

Change / implement the getMessage() method to make the modifications you need

    
10.07.2015 / 21:50