Answer the question
In order to leave comments, you need to log in
How to properly use foreach loops in jsf?
Good afternoon.
There was such a problem: from the database I get a string of words separated by a comma. In the entity itself (entity) there are links with a one-to-many relationship, so using the DTO pattern does not work (or I just don’t understand how).
When displaying on a page, I need to display each word as a separate link. the roof is already moving, but the result is still no: - I tried to use a separate bin for the transformation -
@Stateless
@ManagedBean(name = "dtFileHelper")
public class FileHelper {
public List<String> myName(String name) {
String[] oneName;
List<String> rez1=new ArrayList<>();
oneName = name.split(",");
for (String nam:oneName) {
rez1.add(nam);
}
return rez1;
}
}
<p:column headerText="Видеозаписи">
<c:forEach var="fname" items="#{dtFileHelper.myName(file.name)}">
<h:outputText value="#{fname}"/><br/>
</c:forEach>
</p:column>
Answer the question
In order to leave comments, you need to log in
In general, it turned out that the problem lies in a slightly different one - the datagrid was initially filled in a lazy style, then I had to use ui: repeat and it all worked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question