users@glassfish.java.net

Re: Fwd: JSF2 and _at_Inject

From: emiddio-frontier <emiddio_at_frontier.com>
Date: Sun, 27 Mar 2011 11:45:58 -0700

I did not get an Exception -- there were no reported errors of any kind.

yes have beans.xml packaged in war.

the bean to be accessed is annotated @javax.inject.Named("filter");
its class name is FilterBean

the bean accessing FilterBean uses
@javax.inject.Inject private FilterBean fb;

fb.newOneValue always gets null without any exceptions.

fb.getNewOneValue always gets the correct value

I will study your doc reference.

thanks

gary

  ----- Original Message -----
  From: Roger Kitain
  To: users_at_glassfish.java.net
  Sent: Sunday, March 27, 2011 10:56 AM
  Subject: Re: Fwd: JSF2 and @Inject


  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