Skip to content

Category Archives: JSF

Generic Entity Converter for JSF / Spring / JPA

If you’ve come across Seam’s <s:convertEntity> and wondered why isn’t one there for JSF, here you go: Before using this, you should’ve designed your domain model to extend a Base Class (do it, it’s a good practice). In my case, I have BaseIdentityEntity which has an @Id, @Version properties import java.io.Serializable; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; [...]

Custom taglibs with facelets

Creating tag libraries using facelets might be cool but needs more redundant infrastructure than the new JSP tag libs (which doesn’t need tld declaration or web.xml context params). However once your done, building reusable tags on the fly (with no java code) can be pretty slick. Here are the steps for creating a simple tag [...]

A simple java.util.Date to java.sql.Date converter

If you’re using JSF and need a converter for converting UI elements (typically java.util.Date) to your domain object’s date field (typically java.sql.Date), here’s the code snippet, public class DateConverter implements Converter, Serializable { public Object getAsObject(FacesContext context, UIComponent component, String value) { java.sql.Date sqlDate = null; Calendar cal = null; if (value != null && [...]