Skip to main content

JSR 330 Style Injection Support For JSF Managed Beans

Posted by rogerk on July 23, 2010 at 10:58 AM PDT

One of the features that had been lacking in JSF has been the ability to use the JSR 330 @Inject annotation for injecting object instances into JSF managed beans.  The feature now has been enabled in GlassFish 3.1 - starting with the latest July 22 nightly builds, or a current source build.  So now, you should be able to use it in a JSF managed bean as follows:

import javax.inject.Inject;

....

@ManagedBean
@SessionScoped
 

public class UserNumberBean implements Serializable {

    @Inject
    private Count count;

...

    public String getCount() {
        if (null != count) {
            return count.getCount();
        } else {
            return "";
        }
    }
...

}

 

 

 

Cheers...

 

Related Topics >>