i made many to many join table between users and groups tables .
so i have a collection in each entitie ( Users and groups )
@ManyToMany(mappedBy = "usersCollection")
private Collection<Groups> groupsCollection;
and i want to display groups collection in Jsf thats what i did :
<p:dataTable var="user" value="#{usergestion.tableusers}">
<p:column headerText="username">
<h:outputText value="#{user.username}" />
</p:column>
<p:column headerText="nom">
<h:outputText value="#{user.nom}" />
</p:column>
<p:column headerText="prenom">
<h:outputText value="#{user.prenom}" />
</p:column>
<p:column headerText="groupe">
<h:outputText value="#{user.groupsCollection.get(0)}" />
</p:column>
and that what i get :
how i can get just the nombre not com.database.Groups[ idGroups=2 ] ???
Solution :
i used : <h:outputText value="#{user.groupsCollection.get(0).groupname}" />
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…