webtier@glassfish.java.net

ManagedProperty annotation not working

From: Uwe Seimet <Uwe.Seimet_at_seimet.de>
Date: Tue, 7 Jul 2009 18:37:21 +0200

Hello,

The @ManagedProperty annotation does not work as I expect it for both
of my setups (Tomcat 6.0.22 with the latest Mojarra 2.0.0 snapshot and a
recent Glassfish preview).

My code looks like this:

@ManagedBean
final public class MyBean
{
    @ManagedProperty(name = "folder", value = "#{param.folder}")
    private String folder_;
}

Even though a request parameter named "folder" is present its value is
not injected. As a work-around I have added this code fragment:

    @PostConstruct
    public void init()
    {
        final Map<String, String> m = FacesContext.getCurrentInstance()
                .getExternalContext().getRequestParameterMap();
        folder_ = m.get("folder");
    }

This fragment initializes the folder_ field correctly, which also shows
that the request parameter is actually present. But I think
@MangedProperty should do the same.
There is no declaration referring to MyBean in faces-config.xml, by the
way.

I don't think it makes a difference but maybe it's important to note
that the javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER context parameter is
set to true for both of my setups.

Any hint at what I am most likely missing? Thank you for your help.

Best regards Uwe