I have a context-param in web.xml:
<context-param>
<description>Version number will be prefixed to url of requests</description>
<param-name>version_id</param-name>
<param-value>11</param-value>
</context-param>
I want to inject this into a ManagedBean This bean has a scope None
I tried the code below but it's not working, I'm getting an exception on startup with this error:
The scope of the object referenced by expression #{initParam[version_id]}, application, is shorter than the referring managed beans (responseData) scope of none
@ManagedBean
@NoneScoped
public class ResponseData implements Serializable {
@ManagedProperty(value = "#{initParam.version_id}")
private String version;
public ResponseData() {
}
/**
* @param version the version to set
*/
public void setVersion(String version) {
this.version = version;
}
}
What is the right way to inject value of context-param into a managed bean as a managed property?