CDI Injection into a FacesConverter

Replace @FacesConverter(value = “categoryConverter”) by @Named and use <h:inputSomething converter=”#{categoryConverter}” /> or <f:converter binding=”#{categoryConverter}” /> instead of <h:inputSomething converter=”categoryConverter” /> or <f:converter converterId=”categoryConverter” /> By the way, similar problem exist for @EJB inside a @FacesConverter. It however offers a way to be grabbed by JNDI manually. See also Communication in JSF 2.0 – Getting an … Read more

JSF facelets template packaging

Facelets compositions (so, just plain *.xhtml pages, templates and include files) are resolved by ExternalContext#getResource() which delegates to ServletContext#getResource(). This requires a Servlet 3.x compatible container because /WEB-INF/lib/*.jar!/META-INF/resources resolving from is new since Servlet 3.0. If you aren’t on Servlet 3.x yet, or want to put those JARs on a different location for some reason, … Read more

How to find indication of a Validation error (required=”true”) while doing ajax command

Not specifically for required=”true”, but you can check by #{facesContext.validationFailed} if validation has failed in general. If you combine this with checking if the button in question is pressed by #{not empty param[buttonClientId]}, then you can put it together in the rendered attribute of the <h:outputScript> as follows: <h:commandButton id=”add_something_id” binding=”#{add}” value=”Add” action=”#{myBean.addSomething(false)}”> <f:ajax execute=”@form” … Read more

Invoke method with varargs in EL throws java.lang.IllegalArgumentException: wrong number of arguments

No, it is not possible to use variable arguments in EL method expressions, let alone EL functions. Your best bet is to create multiple different named methods with a different amount of fixed arguments. public static boolean isValueIn2(Integer value, Integer option1, Integer option2) {} public static boolean isValueIn3(Integer value, Integer option1, Integer option2, Integer option3) … Read more

Is JSF 2.0 View Scope back-button safe?

To start, the view scope is bound to a particular page/view. Multiple views won’t share the same view scoped bean. The view scope starts with an initial GET request and stops when a POST action navigates with a non-null return value. There are in general the following scenarios, depending on whether the browser is instructed … Read more


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 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