0

I am learning Primefaces 6.1, and I want to update a ui:repeat component. According to Alexandre's answer, I need to wrap ui:component inside a component, such as h:panelGroup. However, when I run the project, there is an error says:

cannot find expression for component 'blogList'

Anyone knows why? Below is part of my code.

 <h:form>
     <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5" >
        <h:outputLabel value="Keyword: " for="keyword" />
        <p:inputText id="keyword" class="searchbox" value="#{viewManagedBean.keyword}"></p:inputText>

        <p:commandButton value="Search" actionListener="#{viewManagedBean.search(event)}" update="blogList"/>
     </h:panelGrid>

     <h:panelGroup id="blogList">
         <ui:repeat value="#{viewManagedBean.guestBlogs}" var="blog">
             <p:panel id="toggleable" header="#{blog.title}" footer="Created Date:#{blog.createdTime}" widgetVar="panel" style="margin-bottom:20px">
                 <h:outputText escape="false" value="#{blog.body}" style="font-weight: bold"/><hr />
             </p:panel>
         </ui:repeat>
     </h:panelGroup>
 </h:form>
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Yanjuan Duan
  • 81
  • 3
  • 13
  • Hi, 1 question per question please... And did you try the links provided by https://www.google.nl/search?q=cannot+find+expression+for+component+jsf? – Kukeltje Oct 05 '17 at 07:34
  • 1
    `widgetVar="panel"` should not work if `guestBlogs.size() > 1`, as `widgetVar`must be unique (per page) – jp-jee Oct 05 '17 at 09:15
  • @Kukeltje yeah, I tried with :blogList, still cannot. But when I tried again in the afternoon, it works. – Yanjuan Duan Oct 05 '17 at 10:39
  • @jp-jee thanks for your advice, actually, I did not need this attribute. Maybe I should delete it. – Yanjuan Duan Oct 05 '17 at 10:40

1 Answers1

0

Thanks for BalusC's answer of "how to address ID in primefae".

I add the id attribute in the h:form:

<h:form id="form">

and modify the update to

update=":form:dataList"

then it works!

Yanjuan Duan
  • 81
  • 3
  • 13