I’m trying to implement a composite component which will display the comments form an Array List.
<cc:interface>
<cc:attribute name="value" type="java.util.List" required="true" shortDescription="The list of objects that should be displayed"/>
</cc:interface>
<cc:implementation>
<ui:repeat var="comment" value="#{cc.attrs.commentList}">
<div class = "comment-block">
<h3>#{comment.title}</h3>
<h4>#{comment.author}</h4>
<p>#{comment.body}</p>
<h:link outcome = "editComment?id={comment.id}" value = "edit" />
</div>
</ui:repeat>
</cc:implementation>
Now the problem is that the tag should be displayed only if the logged user is the author of the comment. Normally I would do this like:
<c:if test = "${comment.authId == authUser.id}">
<a href = "editComment.jsp?id=${comment.id}">
</c:if>
How can I do something like this in JSF?
Most of JSF components have the attribute
renderedin which you can put an EL expression that returns either true or false. Based on the return value, the component will be rendered or not. In your case, you can try this: