質問

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