Refresh message

1

I have the following screen:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<ui:composition template="/layout/template.xhtml">
    <ui:define name="content">
        <h:form id="listaEncomendas">
            <p:tabView id="viewFull">
                <p:messages id="messages" showDetail="true" autoUpdate="true" closable="false" globalOnly="true" />
                <p:tab title="PENDENTES">
                    <p:panel id="horizontal" header="Cadastrar Encomenda" toggleable="true" toggleOrientation="horizontal"
                        toggleTitle="Cadastrar Encomenda" collapsed="true">
                        <h:panelGrid id="cadastro" columns="3">
                            <p:outputLabel value="Código" for="codigo" />
                            <p:inputText id="codigo" value="#{encomendaController.encomenda.codigo}" required="true" />
                            <p:message for="codigo" />
                            <p:outputLabel value="Loja/Origem" for="loja" />
                            <p:selectOneMenu id="loja" value="#{encomendaController.encomenda.loja}" required="true">
                                <f:selectItem itemLabel="" itemValue="" />
                                <f:selectItems value="#{enumHelper.obterLojas()}" var="bean" itemLabel="#{bean.nome}" itemValue="#{bean.nome}" />
                            </p:selectOneMenu>
                            <p:message for="loja" />
                            <p:commandButton value="Cadastrar" action="#{encomendaController.salvar}" update="cadastro,:listaEncomendas:viewFull:messages" />
                        </h:panelGrid>
                    </p:panel>
                    <p:spacer height="10px" />
                    <p:dataTable id="resultadoPendentes" rows="10" paginator="true">
                        <p:column styleClass="botoesGrid">
                            <p:commandButton icon="ui-icon-pencil" />
                            <p:commandButton icon="ui-icon-trash" />
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <p:outputLabel value="Código" />
                            </f:facet>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <p:outputLabel value="Situação" />
                            </f:facet>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <p:outputLabel value="Data/Hora Ocorrência" />
                            </f:facet>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <p:outputLabel value="Loja" />
                            </f:facet>
                        </p:column>
                    </p:dataTable>
                </p:tab>
                <p:tab title="ENTREGUES">
                </p:tab>
                <p:tab title="TODAS">
                </p:tab>
            </p:tabView>
        </h:form>
    </ui:define>
</ui:composition>
</html>

What happens is as follows:

My p:messages works perfectly when it is below p:tab there in the p:commandButton update I refer to it by id. But in the scenario above does not work, ie the message is not displayed on the screen. Does anyone know if this is possible? Is my update wrong?

    
asked by anonymous 21.03.2017 / 15:04

1 answer

2

Tab is a JSF container If the p: commandButton is inside the tab and the p: messages outside you should in the update inform the whole path. Ex .: list Orders: messages

As far as I could tell, except for lack of knowledge on my part, between the tabView and tab does not really work.

Try leaving out the tab by leaving the global parameterOnly="false"

<p:messages id="messages" showDetail="true" autoUpdate="true" closable="false" globalOnly="false" />
<p:tabView id="viewFull">
        <p:tab title="PENDENTES">
         ...
         <p:commandButton value="Cadastrar"  update="cadastro,:listaEncomendas:messages" />

Or within the desired Tab.

<p:tabView id="viewFull">
        <p:tab title="PENDENTES">
             <p:messages id="messages" showDetail="true" autoUpdate="true" closable="false" globalOnly="false" />
              ...
             <p:commandButton value="Cadastrar"  update="cadastro,:listaEncomendas:viewFull:messages" />
    
21.03.2017 / 15:56