Update message

Asked

Viewed 259 times

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 this:

My p:messages works perfectly when it is below the p:tab there in the update of p:commandButton i refer you by id. But in the above scenario it doesn’t work, that is, the message is not displayed on the screen. Does anyone know if this is possible? My update is wrong ?

  • try putting the <p:messages> as the direct daughter of <h:form>. As it is I believe that your message will never be displayed, because (if I’m not mistaken) <p:tabView> can only have <p:tab> as daughters.

1 answer

2


Tab is a JSF container If p:commandButton is inside the tab and p:messages is outside, you should not update the whole way. E.g. :listNext:messages

From what I could notice, except for lack of knowledge on my part, between tabview and tab really does not work.

Try to leave it outside the tab by leaving the globalOnly = "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 inside 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" />
  • I tried that even my example is like this.

  • 1

    Inspect how this html is at the end. I think the messages is either outside the container or inside a tab. Between tabViwer and tab I think it doesn’t really work.

  • I complemented the answer based on some tests I did.

  • Thanks for the tip, it turned out that the growl got better and is working.

Browser other questions tagged

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