[jboss-user] [JBoss Seam] - Using @Factory annotation

gsawant do-not-reply at jboss.com
Wed Jan 17 17:06:08 EST 2007


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 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003058#4003058

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003058



More information about the jboss-user mailing list