문제

I have the following Facelets code with an update on the <p:growl> component after the saving action. But I have the following exception while rendering the page :

javax.servlet.ServletException: Cannot find component with expression ":principal:display" referenced from "mainForm:form1:j_idt27".

<ui:define id="principal" name="content">
    <p:growl id="display" showDetail="true" sticky="false" />

    <p:panel header="Gestion de projets">

        <h:form id="form1">
            <h:panelGrid columns="3">
                <h:outputText value="Nom du projet: *" />
                <p:inputText value="#{gestionProjetBean.nomProjet}"
                    required="true" label="Nom du projet" />
                <p:commandButton value="Save"
                    actionListener="#{gestionProjetBean.creerProjet(gestionProjetBean.nomProjet)}"
                    update=":principal:display" />
            </h:panelGrid>
        </h:form>
도움이 되었습니까?

해결책

I finally found the solution: it should be update=":mainForm:display"

For those who are facing the same problem, firebug helped me finding the real id of the component, by displaying the source code of the page and searching for my component on it.

There, I found this:

<div id="mainForm:msgs" class="ui-messages ui-widget" aria-live="polite"></div> <span id="mainForm:display"></span> <script id="mainForm:display_s" type="text/javascript"> $(function(){PrimeFaces.cw('Growl','widget_mainForm_display',{id:'mainForm:display',sticky:false,life:6000,escape:true,msgs:[]});}); </script>

Also don't forget to prepend the id by an ":" (because every id should start with the NamingContainer separator character ":")

다른 팁

don't use :principal:display try just :display

Try this give a id to the panel component and modify code like below

:panelid:display

this works for me.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top