5 Replies Latest reply on Jun 1, 2011 7:10 PM by Ozzy Ozz

    Extending Identity in SEAM 2.2.1

    Ozzy Ozz Newbie

      I am pretty new to SEAM and could use some help with extending Identity. Basically I am trying to save the user id (and later more info related to the user).


      SEAM 2.2.1
      jboss 6.0.0


      This is the code I have under classes/hot/com/mydomain/action/CustomIdentity.class



      package com.mydomain.action;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Install;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.Startup;
      import org.jboss.seam.annotations.intercept.BypassInterceptors;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.security.Identity;
      
      @Name("org.jboss.seam.security.identity")
      @Scope(ScopeType.SESSION)
      @Install(precedence = Install.APPLICATION)
      @BypassInterceptors
      @Startup
      public class CustomIdentity extends Identity {
      
              private int userId;
              @Logger private Log log;
      
              @Override
              public boolean isLoggedIn() {
                      //log.info("---------------------------- is LoggedIn ");
                      return super.isLoggedIn();
              }
      
              public int getUserId() {
                      return userId;
              }
      
              public void setUserId(int userId) {
                      this.userId = userId;
              }
      
      }
      




      Under the authenticate method I try to set the user id using



      identity.setUserId(user.getRecid());
      



      The two errors I see are
      1. @Name(org.jboss.seam.security.identity) - Duplicate component name: org.jboss.seam.security.identity
      2. Under the authenticate method it says setUserId is undefined.


      Can someone kindly tell me what I'm doing wrong?