9 Replies Latest reply: Feb 3, 2010 3:35 AM by r035198x RSS

    jsf getter is calling more than once

    600229
      In my application i can see getter is calling more than once. I know this is due to JSF life cycle, but can i avoid that?
      is there any solution to make getter called only once? what will happen if i use immediate ="true"

      thanks in advance
        • 1. Re: jsf getter is calling more than once
          600229
          Sorry i think i should have to post in Jsf section
          • 2. Re: jsf getter is calling more than once
            EJP
            what will happen if i use immediate ="true"
            Wouldn't it be about a million times as efficient to try it? than to post in the wrong forum, or even the right forum, and still around waiting for an answer that may never come?
            • 3. Re: jsf getter is calling more than once
              r035198x
              debdutta wrote:
              In my application i can see getter is calling more than once. I know this is due to JSF life cycle, but can i avoid that?
              Why do you want to avoid it? If your getters merely return a value as they should then you won't need to change anything.
              what will happen if i use immediate ="true"
              You do have some documentation with you as you are developing to check on such things, right?
              • 4. Re: jsf getter is calling more than once
                600229
                No actually i wanted to know the effect of immediate ="true" over all , means will there be any problem with my data if i use that..
                • 5. Re: jsf getter is calling more than once
                  600229
                  actually why i want to avoid it becauase, in my getter what value i am getting that is from a xml node, and there is some code in getter which each time executing , i know its not standard to put any code in getter..but i have to do so becasue each variable is taking from a buffer position i can't change this logic / its not possible as per my project stucture .
                  So i just want to stop multiple time getter execution ...
                  • 6. Re: jsf getter is calling more than once
                    r035198x
                    debdutta wrote:
                    ...but i have to do so becasue each variable is taking from a buffer position i can't change this logic / its not possible as per my project stucture .
                    I'm not yet convinced of this.
                    Is your bean using request scope?
                    Why not get the value in a method (say init) called by the constructor of the bean?
                    If you need fresh data on the page you can invoke that init method each time.
                    • 7. Re: jsf getter is calling more than once
                      600229
                      My bean is in session scope.
                      I can't use one single init, because suppose i want to work with a variable , so only that value have to get from buffer, i can't call whole init in this case, so its requirement basic, why i have use that in getter means when ever that variable is refered , i can get the correct value from that buffer as i am not directly assigning value directly to that variable insatde of i am updating the buffer.
                      Actually this architecture i have used because this is a conversion project and this we have done to handle multiple redifination of the source language where suppose for example
                      0 to 5 position means variable A
                      0 to 8 means variable B
                      3 to 12 means variable C

                      nyway that is reason to use logic in getter and we have to stricked on that...
                      And my question is I am trying to find a solution to stop multiple time getter execution on a single request , [like page load or sometimes ajax based - only pertial part of pages will be rerender] ..so it is possible any way ..
                      "ejp" can i expect any solution if anyother people has faced same problem on this or it might never come...lets see
                      • 8. Re: jsf getter is calling more than once
                        r035198x
                        AJAX is pretty easy to integrate with JSF. Just add richfaces and use the a4j tags.
                        In fact I believe the latest JSF versions have built in support for AJAX without the need to add any other extensions.
                        • 9. Re: jsf getter is calling more than once
                          600229
                          I know how to use ajax and we already using different ajax based tag libraries like richfaces ..
                          I just wann some light on getter execution more than once