Search in sources :

Example 1 with PageNavigator

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

the class ViewMyForumsBase method execute.

/**
 * @throws Exception
 *             an error exception is launched
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public void execute() throws Exception {
    Collection<Topic> topics = getWatchedTopics();
    // minipaging
    if (topics != null) {
        for (Topic courTopic : topics) {
            if (courTopic.getReplies() > 0) {
                PageNavigator topicNav = new PageNavigator(courTopic.getReplies() + 1, // this
                getUserPreferences().getPostsPerTopic(), // current page of the navigator
                0) {

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

                    protected Collection<Integer> initializePage() {
                        return null;
                    }
                };
                topicNavigator.put(courTopic.getId(), topicNav);
            }
        }
    }
}
Also used : PageNavigator(it.vige.rubia.ui.PageNavigator) Topic(it.vige.rubia.model.Topic) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 2 with PageNavigator

use of it.vige.rubia.ui.PageNavigator 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

Topic (it.vige.rubia.model.Topic)2 PageNavigator (it.vige.rubia.ui.PageNavigator)2 ForumsModule (it.vige.rubia.ForumsModule)1 ModuleException (it.vige.rubia.ModuleException)1 SecureActionForum (it.vige.rubia.auth.SecureActionForum)1 LinkedList (java.util.LinkedList)1 PostConstruct (javax.annotation.PostConstruct)1 Interceptors (javax.interceptor.Interceptors)1