Search in sources :

Example 46 with PostConstruct

use of jakarta.annotation.PostConstruct in project faces by jakartaee.

the class Spec329 method init.

@PostConstruct
public void init() {
    entityList = new ArrayList<>();
    entityList.add(new Spec329Entity("one"));
    entityList.add(new Spec329Entity("two"));
    entityList.add(new Spec329Entity("three"));
    selectItemList = new ArrayList<>();
    selectItemList.add(new SelectItem("value1", "label1"));
    selectItemList.add(new SelectItem("value2", "label2"));
    selectItemList.add(new SelectItem("value3", "label3"));
}
Also used : SelectItem(jakarta.faces.model.SelectItem) PostConstruct(jakarta.annotation.PostConstruct)

Example 47 with PostConstruct

use of jakarta.annotation.PostConstruct in project faces by jakartaee.

the class UserBean method init.

@PostConstruct
private void init() {
    ApplicationAssociate appAss = ApplicationAssociate.getInstance(extContext);
    firstName = "" + appAss.getFaceletFactory().getRefreshPeriod();
}
Also used : ApplicationAssociate(com.sun.faces.application.ApplicationAssociate) PostConstruct(jakarta.annotation.PostConstruct)

Example 48 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ModeratorAction method execute.

@PostConstruct
public void execute() {
    try {
        // trying to get forumId from request parameter
        int forumId = -1;
        String f = getParameter(p_forumId);
        if (f != null && f.trim().length() > 0) {
            forumId = parseInt(f);
        }
        checkboxes = new HashMap<Integer, Boolean>();
        // grab the data to be displayed for this page
        if (forumId != -1) {
            // setup the business objects like the forum, topics etc that
            // will
            // be displayed
            forum = forumsModule.findForumById(forumId);
        } else {
            // trying to get forumId from topicId read from request
            String t = getParameter(p_topicId);
            if (t != null && t.trim().length() > 0) {
                TopicBean topic = forumsModule.findTopicById(parseInt(t));
                forum = topic.getForum();
            } else {
                String p = getParameter(p_postId);
                if (p != null && p.trim().length() > 0) {
                    PostBean post = forumsModule.findPostById(parseInt(p));
                    TopicBean topic = post.getTopic();
                    forum = topic.getForum();
                }
            }
        }
        if (forum != null) {
            topics = forumsModule.findTopics(forum);
            topicsDataModel = new ListDataModel<TopicBean>(topics);
        }
    } catch (ModuleException e) {
        log.error(e);
    }
}
Also used : PostBean(it.vige.rubia.dto.PostBean) ModuleException(it.vige.rubia.ModuleException) TopicBean(it.vige.rubia.dto.TopicBean) PostConstruct(jakarta.annotation.PostConstruct)

Example 49 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ViewMyForumsEditAllForums method execute.

/**
 */
@PostConstruct
public void execute() {
    Collection<ForumBean> forums = getWatchedForums();
    try {
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        forumWatches = forumsModule.findForumWatches(getUser(userModule), forumInstanceId);
    } catch (Exception e) {
        handleException(e);
        setForumWatches(new HashMap<Integer, ForumWatchBean>(0));
    }
    Date userLastLogin = getUserLastLoginDate(userModule, userProfileModule);
    for (ForumBean currentForum : forums) {
        // setup folderLook based on whats specified in the theme
        String folderImage = themeHelper.getResourceForumURL();
        // bundle key
        String folderAlt = "No_new_posts";
        if (forumsLastPosts != null && forumsLastPosts.containsKey(currentForum.getId())) {
            PostBean lastPost = (PostBean) forumsLastPosts.get(currentForum.getId());
            Date lastPostDate = lastPost.getCreateDate();
            if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
                // bundle key
                folderAlt = "New_posts";
                folderImage = themeHelper.getResourceForumNewURL();
            }
        }
        if (currentForum.getStatus() == FORUM_LOCKED) {
            folderImage = themeHelper.getResourceForumLockedURL();
            // bundle key
            folderAlt = "Forum_locked";
        }
        getForumImages().put(currentForum.getId(), folderImage);
        getForumImageDescriptions().put(currentForum.getId(), folderAlt);
    }
    try {
        String t = getRequestParameter(p_forumId);
        if (t != null && t.trim().length() > 0) {
            forumId = parseInt(t);
        } else {
            forumId = -1;
        }
        if (forumId != -1) {
            watch = forumsModule.findForumWatchByUserAndForum(getUser(userModule), forumId);
        }
    } catch (Exception e) {
        handleException(e);
        forumId = -1;
        watch = null;
    }
}
Also used : PostBean(it.vige.rubia.dto.PostBean) ForumBean(it.vige.rubia.dto.ForumBean) HashMap(java.util.HashMap) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) PostConstruct(jakarta.annotation.PostConstruct)

Example 50 with PostConstruct

use of jakarta.annotation.PostConstruct 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<TopicBean> stickies = getStickyThreads();
            // Getting announcements
            Collection<TopicBean> announcements = getAnnouncements();
            TopicRequestBean topicRequestBean = new TopicRequestBean();
            TopicBean topicBean = new TopicBean();
            topicBean.setForum(forum);
            topicBean.setType(NORMAL);
            topicRequestBean.setTopic(topicBean);
            topicRequestBean.setPerPage(MAX_VALUE);
            normalThreads = fm.findTopicsDesc(topicRequestBean);
            normalThreadsDataModel = new ListDataModel<TopicBean>(normalThreads);
            Collection<TopicBean> listOfTopics = new LinkedList<TopicBean>();
            listOfTopics.addAll(stickies);
            listOfTopics.addAll(announcements);
            listOfTopics.addAll(normalThreads);
            // Getting sticky topics for this page
            topicLastPosts = fm.findLastPostsOfTopics(listOfTopics);
            // topic minipaging
            for (TopicBean 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) {
            handleException(e);
        }
    }
}
Also used : TopicRequestBean(it.vige.rubia.dto.TopicRequestBean) PageNavigator(it.vige.rubia.ui.PageNavigator) ForumsModule(it.vige.rubia.ForumsModule) ModuleException(it.vige.rubia.ModuleException) LinkedList(java.util.LinkedList) TopicBean(it.vige.rubia.dto.TopicBean) PostConstruct(jakarta.annotation.PostConstruct)

Aggregations

PostConstruct (jakarta.annotation.PostConstruct)76 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 IOException (java.io.IOException)6 Date (java.util.Date)6 PostBean (it.vige.rubia.dto.PostBean)4 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)4 ArrayList (java.util.ArrayList)4 ForumBean (it.vige.rubia.dto.ForumBean)3 FacesContext (jakarta.faces.context.FacesContext)3 Method (java.lang.reflect.Method)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ApplicationAssociate (com.sun.faces.application.ApplicationAssociate)2 HTTPServer (io.prometheus.client.exporter.HTTPServer)2 ModuleException (it.vige.rubia.ModuleException)2 CategoryBean (it.vige.rubia.dto.CategoryBean)2 TopicBean (it.vige.rubia.dto.TopicBean)2 SessionScoped (jakarta.enterprise.context.SessionScoped)2 Typed (jakarta.enterprise.inject.Typed)2 ClientWindow (jakarta.faces.lifecycle.ClientWindow)2 Serializable (java.io.Serializable)2