3 Replies Latest reply on Mar 8, 2007 7:23 AM by Chico Chen

    Allways can't get he project value, bother me for 2 days

    Chico Chen Newbie

      pages.xml

      <navigation from-action="#{projectMaintAction.add}">
       <render view-id="/backend/project/projectAdd.xhtml" />
       </navigation>
      
      <page view-id="/projectAdd.xhtml"
       conversation-required="true">
       <navigation from-action="#{projectMaintAction.save}">
       <render view-id="/projectQuery.xhtml" />
       </navigation>
       </page>

      projectQuery.xhtml
      <h:commandLink id="addProject" value="Add Project" action="#{projectMaintAction.add}" propagation="true"/>

      ProjectMaintActionImpl.Add()
      @Stateful
      @Name("projectMaintAction")
      @Scope(ScopeType.CONVERSATION)
      @Restrict("#{identity.loggedIn}")
      public class ProjectMaintActionImpl implements ProjectMaintAction {
       @Begin
       public void add() {
       isCreation = true;
       project = new Project();
       }
      }

      projectAdd.xhtml

       <h:form>
       <h:inputText id="projectName"
       value="#{project.name}" />
      <h:commandButton type="reset" action="#" value="Reset" />
       </h:form>
      

      public void save() {
       if (isCreation == true){
       String aa = project.getName();
       projectMaintService.save(project);
       }
       }

      String aa = project.getName() return null, why?

        • 1. Re: Allways can't get he project value, bother me for 2 days
          Pete Muir Master

          I don't see you make project available as a Seam context variable anywhere.

          • 2. Re: Allways can't get he project value, bother me for 2 days
            Chico Chen Newbie

            thanks for your feedback!
            my actionbean:

            @Stateful
            @Name("projectMaintAction")
            @Scope(ScopeType.CONVERSATION)
            @Restrict("#{identity.loggedIn}")
            public class ProjectMaintActionImpl implements ProjectMaintAction {
            
             @In(required = false) @Out
             private Project project;
            
             //@In(value="projectMaintService", create=true)
             //public ProjectMaintService projectMaintService;
             @In
             private EntityManager entityManager;
            
             @In
             private FacesMessages facesMessages;
            
             @Logger
             private Log log;
            
             private boolean isCreation = false;
            
             public boolean isCreation() {
             return isCreation;
             }
             @Begin
             public void createProject() {
             isCreation = true;
             project = new Project();
             }
             @End
             public void saveProject() {
             if (isCreation == true){
             String aa = project.getName();
             entityManager.persist(project);
             }
             }
            
            
             @Destroy @Remove
             public void destroy() {
             }
             public void delete() {
             // TODO Auto-generated method stub
            
             }
             public void editProject() {
             // TODO Auto-generated method stub
            
             }
             public void updateProject() {
             // TODO Auto-generated method stub
            
             }
             public void viewProject() {
             // TODO Auto-generated method stub
            
             }
            
            }


            • 3. Re: Allways can't get he project value, bother me for 2 days
              Chico Chen Newbie

              it's ok now, my code come from different doc, it's my mistake.