2 Replies Latest reply on Apr 13, 2009 3:48 AM by zwz mycoy

    HELP passing parameters between pages

    zwz mycoy Newbie

      Hi, everyone:
         I'm trying to pass parameters between page. For example, i pass an id from home.jsp to a seam component in which i do some DB query according the parameter and then redirect to another page.  But i cannot get the queried result.


         the start page:


      <f:view>
         <h:form prependId="false">
             <h:inputText id="id" value="#{testId}"></h:inputText>
             <h:commandLink action="#{test_statefull.turn}">
                 <h:outputText value="CommandLink"></h:outputText>
             </h:commandLink>
         </h:form>
      </f:view>



          the seam component:


      @Stateful
      @Name("test_statefull")
      @Scope(ScopeType.CONVERSATION)
      public class TestAction_Stateful implements TestStatefull{
           @PersistenceContext(type = EXTENDED)
           private EntityManager em;
      
           @DataModel
              //@Out
           private List testList; //=new LinkedList();     
           
           @In(required=false)
           @Out(required=false)
           private String testId;
           
           @Begin(join=true)
           public String turn(){
                System.out.println("%%%%%%%%%%%%%%%%  "+testId);
                
                testList=new LinkedList();
                if(testId.equals("1")){
                     testList.add(1);
                     testList.add(11);
                }
                else if(testId.equals("2")){
                     testList.add(2);
                     testList.add(22);
                }
                else{
                     testList.add(3);
                     testList.add(33);
                     testList.add(333);
                }
                
                return "turn";
           }
           
           @Remove
           public void destroy(){
                
           }
      }



          the result page:


      <f:view>
              <h:dataTable border="0" value="#{testList}" var="ll">
                <h:column id="column1">
                     <h:outputText value="#{ll}"></h:outputText>
                </h:column>                    
           </h:dataTable>
      </f:view>



          in the result page, i always get nothing.
          I have tried add a factory method into the seam component:
      @Factory(testList)


      public void find(){          
           System.out.println("%%%%%%%%%%%%%%%%  "+testId);
           System.out.println("%%%%%%%%%%%%%%%%  "+testList);
      }



          But both the testId and testList are null.
          I have also tried seam-pojo and stateless-session-bean as the component and tried default scope, but all failed.
          Could anyone help me? Thanks a lot.