users@glassfish.java.net

Re: Fwd: JSF2 and _at_Inject

From: Roger Kitain <roger.kitain_at_oracle.com>
Date: Sun, 27 Mar 2011 13:56:12 -0400

Can you provide the stack trace for the weld exception?
Also, I presume you have a beans.xml packaged in your war.
Are you using the @Named annotation for the CDI bean?
Here's a reference article you can look at:
http://blogs.sun.com/enterprisetechtips/entry/using_cdi_and_dependency_injection

-roger

On 3/25/11 6:55 PM, Dhiru Pandey wrote:
> Hi
>
> Could one of you please respond to this
>
> -------- Original Message --------
> Subject: JSF2 and @Inject
> Date: Thu, 24 Mar 2011 14:53:17 -0700
> From: emiddio-frontier <emiddio_at_frontier.com>
> Reply-To: users_at_glassfish.java.net
> To: <users_at_glassfish.java.net>
>
>
>
> 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


-- 
roger.kitain_at_oracle.com
https://twitter.com/rogerk09
http://www.java.net/blogs/rogerk