, , , .
, , <ui:repeat>
size
, bean, . EL, . , EL #{5}
. , , , , , , , ?
, JSF <ui:repeat>
, . , .
, .
, . <ui:repeat>
, . JSF bean . <ui:param>
<ui:fragment>
. .
:
<p:dataTable value="#{statusBean.statusesList}" var="status">
<p:column headerText="Status name">
<h:outputText value="#{status.statusName}"/>
</p:column>
<p:column headerText="Status comments">
<ul>
<ui:param name="max" value="#{status.numOfComments}"/>
<ui:repeat var="comment" value="#{status.commentList}" varStatus="statusVar">
<ui:fragment rendered="#{statusVar.index lt max}">
<li>
<h:outputText value="Author: #{comment.authorName}; comment: #{comment.description}"/>
</li>
</ui:fragment>
</ui:repeat>
</ul>
</p:column>
</p:dataTable>
:
public class Comment {
private String authorName;
private String description;
}
public class Status {
private List<Comment> commentList;
private int numOfComments;
private String statusName;
}
bean:
@ManagedBean
@RequestScoped
public class StatusBean {
private List<Status> statusesList;
public StatusBean() {
Status status;
List<Status> statusesList = new ArrayList<Status>();
Comment comment;
List<Comment> commentList;
for(int s = 0; s < 10; s++) {
commentList = new ArrayList<Comment>();
for(int c = 0; c < 20; c++) {
commentList.add(new Comment("User " + (s + 1) + "-" + (c + 1), "Description for comment " + (s + 1) + "-" + (c + 1)));
}
statusesList.add(new Status(commentList, (s + 1), "Status " + (s + 1)));
}
this.statusesList = statusesList;
}
}
,
, , , .
- :
@ManagedBean
@...Scoped
() @Entity
, bean; - , . bean: ,
Status
; - beans, () (Servlet 3.0)
preRenderView
(Servlet 2.5) @PostConstruct
. bean. BalusC ; - : , ? , (, " ", ajax ).
size="..."
; - , Primefaces, Luiggi Mendoza.
bean :
@ManagedBean
@RequestScoped
public class StatusBean {
private List<Status> statusesList;
@EJB
private StatusService statusService;
@ManagedProperty(value="#{user}")
private User user;
@PostConstruct
public void init() {
statusesList = statusService.getStatuses(user);
}
public List<Status> getStatusesList() {
return statusesList;
}
}