1 Reply Latest reply on Oct 19, 2009 10:34 PM by blabno

    page parameter accesible

    Alexei R Newbie

      Hi I'm really new in seam, I'm trying to create a page for display data from an entity like this:


      BookEditManager.java




      @Name("bookEditManager")
      public class BookEditManager {
           @In EntityManager entityManager;
           @Logger     Log log;
           
           private Book book;
           
           private Integer bookId;     
           
           @Create
           public void initEditManager() {          
                log.info(this.bookId);
                
                if (this.bookId != null){
                     this.book = entityManager.find(Book.class, this.bookId);
                     if (this.book == null){
                          throw new org.jboss.seam.framework.EntityNotFoundException(this.bookId, Book.class);
                     }
                }else {
                     this.book = new Book();               
                }                    
           }



      and the page parameter




      <param name="bookId" value="#{bookEditManager.bookId}"/>




      When I request the url:





      http://localhost:8080/libraryProject/book/BookEdit.seam?bookId=2







      In the initEditManager the bookId parameter is null, my question is:



      When the initEditManager method is called, the bookId property it already has the value taken from the page parameter?.


      Which is the order of execution of this ?


      1. Constructor.
      2. Set page parameter.
      3. Call method annotated with @Create.


      Is this correct ?

        • 1. Re: page parameter accesible
          blabno Master

          No, @Create should be prior to setting parameters. Parameters are set via EL so component must be instantiated, which means @Create gets invoked before EL gets evaluated further.
          You cannot have bookId injected nor used in EL since it is not a property (no setters nor getters).