I am developing commenting structure similar to facebook. Inside <ui:repeat>
I have placed a form and I expect that when I click on a command link within that form, it should submit the form which is the command link containing. But what I get is that the action of every link is invoked on click of a single link.
The backing bean is @ViewScoped
. I am using Mojarra 2.1.7.
How is this caused and how can I solve it? Is this problem related to the <h:form>
tag?
<ui:repeat var="parentComment" value="#{commentTree.parentComments}">
<h:form>
<ul>
<li>
#{parentComment.comment}<br />
<span class="small darkblue">#{parentComment.userNodeImpl.firstName} #{parentComment.userNodeImpl.lastName}</span>
<span class="small darkblue">#{parentComment.commentTime}</span>
<ui:repeat var="childComment" value="#{commentTree.getChildComments(parentComment)}">
<ul>
<li>
#{childComment.comment}<br />
<span class="small darkblue">#{childComment.userNodeImpl.firstName} #{childComment.userNodeImpl.lastName}</span>
<span class="small darkblue">#{childComment.commentTime}</span>
</li>
</ul>
</ui:repeat>
<div class="small darkblue">
<h:commandLink value="comment" action="#{commentTree.saveChildComment(parentComment)}" />
</div>
</li>
</ul>
</h:form>
</ui:repeat>