3 Replies Latest reply on Sep 22, 2008 12:11 PM by Pete Muir

    RequestParameter annotated setter called many times

    davide ficano Newbie

      I've a setter method marked with @RequestParameter annotation all works fine but setter is called many times for single page .


      Is this a bug?
      Or simply I have made some error?

        • 2. Re: RequestParameter annotated setter called many times
          Mikael Andersson Master

          Hi


          (using Seam 2.0.1.GA)


          Pete could you elaborate on that please.


          Currently I have a usecase which doesn't seem to be doable with @RequestParameter because of the many invocations of the setter.




          • I have abacking bean which has a String riskDateStr property which has its setter annotated with the @RequestParameter.




          • The backing bean has an @Create annotated init method, in here I want to pull a Date from the session if riskDateStr is null. Here I also need to assign riskDateStr a String represantation of that date.



          What I notice is the following:


          2008/09/17 15:51:56,784 ===========  RESTORE_VIEW 1 Time spent = 0 seconds
          2008/09/17 15:51:56,846 Setting riskDateStr: null
          2008/09/17 15:51:56,846 Setting riskDateStr: 17/09/2008
          2008/09/17 15:51:57,830 Setting riskDateStr: null
          2008/09/17 15:51:57,830 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 getter riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 getter riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,862 Setting riskDateStr: null
          2008/09/17 15:51:57,909 Setting riskDateStr: null
          2008/09/17 15:51:57,909 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 getter riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:57,971 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,002 Setting riskDateStr: null
          2008/09/17 15:51:58,018 Setting riskDateStr: null
          2008/09/17 15:51:58,018 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,034 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,049 Setting riskDateStr: null
          2008/09/17 15:51:58,080 Setting riskDateStr: null
          2008/09/17 15:51:58,080 Setting riskDateStr: null
          2008/09/17 15:51:58,080 Setting riskDateStr: null
          2008/09/17 15:51:58,096 Setting riskDateStr: null
          2008/09/17 15:51:58,096 Setting riskDateStr: null
          2008/09/17 15:51:58,096 Setting riskDateStr: null
          2008/09/17 15:51:58,096 Setting riskDateStr: null
          2008/09/17 15:51:58,096 Setting riskDateStr: null
          2008/09/17 15:51:58,096 Setting riskDateStr: null
          2008/09/17 15:51:58,143 Setting riskDateStr: null
          2008/09/17 15:51:58,143 Setting riskDateStr: null
          2008/09/17 15:51:58,143 Setting riskDateStr: null
          2008/09/17 15:51:58,143 Setting riskDateStr: null
          2008/09/17 15:51:58,143 Setting riskDateStr: null
          2008/09/17 15:51:58,159 Setting riskDateStr: null
          2008/09/17 15:51:58,159 Setting riskDateStr: null
          2008/09/17 15:51:58,159 Setting riskDateStr: null
          2008/09/17 15:51:58,159 Setting riskDateStr: null
          2008/09/17 15:51:58,190 Setting riskDateStr: null
          2008/09/17 15:51:58,190 Setting riskDateStr: null
          2008/09/17 15:51:58,190 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,205 Setting riskDateStr: null
          2008/09/17 15:51:58,221 Setting riskDateStr: null
          2008/09/17 15:51:58,221 Setting riskDateStr: null
          2008/09/17 15:51:58,221 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,237 Setting riskDateStr: null
          2008/09/17 15:51:58,252 Setting riskDateStr: null
          2008/09/17 15:51:58,252 Setting riskDateStr: null
          2008/09/17 15:51:58,252 Setting riskDateStr: null
          2008/09/17 15:51:58,252 Setting riskDateStr: null
          2008/09/17 15:51:58,252 Setting riskDateStr: null
          2008/09/17 15:51:58,252 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,268 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,299 Setting riskDateStr: null
          2008/09/17 15:51:58,330 ===========  RENDER_RESPONSE 6 Time spent = 1 seconds
          



          The second setter invocation is from the @Create annotated method, but that value gets overwritten the other calls to the setter.


          To me it seems that the setter is called a couple of times to many :) and it would be excellent if the @RequestParameter setter invocations were done before the @Create init method was called.


          Is there an architectural reason it works the way it currently does?


          Perhaps a xzy.page.xml will work for me, haven't tried that yet but don't really want the file when annotations should work.



          • 3. Re: RequestParameter annotated setter called many times
            Pete Muir Master

            @RequestParameter is an injection point, so is called every time the component needs to be injected (each call).


            Lazy initialize the variable in the create method is the best bet (access the value programatically from the faceContext).


            You could file a FR to enhance @RequestParameter to have a if-not-null alike attribute.