How to interrupt and return to xhtml error to display in p: messages

0

I have a processing of a <p:dialog> within this dialog I have a <p:messages> .

<p:messages id="msg-dialog" showDetail="true" autoUpdate="true" closable="true" />

Messages from required="true" of inpuText work perfectly.

But when processing a submission in the Bean for example:

    if (!ValidaCPF.isCPF(itemEdicao.getCpf())) {
            itemEdicao.setSituacao("I");
            messages.error("CPF Inválido!");
            msgErro = "CPF Inválido";
            RequestContext.getCurrentInstance().update(Arrays.asList("frm:msg-dialog","frm:itens-table"));
        }

I can not get the message to appear. My messages is an extended class of FacesMessages and in it when I execute:

messages.error() or messages.info() - the parameter (below the implementation) is sent

public void info(String message) {
    add(message, FacesMessage.SEVERITY_INFO);
}

public void error(String message) {
    add(message, FacesMessage.SEVERITY_ERROR);
}

How do I make xhtml recognize the error and do not close <p:dialog>

Here is the code where hide is executed:

<p:commandButton id="btn-salvar" value="Salvar"
    action="#{solicitacaoRHBean.salvarItem()}" process="item-dialog"
    disabled="#{solicitacaoRHBean.id == null}"
    oncomplete="if (! args.validationFailed) PF('edicaoItemDialog').hide()"
    update="msg-dialog painel-dialog itens-table">
</p:commandButton>
    
asked by anonymous 14.10.2015 / 16:23

1 answer

0

I received the response from a friend outside the OS. Implemented and worked.

Follows:

import org.primefaces.context.RequestContext;

(...)

RequestContext context = RequestContext.getCurrentInstance(); context.addCallbackParam("validationFailed", true);

    
14.10.2015 / 20:43