List tbs = new ArrayList();
Iterator threadIterator = forum.threads(start,maxPageItems); //start,range
ThreadBean tb = null;
while (threadIterator.hasNext()) {
ForumThread currentThread = (ForumThread) threadIterator.next();
tb = new ThreadBean();
tb.setId(currentThread.getID());
tb.setForumID(forum.getID());
tb.setCreationDate(currentThread.getCreationDate());
tb.setModifiedDate(currentThread.getModifiedDate());
tb.setApproved(currentThread.isApproved());
tb.setNotApprovedMessages(currentThread.getMessageCount(false));
tb.setReplies(currentThread.getMessageCount() - 1);
tb.setTopic(currentThread.getName());
Message rootMessage = currentThread.getRootMessage();
MessageBean mb = new MessageBean();
mb.setAnonymous(rootMessage.isAnonymous());
UserBean ub = new UserBean();
if(!rootMessage.isAnonymous()){
User rootMessageUser = rootMessage.getUser();
ub.setId(rootMessageUser.getID());
ub.setUserName(rootMessageUser.getUsername());
ub.setName(rootMessageUser.getName());
ub.setEmail(rootMessageUser.getEmail());
}else{
//:NOTE: we suppose in front application : name & email message property for anonymous user
ub.setUserName(rootMessage.getProperty("name"));
ub.setEmail(rootMessage.getProperty("email"));
}
mb.setAuthor(ub);
tb.setRootMessage(mb);
tbs.add(tb);
}
request.setAttribute("tbs", tbs);
request.setAttribute("formatDatePattern", getResources(request).getMessage(getLocale(request),"dateformat"));