2 Replies Latest reply on May 20, 2009 5:16 PM by Jaime Martin

    Property 'kpassword' not found

    Sergio Szychowski Newbie

      Property 'kpassword' not found on type org.javassist.tmp.java.lang.Objec



      In my usuario.xhtml


           <s:decorate id="passwordField" template="/layout/edit.xhtml">
                      <ui:define name="label">Password</ui:define>
                      <h:inputText id="password" required="true"
                                   value="#{admUsuario.kpassword}"/>
                  </s:decorate>
      



      In my stateful Bean



      package org.promeba.session;
      
      
      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.List;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.ejb.TransactionAttribute;
      import javax.ejb.TransactionAttributeType;
      import javax.persistence.EntityManager;
      
      import org.jboss.seam.Component;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Create;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.security.Delete;
      import org.jboss.seam.annotations.security.Insert;
      import org.jboss.seam.annotations.security.Restrict;
      import org.jboss.seam.annotations.security.Update;
      import org.jboss.seam.annotations.web.RequestParameter;
      import org.jboss.seam.log.LogProvider;
      import org.jboss.seam.log.Logging;
      import org.jboss.seam.security.management.IdentityStore;
      import org.jboss.seam.security.management.JpaIdentityStore;
      import org.promeba.pojo.User;
      import org.promeba.pojo.UserLdap;
      import org.promeba.seguridad.CustomIdentityStore;
      
      @Stateful
      @Name("admUsuario")
      @Scope(ScopeType.SESSION)
      @Restrict("#{s:hasRole('admin')}")
      
      public class UserCrudBean implements CrudInt<UserLdap>, Serializable {
      
              @In(value="org.jboss.seam.security.identityStore",required=false, scope=ScopeType.APPLICATION)
              private IdentityStore identityStore;
      
         private static final LogProvider log = Logging.getLogProvider(UserCrudBean.class);    
              
              @RequestParameter 
              String userCodigo = null;
              
              private UserLdap user = null;
              private boolean managed = false;
              private List<UserLdap> resultList;
              private String searchString;
              private int maxResults;
              private String userpassword;
              private String userpassword2;
              
              @Create
              public void initBean() {
                      log.info("INITBEAN");
                      
                      if ( identityStore == null ) {
                              log.info("IDENTITY NULL");
                              identityStore = (IdentityStore) Component.getInstance(JpaIdentityStore.class);
                              if ( identityStore == null ) {
                                      log.info("IDENTITY NOT COMPONENT");
                                      
                              }
                              else {
                                      log.info("IDENTITY ");
                              }
                      }
                      else {
                              log.info("IDENTITY INJECTED");
                      }
              }
              
              
              public int getMaxResults() {
                      return maxResults;
              }
              
              public void setMaxResults( int maxResults) {
                      this.maxResults = maxResults;
              }
              
              public String getSearchString() {
                      return searchString;
              }
              
              public void setSearchString(String searchString) {
                      this.searchString = searchString;
              }
      
              public String getKpassword() {
                      return userpassword;
              }
              
              public String getKpassword2() {
                      return userpassword2;
              }
      
              public void setKpassword(String password) {
                      this.userpassword = password;
              }
              
              public void setKpassword2(String password2) {
                      this.userpassword2 = password2;
              }
      
              
              @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
              public UserLdap getInstance() {
                      if ( isManaged() ) {
                              if ( user == null ||
                                        ( userCodigo != null && ! user.getCodigo().equals(userCodigo))) {
                                      user = (UserLdap) ((CustomIdentityStore)identityStore).lookupUser(userCodigo);
                              }
                              else {
                                      log.info(user.getCodigo() + "==" + userCodigo );
      
                              }
                      }
                      else {
                              log.info("user not managed " );
                      }
                      
                      return user;
              }
              
              public void consulta() {
                      List<String> userNames = null;
                      if      (searchString != null && searchString.trim().length() > 0 ) {
                              userNames = identityStore.listUsers(searchString);
                      }
                      else {
                              userNames = identityStore.listUsers();
                      }
                      
                      this.resultList = new ArrayList();
                      
                      if ( userNames != null ) {
                              int res = 0;
                              for ( String auserName : userNames ) {
                                      
                                      Object auser = ((CustomIdentityStore)identityStore).lookupUser(auserName);
                                      if ( auser != null ){
                                              if ( res < getMaxResults() ) {
                                                      res++;
                                                      resultList.add((UserLdap) auser);
                                              }
                                              else {
                                                      break;
                                              }
                                      }
                              }       
                      }
                      
              }
      
              public boolean isManaged()
              {
                      log.info("managed:" + userCodigo +  ":" + managed );
                      if ( userCodigo != null) {
                              managed = true;
                      }
                      else {
                              if ( user == null ) {
                                      managed = false;
                                      user = new UserLdap();
                              }
                      }
                  return managed;
              }
      
              
              public void alta() {
                      log.info("persist::" + userCodigo + ":" + user.getCodigo() );
                      ((CustomIdentityStore)identityStore).createUser(user, userpassword);
                      managed = true;
                      if ( resultList == null ) {
                              resultList = new ArrayList<UserLdap>();
                      }
                      resultList.add(user);
              }
      
              @Restrict
              public void baja() {
                      log.info("baja");
                      try {
                              int ix = -1;
                              for ( int xx=0; xx < resultList.size(); xx++ ) {
                                      if ( resultList.get(xx).getCodigo().equals(user.getCodigo())) {
                                              ix = xx;
                                              break;
                                      }
                              }
                              if ( ix >= 0 ) {
                                      resultList.remove(ix);
                              }
                      }
                      catch(Exception e) {
                              log.debug(e);
                      }
                      ((CustomIdentityStore)identityStore).deleteUser(user);
              }
      
              public void setInstance(UserLdap user) {
                      this.user = user;
              }
      
              public void modifica() {
                      log.info("modifica");
                      ((CustomIdentityStore)identityStore).updateUser(user);
              }
              
              public void cancel() {
                      log.info("cancel");
                      managed = false;
              }
              
              public List getResultList() {
                      return resultList;
              }
      
              
          @Remove
          public void destroy() {
              
          }
      
              
      }
      


        • 1. Re: Property 'kpassword' not found
          Ambrish Singh Newbie

          Hi Sergio,


          You should replace the following fields



          private String userpassword;
          private String userpassword2;




          with these



          private String kpassword1;
          private String kpassword2




          And also declare getter/setter in the Interface CrudInt<UserLdap>.


          Thanks


          Ambrish

          • 2. Re: Property 'kpassword' not found
            Jaime Martin Apprentice

            Sergio,
            in spite of having a method called getKpassword, you have no property called kpassword.
            Try one of the following ways::
            - rename your userpassword member to kpassword
            - keep userpassword member, but create a getter (called getUserpassword) and then acces to it this way


             <s:decorate id="passwordField" template="/layout/edit.xhtml">
                            <ui:define name="label">Password</ui:define>
                            <h:inputText id="password" required="true"
                                         value="#{admUsuario.userpassword}"/>
                        </s:decorate>
            



            In order to avoid problems with frameworks I advise you to call a member´s getter getMember, and its setter, setMember.
            For example, in your case:


            private String userpassword;
            
                public String getUserpassword() {
                    return userpassword;
                }
            
                public void setUserpassword(String userpassword) {
                    this.userpassword = userpassword;
                }