users@glassfish.java.net

JSF2 and _at_Inject

From: emiddio-frontier <emiddio_at_frontier.com>
Date: Thu, 24 Mar 2011 14:53:17 -0700

I am new to JSF and using @Inject --

I know one should use getters and setters with beans -- but I was doing learning code
so chose to try to access some non-public instance fields in the injected bean.

All beans are in same package.

in FilterBean the fields were declared like
Object new1Value;

the bean was annotated like
@Inject FilterBean fb;

FilterBean has an
Object getNew1Value(){} method

I am using CDI not JSF Managed Beans;

if the field -- Object new1Value, was declared: public Object new1Value -- i get deployment error - jboss weld complaint.

when I access the field -- fb.new1Value from the bean that FilterBean was injected into -- i rarely/never? see the value of the instance field;

if I use the getter, getNew1Value() -- i always to get the correct value returned.

Someone explain to me this behaviour -- or point me to some documentation explaining it;

Thanks
Gary