1 Reply Latest reply on Jan 17, 2007 6:13 PM by geeta sawant

    Using @Factory annotation

    geeta sawant Newbie

      I have a jsf page to edit user and a user can be a "supplier" or "admin".
      If logged in as a "supplier" user can edit his profile and If logged in as a "admin" user can edit other users.

      In EditUser.xhtml page I have single select list whose values are "supplier" or "admin" coming from a database. We call this list "eligibleGroups". Only admin can edit a users group.

      <t:selectOneMenu value="#{viewUser.selectedRoleId}" enabledOnUserRole="Administration">
      <f:selectItems value="#{eligibleGroups}" />
      </t:selectOneMenu>

      In seam action bean I have a method which intializes a list variable "eligibleGroups".

      @Out(scope = ScopeType.SESSION)
      private List eligibleGroups;

      @Factory("eligibleGroups")
      public void initializeGroups() {
      if (eligibleGroups == null) {

      eligibleGroups = new ArrayList();

      String queryStr = "from Role r ";
      Query query = em.createQuery(queryStr);
      List roles = query.getResultList();
      for (Role role : roles) {
      eligibleGroups.add(new SelectItem(role.getId(), role.getName()));
      }
      }
      }

      If I try to access any part of EditUser.xhtml page after session expires my code logic brings back a login page and after successfull login tries to show EditUser.xhtnl because that was the last request.

      However , before using @Factory annotation I was getting Error that eligibleGroups collection is null. So I decided to add a @Factory to the method which initializes variable "eligibleGroups".

      This is giving me a [java] java.lang.IllegalArgumentException: create method not found


      any help appreciated
      geeta