I have a @ViewScoped
bean:
@Named
@ViewScoped
public class testBean implements Serializable {
private static final long serialVersionUID = 1L;
private String color;
@PostConstruct
public void postConstruct() {
color = "red";
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
In my JSF page I can access the property color by #{testBean.color}
, but in my CSS resource it doesn't work.
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
border: 0;
background-color: #{testBean.color};
}
It throws the below exception:
org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.faces.view.ViewScoped
at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
at com.unifik.core.subdomain.admin.WidgetLoginBean$Proxy$_$$_WeldClientProxy.getWidgetLogin(Unknown Source) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_67]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_67]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:363) [jboss-el-api_3.0_spec-1.0.3.Final.jar:1.0.3.Final]
... 46 more
If I change @ViewScoped
to @SessionScoped
, then it works, but I do not want that.