To interrupt and return to xhtml error to display in <p:messages>

Asked

Viewed 111 times

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" />

The messages of required="true" of inpuText work perfectly.

But when processing a commit in 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 cannot get the message to appear. Mine messages is an extended class of Facesmessages and in it when executed:

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

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>

Follow the code where the 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>
  • painel-dialog is the dialog id or a panel inside it?

  • Rafael is a <p:panelGrid>, of dialogue is item-dialog.

  • From what I see the problem may be in this oncomplete, I think it is closing regardless of its condition. You have tried to close just by your bean?

1 answer

0


I got a reply from a friend outside the OS. I implemented and it worked.

Follows:

import org.primefaces.context.RequestContext;

(...)

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.