

Use this scope if no one of the other scopes suits the requirement, for example a conservation scope which spans across multiple views.Ĭhoose the right scope for the data the bean holds! Abusing an application scoped bean for session/view/request scoped data would make it to be shared among all users, so anyone else can see each other's data which is just plain wrong. You need to control the removal of the bean from the Map yourself. You need to create and prepare this Map yourself in a broader scope, for example the session scope.

a bean in this scope lives as long as the bean's entry in the custom Map which is created for this scope lives.The injected bean will then live as long as the acceptor bean. Use this scope for a data bean which is purely supposed to be injected in another bean of a definied scope. This way the managed bean is available in EL by # expressions in your view, then the bean get effectively created three times.

You probably already know that you can annotate backing beans as managed bean with and specify the managed bean name by the name attribute of the annotation without the need to specify them as boilerplate in faces-config.xml like as in legacy JSF 1.x. Most notable is Mojarra version 2.1.0 this version does not work on Tomcat/Jetty due to a major bug in the annotation scanner. As to compatibility, it's important to know that JSF 2.1 is targeted on Servlet 3.0 containers (Glassfish 3, Tomcat 7, JBoss AS 6, etc), while JSF 2.0 is targeted on older Servlet 2.5 containers (Glassfish 2, Tomcat 6, JBoss AS 5, etc). The difference between JSF 2.0 and JSF 2.1 is subtle. Any error/exception message examples are Mojarra 2.1.3 specific and may (slightly) differ on different versions and implementations. They should work equally good on older or newer versions or different implementations of JSF 2.x (MyFaces, for example) and/or servlet containers (Tomcat, JBoss, etc), unless explicitly otherwise mentioned.

#Primeface vs icefaces vs richfaces code
The code examples throughout the article are wherever applicable created and tested on Mojarra 2.1.3 and Glassfish 3.1.1 which are at the time of writing just the newest available. For more detail, see also the empty string madness article. Glassfish for example does not have this problem. Long, Integer, Double, Boolean, etc), because this EL parser would immediately coerce an empty string to the wrapped primitive's default value such as 0, 0.0 or false before returning the value to JSF. This will prevent that the aforementioned context parameter will fail for primitive wrapper managed bean properties (e.g. JBoss AS, WebSphere AS, etc) or at least a servletcontainer which utilizes Apache EL parser, then we also assume that you've the following startup VM argument set: .parser.COERCE_TO_ZERO=false If you're running Tomcat or a clone/fork of it (e.g. The above will prevent that model values get littered with empty strings when the enduser leaves input fields empty. We assume that you've configured JSF to interpret empty string submitted values as null by the following context parameter in web.xml: _EMPTY_STRING_SUBMITTED_VALUES_AS_NULL true We assume that you're able to create JSF forms and beans like as demonstrated in the JSF 2.0 tutorial of this blog (model, view and controller). We assume that you're familiar with JSF basics.
