You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by dushyant agarwal <ag...@yahoo.co.in> on 2009/01/30 05:55:15 UTC

[JSF] Should I initialize components in their getters.

Hi,
JSF components getters (getter methods of instances that are EL bound to JSF components in the JSPs) are called only during initial requests and I presume that they are used by the JSF framework to synchronize the JSF view tree on the server with the instances on the Backing beans (i.e. Both the tree and the Backing bean should refer to the same instances of components).

Now is it ethical / correct to set initial values to a component in their getter methods?

Thanks,
Dushyant



      Did you know? You can CHAT without downloading messenger. Go to http://in.webmessenger.yahoo.com/

Re: [JSF] Should I initialize components in their getters.

Posted by Kito Mann <ki...@virtua.com>.
Dushyant,

Sorry -- It's usually easier to set UI component properties in the setter
methods, as the JSF implementation has already created the instance of the
component for you. Otherwise you'll have to create the component instance
yourself, which normally isn't necessary.

---
Kito D. Mann -- Author, JavaServer Faces in Action
http://twitter.com/kito99
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
+1 203-404-4848 x3





On Fri, Jan 30, 2009 at 12:41 PM, Kito Mann <ki...@virtua.com> wrote:

> Dushyant,
>
> Sure, it's safe to set properties in the getter methods.
>
> ---
> Kito D. Mann -- Author, JavaServer Faces in Action
> http://twitter.com/kito99
> http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
> +1 203-404-4848 x3
>
>
>
>
>
>
> On Fri, Jan 30, 2009 at 12:55 AM, dushyant agarwal <
> agarwal_dushyant@yahoo.co.in> wrote:
>
>>  Hi,
>> JSF components getters (getter methods of instances that are EL bound to
>> JSF components in the JSPs) are called only during initial requests and I
>> presume that they are used by the JSF framework to synchronize the JSF view
>> tree on the server with the instances on the Backing beans (i.e. Both the
>> tree and the Backing bean should refer to the same instances of components).
>>
>> Now is it ethical / correct to set initial values to a component in their
>> getter methods?
>>
>> Thanks,
>> Dushyant
>>
>> ------------------------------
>> Unlimited freedom, unlimited storage. Get it now<http://in.rd.yahoo.com/tagline_mail_2/*http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/>
>
>
>

Re: [JSF] Should I initialize components in their getters.

Posted by Kito Mann <ki...@virtua.com>.
Dushyant,

Sure, it's safe to set properties in the getter methods.

---
Kito D. Mann -- Author, JavaServer Faces in Action
http://twitter.com/kito99
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
+1 203-404-4848 x3





On Fri, Jan 30, 2009 at 12:55 AM, dushyant agarwal <
agarwal_dushyant@yahoo.co.in> wrote:

> Hi,
> JSF components getters (getter methods of instances that are EL bound to
> JSF components in the JSPs) are called only during initial requests and I
> presume that they are used by the JSF framework to synchronize the JSF view
> tree on the server with the instances on the Backing beans (i.e. Both the
> tree and the Backing bean should refer to the same instances of components).
>
> Now is it ethical / correct to set initial values to a component in their
> getter methods?
>
> Thanks,
> Dushyant
>
> ------------------------------
> Unlimited freedom, unlimited storage. Get it now<http://in.rd.yahoo.com/tagline_mail_2/*http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/>