2 Replies Latest reply on Apr 25, 2010 1:03 AM by Lucas Paes

    RequestParameter is null in Stateful SB

    alain hsiung Newbie

      The RequestParameter in my EntityHome (WebServiceHome) is working correctly.


      But when I transform this EntityHome in a Stateful SessionBean (adding @Stateful an implements the @Local interface)
      the same RequestParameter is always null!


      What am I doing wrong?


      The WebServiceHome Stateful SB:


      package com.csg.cs.wsrepository.session;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      
      import com.csg.cs.wsrepository.entity.WebService;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.web.RequestParameter;
      import org.jboss.seam.faces.Redirect;
      import org.jboss.seam.framework.EntityHome;
      
      
      
      
      @SuppressWarnings("serial")
      @Stateful
      @Name("webServiceHome")
      public class WebServiceHome extends EntityHome<WebService> implements WebServiceInterface
      {
         @RequestParameter String webServiceId;
         
          @Override
          public Object getId() {
               System.out.println("@RequestParameter webServiceId " + webServiceId);
               String webServiceId = (String) Redirect.instance().getParameters().get("webServiceId");
               System.out.println("@RequestParameter webServiceId " + webServiceId);
               if (webServiceId == null) {
                     return super.getId();
                } else {
                     return webServiceId;
                }
           }
              
          @Override
          public Class<WebService> getEntityClass() {
               setEntityClass(WebService.class);
               return WebService.class;
          }
          
          @Override @Begin
          public void create() {
               System.out.println("create webServiceId " + webServiceId);
               super.create();
               System.out.println("create webServiceId " + webServiceId);
           }
          
          public String persist()
          {
               String result = super.persist();
               System.out.println("**************** persist WebService");
               return result;
          }
      
          public String update()
          {
               String result = super.update();
               System.out.println("**************** update WebService");
               return result;
          }
          
          @Remove
          public String remove() {
               return "removed";
          }
      
      }