f:viewParam doesn’t pass required parameter when new xmlns.jcp.org namespace is used

The way how the new xmlns.jcp.org XML namespaces are been handled is broken in the first Mojarra releases 2.2.0 and 2.2.1. It has been fixed in Mojarra 2.2.2 (note: ticket in the link describes different problem symptom, but under the covers, it’s essentially the same cause). It’s recommended to upgrade to Mojarra 2.2.2. GlassFish 4.0 … Read more

JSF: Mojarra vs. OmniFaces @ViewScoped: @PreDestroy called but bean can’t be garbage collected

The cause of this problem seems to be due to strange behaviour JVisualVM when attached to Glassfish/Payara. The test case used for this question is still extremely useful, however the conclusions concerning Garbage Collection in the original post (and images) were based on JVisualVM, and I have since found they are not valid. Use the … 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

JSF and automatic reload of xhtml files

JRebel handles /WebContent folder changes. The problem is that Facelets do caching and do not reread changed files. To force reread specify the following parameters in web.xml. JSF 2 (Facelets 2.x): <!– Time in seconds that facelets should be checked for changes since last request. A value of -1 disables refresh checking. –> <context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> … Read more

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

How to update Mojarra version in GlassFish

GlassFish itself already ships with JSF bundled which get by default classloading precedence over the one bundled in the webapp. You basically need to tell GlassFish to use the webapp bundled JSF instead. Edit the webapp’s /WEB-INF/glassfish-web.xml (or /WEB-INF/sun-web.xml if you’re using one of the first GF3 versions) to add the following two entries: <class-loader … 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