Work around for faulty INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL in Mojarra JSF 2.1

This is not Mojarra specific. This is Tomcat specific (JBoss uses Tomcat as servletcontainer). Add the following VM argument to startup options. -Dorg.apache.el.parser.COERCE_TO_ZERO=false To my experience, this one should actually only apply on Number properties (int, long, etc), however since a certain late Tomcat 6.0.x version (at least after 6.0.20) it seems to be broken … Read more

Configuration of com.sun.faces.config.ConfigureListener

The ConfigureListener is normally automatically registered via /META-INF/jsf_core.tld file of Mojarra implementation JAR file. Additionally, the ConfigureListener is explicitly registered via a Servlet 3.0 ServletContainerInitializer in order to workaround an old GlassFish v3 bug (note: v3, not 3.0.x, thus really that one first GF3 version ever). There exist situations wherein the auto-registration via .tld file … Read more

How to get rid of WARNING: PWC4011: Unable to set request character encoding to UTF-8

JSF/Facelets uses by default UTF-8 to decode HTTP request parameters. GlassFish itself uses by default ISO-8859-1 do decode HTTP request parameters. HTTP request parameters can be parsed and decoded only once and this happens whenever a request parameter is requested by the code for the first time like so request.getParameter(“name”). So, if a request parameter … Read more

Adding custom attribute (HTML5) support to JSF 2.0 UIInput component

This is my way. I added placeholder and data-theme attributes. If you want to add more attributes, you should just add its name to attributes array. import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import com.sun.faces.renderkit.html_basic.TextRenderer; public class InputRender extends TextRenderer { @Override protected void getEndTextToRender(FacesContext context, UIComponent component, String currentValue) throws java.io.IOException{ String [] attributes = … Read more

Should PARTIAL_STATE_SAVING be set to false?

Should PARTIAL_STATE_SAVING be set to false? Only when you encounter a general defect related to partial state saving in your webapp which can really not be solved/workarounded the other way. Partial state saving has namely major advantages as to overall performance and memory usage. See also Why JSF saves the state of UI components on … Read more

Difference between Mojarra and MyFaces

Why do I need more jars if I use MyFaces? Because those commons-* dependencies are not bundled in MyFaces. On the other hand, if you’re using other libraries from Apache.org which also use those commons-* dependencies, then you ultimately end up with smaller total size libraries. Noted should be that since Mojarra 2.1.6 a single … Read more

What is the usefulness of statelessness in JSF?

First of all, I would like to clarify that JSF isn’t exactly “going stateless” at its whole own. JSF just adds a new feature enabling the developers to create stateless views/forms on demand. State saving is particularly helpful in dynamically manipulated forms with e.g. conditionally ajax-rendered parts. It remembers the state of the form across … Read more

com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews

First of all, the Mojarra implementation unintentionally swapped the meaning of those context parameters. So if you have the impression that the description is exactly the other way round than what the literal context parameter name implies, then this is indeed true. com.sun.faces.numberOfLogicalViews This is basically GET request based. Every GET request creates a new … Read more

Upgrade JSF / Mojarra in JBoss AS / EAP / WildFly

The below procedure applies to JBoss AS 7.2+, JBoss EAP 6.1+, and JBoss WildFly 8+ and assumes that you’ve full control over the server installation and configuration. This upgrades the server-wide default JSF version: Download the individual Mojarra API and impl files (and thus not the single javax.faces.jar file). Current latest 2.1.x version is 2.1.29 … Read more

tech