0

I'm a beginner with JSF and I've a small problem, if I use a h:commandButton inside a c:forEach then it doesn't trigger the method but if I use it outside the c:forEach then it works. In my code below the "First test" works but not the "Second Test".

Do you guys have any idea why it doesn't work?

Thanks in advance

<p:panel>
    <h:panelGrid id="searchResult">
        <!--  First Test -->
        <h:commandButton value="ID" action="#{database.addShow(257655)}">
            <f:ajax execute="@this"/>
        </h:commandButton>

        <!--  Second Test -->
        <c:forEach items="#{theTVDB.series}" var="item">
            <h:panelGroup styleClass="searchResultElement" layout="block">
                <h:outputText value="#{item.name}"/><br/>

                <h:graphicImage value="#{item.banner}" />

                <h:commandButton value="#{item.id}" action="#{database.addShow(257655)}">
                    <f:ajax execute="@this"/>
                </h:commandButton>
            </h:panelGroup>
        </c:forEach>
    </h:panelGrid>
</p:panel>

Update : The answer in this Topic doesn't work

Community
  • 1
  • 1
Uric34
  • 9
  • 3
  • c:forEach change to ui:repeat – ooozguuur Jul 23 '15 at 12:07
  • Hey! Thank you both for your reply but I had already seen this topic and changing c:foreach to ui:repeat doesn't fix the problem. – Uric34 Jul 23 '15 at 12:11
  • Indeed, c:forEach vs ui:repeat alone doesn't matter. What matters more is bean scope and logic (specifically the `#{theTVDB}`). See point 4 of http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked – BalusC Jul 23 '15 at 12:36

0 Answers0