0 Replies Latest reply on Apr 25, 2012 6:25 AM by thor-k

    @ViewConfig with @UrlMapping and EL-injected path parameters

    thor-k

      Hello, I have a simple @ViewConfig:

       

      @ViewPattern("/jsf/link/link.xhtml")

      @UrlMapping(pattern="/link/#{linkBean.token}")

       

      wich should set a String into a @Named Bean with EL-injected path paramter (http://ocpsoft.org/docs/prettyfaces/3.3.2/en-US/html/Configuration.html#config.pathparams.el):

       

      @Named @RequestScoped

      public class LinkBean implements Serializable

      {

          private String token;

          public String getToken() {return token;}

          public void setToken(String token) {this.token = token;logger.info("SET "+token);}

       

        @PostConstruct

        public void init() throws FileNotFoundException

        {logger.info("@PostConstruct: "+token); }

       

        @PreDestroy

        public void close() throws FileNotFoundException

        {logger.info("@PreDestroy: "+token); }

      }

       

      Actually this is working, but not in the ordering I expect:

       

      12:08:02,625 INFO  [LinkBean] (http--127.0.0.1-8080-6) @PostConstruct: null

      12:08:02,626 INFO  [LinkBean] (http--127.0.0.1-8080-6) SET 123

      12:08:02,677 INFO  [LinkBean] (http--127.0.0.1-8080-6) @PreDestroy: 123

       

      The parameter is set *after* the @PostConstruct? In my understanding (citing from http://stackoverflow.com/questions/1804778/jsf-1-2-does-postconstruct-execute-before-or-after-getters)

       

      1. Bean is constructed.
      2. Managed properties are set.
      3. @PostConstruct is called.
      4. Bean is brought in JSF lifecycle.

      Is this normal behaviour? How can I access the paramater in the @PostConstruct method?