1

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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Sinda MOKADDEM
  • 796
  • 2
  • 12
  • 35
  • It can't find the selector for it, look at your xhtml output to find the direct id - try just doing update="display" – VeenarM May 06 '14 at 10:44
  • @BalusC I've seen that post before posting my question and it helped me undertanding the findComponent mechanism but it doesn't helped me to find the solution for my problem, since I wasn't able to find the real id of my component. – Sinda MOKADDEM May 06 '14 at 17:25
  • Just do rightclick and *View Source* in browser? – BalusC May 06 '14 at 17:39
  • yes it displayed me all the components and their id in simple html – Sinda MOKADDEM May 06 '14 at 17:42

3 Answers3

2

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 ":")

Sinda MOKADDEM
  • 796
  • 2
  • 12
  • 35
  • It's illegal to nest forms. The other answer didn't expect that you were doing that. – BalusC May 06 '14 at 11:05
  • Ohhh thank you @BalusC, I totally forgot that I was using a template ` `. Ok that's where the mainForm id came from... Thank you very much, I though that it was a hidden component in primefaces... It's more clear now. but the solution still valid. – Sinda MOKADDEM May 06 '14 at 17:31
0

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

Blue Ocean
  • 282
  • 1
  • 10
0

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

:panelid:display

this works for me.

Ramakrishna
  • 426
  • 7
  • 26
  • this wouldn't work since the which id is "display" is outside the panel. But, anyway, I tried and (as expected) it doesn't work and throwed the same exception – Sinda MOKADDEM May 06 '14 at 13:58