4 Replies Latest reply on Jul 28, 2006 3:04 PM by Basel Al-Mustafa

    Cannot get @In and @Out to work with a stateless component

    Basel Al-Mustafa Newbie

      I have an Entity bean called PaperDetails and a page called newartwork.jsf which can be used to create a new PaperDetails.

      @Entity(name="gs_paper_details")
      public class PaperDetails implements Serializable{
       @Id
       private int id;
      
       @NotNull
       private String title;
      }
      
      <form action="uploaded.jsf" method="post" enctype="multipart/form-data">
       <h:inputText id="title" value="#{newPaperDetails.title}"/>
       <input type="submit" value="Upload Files"/>
      </form>
      


      There is a page action under pages.xml that is used to create the newPaperDetails component:
      <page view-id="/newartwork.jsf" action="#{fileUploadAction.initPaperDetails}"/>
      


      The FileUploadAction component is used to create and outject the newPaperDetails component. Also, it handles the upload action after the user enters the data of the new PaperDetails in the newartwork.jsf page.
      <page view-id="/uploaded.jsf" action="#{fileUploadAction.upload}"/>
      
      @Name("fileUploadAction")
      @Scope(ScopeType.STATELESS)
      public class FileUploadAction{
       //@In(required=false)
       @In(required=false, value="newPaperDetails")
       @Out(value="newPaperDetails")
       private PaperDetails paperDetails;
      
       public void initPaperDetails(){
       log.info("Creating a new paperDetails-120");
       paperDetails = new PaperDetails();
       if(paperDetails == null)
       log.info("initPaperDetails[papreDetails is null]");
       }
      
       public String upload(){
       this.initComponent();
      
       if(paperDetails == null){
       log.info("upload[papreDetails is null]");
       return null;
       }
       }
      }
      


      However, the newPaperDetails is gone and its value is set to null when I try to upload a new artwork. This causes the @Out annotation to complain as shown in stack trace below:

      StackTrace after accessing the newartwork.jsf page:
      13:59:21,920 INFO [Pages] reading pages.xml
      13:59:22,200 INFO [FileUploadAction] Creating a new paperDetails-120
      
      
      StackTrace after calling the upload method:
      13:59:56,270 INFO [FileUploadAction] upload[papreDetails is null]
      13:59:56,270 INFO [FileUploadAction] PD is null
      13:59:56,273 ERROR [STDERR] Jul 28, 2006 1:59:56 PM com.sun.faces.lifecycle.LifecycleImpl phase
      WARNING: phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@7ce229be) threw exception: javax.faces.el.EvaluationException: org.jboss.seam.RequiredException: Out attribute requires value for component: fileUploadAction.newPaperDetails org.jboss.seam.RequiredException: Out attribute requires value for component: fileUploadAction.newPaperDetails
      com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
      org.jboss.seam.core.Pages.callAction(Pages.java:161)
      org.jboss.seam.core.Pages.callAction(Pages.java:143)
      org.jboss.seam.jsf.AbstractSeamPhaseListener.callPageActions(AbstractSeamPhaseListener.java:128)
      org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:98)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:50)
      org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.beforePhase(SeamExtendedManagedPersistencePhaseListener.java:38)
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:249)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Thread.java:595)
      13:59:56,311 INFO [SeamExceptionFilter] killing transaction
      


      I even tried to use the getInstance method of the Component class but with no luck.
      public String upload(){
       PaperDetails pd = (PaperDetails)Component.getInstance("newPaperDetails");
       if(pd == null){
       log.info("PD is null");
       }
      }
      


      I tried to used different scope types for the newPaperDetails component but with no avail. I would truly appreciate your help guys.