Search in sources :

Example 1 with ForumsModule

use of it.vige.rubia.ForumsModule in project rubia-forums by flashboss.

the class ViewForum method execute.

/**
 */
@PostConstruct
public void execute() {
    // parse the input parameters
    int forumId = -1;
    String f = getParameter(p_forumId);
    if (f != null && f.trim().length() > 0) {
        forumId = parseInt(f);
    }
    // ForumsModule is stored as a final variable so that anonymous
    // class
    // could use it.
    final ForumsModule fm = forumsModule;
    // grab the data to be displayed for this page
    if (forumId != -1) {
        // be displayed
        try {
            forum = fm.findForumById(forumId);
            // Getting sticky topics for this page
            Collection<Topic> stickies = getStickyThreads();
            // Getting announcements
            Collection<Topic> announcements = getAnnouncements();
            normalThreads = fm.findTopicsDesc(forum, NORMAL, 0, MAX_VALUE);
            normalThreadsDataModel = new ListDataModel<Topic>(normalThreads);
            Collection<Topic> listOfTopics = new LinkedList<Topic>();
            listOfTopics.addAll(stickies);
            listOfTopics.addAll(announcements);
            listOfTopics.addAll(normalThreads);
            // Getting sticky topics for this page
            topicLastPosts = fm.findLastPostsOfTopics(listOfTopics);
            // topic minipaging
            for (Topic cour : listOfTopics) {
                if (cour.getReplies() > 0) {
                    PageNavigator topicNav = new PageNavigator(cour.getReplies() + 1, // this
                    userPreferences.getPostsPerTopic(), // current page of the navigator
                    0) {

                        /**
                         */
                        private static final long serialVersionUID = 6277599446838264687L;

                        protected Collection<Integer> initializePage() {
                            return null;
                        }
                    };
                    topicNavigator.put(cour.getId(), topicNav);
                }
            }
        } catch (ModuleException e) {
            log.error(e);
        }
    }
}
Also used : PageNavigator(it.vige.rubia.ui.PageNavigator) ForumsModule(it.vige.rubia.ForumsModule) Topic(it.vige.rubia.model.Topic) ModuleException(it.vige.rubia.ModuleException) LinkedList(java.util.LinkedList) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ForumsModule (it.vige.rubia.ForumsModule)1 ModuleException (it.vige.rubia.ModuleException)1 Topic (it.vige.rubia.model.Topic)1 PageNavigator (it.vige.rubia.ui.PageNavigator)1 LinkedList (java.util.LinkedList)1 PostConstruct (javax.annotation.PostConstruct)1