3 Replies Latest reply on Jun 1, 2011 3:52 AM by Kike Gil

    How to initiate a list

    pankaj jain Newbie

      Hi,

       

      I am developing a web applicaiton in which very first page contains two included jsp pages

      1. login page

      2. List of topics

       

      properties of above two pages are associated with UserBean which is managed bean and having session scope.

       

      When user hits url for this application above page should be appear. But my problem is list of topics is arrayList  associated with UserBean whose instance is being created when user hits url for application.I need to pre initialize that list and needs to show the user when he will hit url. So how can I achieve that

       

      For visualization I am attaching image

       

        • 1. Re: How to initiate a list
          Kike Gil Novice

          in the constructor of bean, you can initialize arraylist

          • 2. Re: How to initiate a list
            pankaj jain Newbie

            Thanks for your reply.. I did that but another problem stroke at that time. UserBean is class , a managed bean, which handles login and logout action as well. When there is login no problem occurs as it's instance is already created and ready for further navigation . But when log out action has been fired I have to remove UserBean's instance from session using following code

             

            HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

            req.getSession().removeAttribute("UserBean");

             

            So when UserBean is being removed a topic list is already associated with it is also get removed. After log out , index page should appear with topic list and login page as I described earlier. So How can I achieve log out action then .............

            • 3. Re: How to initiate a list
              Kike Gil Novice

              try include the list in postconstructor:

               

               

               

              @PostConstruct

               

              public void something(){

              System.out.println("Works"

              );

              }

               

              This way, always the bean is created this function is executed