JSF add a commandLink tag or outputText tag depand on a boolean flag
I have a userBean
object with name
, id
, boolean isConnected
.
I built a login page using JSF. If one login successfully, the next page is a table of all users (name, id)
What I want is on the column of the user who logged in his id will be shown in a h:commandlink
, and the rest of the users id will be in an h:outputText
tag.
When the user logged in his isConnected
flag (boolean
) is true
and all other users are false
.
Is there a way to insert a different tag depand on a certain flag like mine? Something like call a method开发者_如何学Go on my managerBean
that will send a different string depending on the user flag on the page init
.
The simplest way is probably to use the rendered
attribute of the outputText
and commandLink
tags.
For example, something like the following:
...
<h:dataTable value="#{myBean.users}" var="user">
...
<h:column>
<h:commandLink rendered=#{user.connected} value="#{user.id}"/>
<h:outputText rendered=#{!user.connected} value="#{user.id}"/>
</h:column>
...
</h:dataTable>
...
精彩评论