Letting the presentation layer (JSF) handle business exceptions from service layer (EJB)

Create a custom service layer specific runtime exception which is annotated with @ApplicationException with rollback=true. @ApplicationException(rollback=true) public abstract class ServiceException extends RuntimeException {} Create some concrete subclasses for general business exceptions, such as constraint violation, required entity, and of course optimistic lock. public class DuplicateEntityException extends ServiceException {} public class EntityNotFoundException extends ServiceException {} public … Read more

What exactly is #{component} in EL?

The #{component} is an implicit EL variable referring the current UIComponent in EL scope (see also implicit EL objects). You can usually only refer it in component’s HTML attribute or in template text children. E.g. in case of <h:inputText> it will reference an instance of UIInput class which has among others an isValid() method. <h:inputText … Read more

Dynamically generate h:column based on list of hashmaps

Is it possible to bind a List of HashMaps to the jsf component h:dataTable? That’s only possible if you generate the necessary <h:column> tags with a view build time tag such as JSTL <c:forEach>. Here’s a concrete kickoff example, assuming that your environment supports EL 2.2: <h:dataTable value=”#{bean.listOfMaps}” var=”map”> <c:forEach items=”#{bean.listOfMaps[0].keySet().toArray()}” var=”key”> <h:column> #{map[key]} </h:column> … Read more

c:forEach inside primefaces(e.g. p:panelgrid) inside ui:repeat

The transition from the XHTML source code to the generated HTML output is a two-step process. First, during view build time, the XHTML source code is parsed and turned in a tree of Java UIComponent instances representing the JSF UI component tree, as available by FacesContext#getViewRoot(). Then, during view render time, the JSF UI component … Read more

Set decimal separator when using f:convertNumber

The default decimal separator depends on the locale used. You can set it in 2 ways: On a per-view basis by the locale attribute of the <f:view> tag: <f:view locale=”#{bean.locale}”> On a per-converter basis by the locale attribute of the <f:convertNumber> tag: <f:convertNumber locale=”#{bean.locale}” /> It’s unclear what locale you’re targeting, but the use of … Read more