javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL does not work anymore since Java EE 7 / EL 3.0

Fixed with a custom resolver: faces-config.xml: <application> <el-resolver>my.package.EmptyNullStringResolver</el-resolver> </application> EmptyNullStringResolver.java: /** * @author pg */ public class EmptyNullStringResolver extends ELResolver { @Override public Class<?> getCommonPropertyType(ELContext context, Object base) { return String.class; } @Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } @Override public Class<?> getType(ELContext context, Object base, Object property) { return null; … Read more

Spring Boot JSF Integration

This is the way I have JSF working with Spring Boot (full sample project at Github, updated with JSF 2.3 and Spring Boot 2): 1. Dependencies In addition to the standard web starter dependency, you’ll need to include the tomcat embedded jasper marked as provided (thanks @Fencer for commenting in here). Otherwise you’ll get an … Read more

Execute JavaScript before and after the f:ajax listener is invoked

Use onevent attribute. It must point to a callback function reference (so don’t include parentheses!): <f:ajax … onevent=”functionName” /> Whereby the actual callback function look like this (JSF will provide the argument all by itself): function functionName(data) { var status = data.status; // Can be “begin”, “complete” or “success”. var source = data.source; // The … Read more

Using a “Please select” f:selectItem with null/empty value inside a p:selectOneMenu

When the select item value is null, then JSF won’t render <option value>, but only <option>. As consequence, browsers will submit the option’s label instead. This is clearly specified in HTML specification (emphasis mine): value = cdata [CS] This attribute specifies the initial value of the control. If this attribute is not set, the initial … Read more

Getting ViewExpiredException in clustered environment while state saving method is set to client and user session is valid

This will happen if the client side state is encrypted by one server and decrypted by other server and the servers don’t use the same AES key for this. Normally, you should also have seen below warning in server log: ERROR: MAC did not verify You need to ensure that you have set jsf/ClientSideSecretKey in … Read more

When using @EJB, does each managed bean get its own @EJB instance?

Does this mean that each new UserLoginView gets a new instance of UserService? Nope. The given UserService is a @Stateless EJB. @Stateless EJBs are pooled and injected as serializable proxies autogenerated by the container. Among others the stack trace when an exception occurs from an EJB is evidence for this. You see extra layers between … Read more

@ViewScoped bean recreated on every postback request when using JSF 2.2

This, import javax.faces.view.ViewScoped; is the JSF 2.2-introduced CDI-specific annotation, intented to be used in combination with CDI-specific bean management annotation @Named. However, you’re using the JSF-specific bean management annotation @ManagedBean. import javax.faces.bean.ManagedBean; You should then be using any of the scopes provided by the very same javax.faces.bean package instead. The right @ViewScoped is over there: … Read more

File upload doesn’t work with AJAX in PrimeFaces 4.0/JSF 2.2.x – javax.servlet.ServletException: The request content-type is not a multipart/form-data

As Kai rightfully pointed out in his answer on the current question, the problem is caused by the NativeFileUploadDecoder as used by FileUploadRenderer not checking whether the request is a multipart/form-data request or not. This will cause trouble when the component is present in a form on which a “regular” ajax request is being submitted. … Read more