View Javadoc
1   package org.andromda.cartridges.jsf.taglib;
2   
3   import javax.el.ExpressionFactory;
4   import javax.faces.context.FacesContext;
5   import javax.servlet.jsp.PageContext;
6   import org.andromda.cartridges.jsf.converters.JSFDateTimeConverter;
7   
8   /**
9    * Extends the default myfaces convert date time tag in order to use
10   * the custom date time converter {@link org.andromda.cartridges.jsf.converters.JSFDateTimeConverter}.
11   *
12   * @author Chad Brandon
13   */
14  public class ConvertDateTimeTag
15      extends org.apache.myfaces.taglib.core.ConvertDateTimeTag
16  {
17      /**
18       *
19       */
20      private static final long serialVersionUID = 1L;
21  
22      /**
23       * Overridden to set the converter id using out custom date time
24       * converter: {@link org.andromda.cartridges.jsf.converters.JSFDateTimeConverter}.
25       *
26       * @see javax.servlet.jsp.tagext.Tag#setPageContext(javax.servlet.jsp.PageContext)
27       */
28      @Override
29      public void setPageContext(PageContext context)
30      {
31          super.setPageContext(context);
32          ExpressionFactory expressionFactory =
33              FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
34          setConverterId(expressionFactory.createValueExpression(context.getELContext(),
35              JSFDateTimeConverter.CONVERTER_ID, String.class));
36      }
37  }