com.mycompany.jsf.renderer
Class DatePickerRenderer

java.lang.Object
  extended byjavax.faces.render.Renderer
      extended bycom.mycompany.jsf.renderer.DatePickerRenderer

public class DatePickerRenderer
extends javax.faces.render.Renderer

This class is a JSF Renderer for the "javax.faces.Input" component type. It renders a date value as three selection lists for the year, month and day.

Version:
1.0
Author:
Hans Bergsten, Gefion Software

Constructor Summary
DatePickerRenderer()
           
 
Method Summary
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Creates a Map to hold the year, month and day values from the request parameters and saves it as the submitted value for the component.
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Renders selection lists for the year, month and day value.
 java.lang.Object getConvertedValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object submittedValue)
          Returns a Date instance created from the year, month and day values held by the Map submitted value.
private  java.util.List getDays()
          Returns a List with SelectItem instances representing 31 days.
private  java.util.List getMonths()
          Returns a List with SelectItem instances representing all months.
private  java.util.List getYears(int startYear, int noOfyears)
          Returns a List with SelectItem instances representing the specified number of years, starting with the specified start year.
private  boolean isDisabledOrReadOnly(javax.faces.component.UIComponent component)
          Returns true if one or both of the HTML attributes "disabled" or "readonly" are set to true.
private  void renderMenu(javax.faces.context.ResponseWriter out, java.util.List items, int selected, java.lang.String clientId, java.lang.String styleClass, javax.faces.component.UIComponent component)
          Writes a "select" element with "option" elements based on the List with SelectItem instances, with a "selected" attribute for the SelectItem matching the selected value.
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, encodeChildren, encodeEnd, getRendersChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatePickerRenderer

public DatePickerRenderer()
Method Detail

decode

public void decode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent component)
Creates a Map to hold the year, month and day values from the request parameters and saves it as the submitted value for the component.


getConvertedValue

public java.lang.Object getConvertedValue(javax.faces.context.FacesContext context,
                                          javax.faces.component.UIComponent component,
                                          java.lang.Object submittedValue)
Returns a Date instance created from the year, month and day values held by the Map submitted value.


encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)
                 throws java.io.IOException
Renders selection lists for the year, month and day value.

Throws:
java.io.IOException

getYears

private java.util.List getYears(int startYear,
                                int noOfyears)
Returns a List with SelectItem instances representing the specified number of years, starting with the specified start year.


getMonths

private java.util.List getMonths()
Returns a List with SelectItem instances representing all months.


getDays

private java.util.List getDays()
Returns a List with SelectItem instances representing 31 days.


renderMenu

private void renderMenu(javax.faces.context.ResponseWriter out,
                        java.util.List items,
                        int selected,
                        java.lang.String clientId,
                        java.lang.String styleClass,
                        javax.faces.component.UIComponent component)
                 throws java.io.IOException
Writes a "select" element with "option" elements based on the List with SelectItem instances, with a "selected" attribute for the SelectItem matching the selected value. If a CSS class is specified, it's used as the "class" attribute of the "select" element.

Throws:
java.io.IOException

isDisabledOrReadOnly

private boolean isDisabledOrReadOnly(javax.faces.component.UIComponent component)
Returns true if one or both of the HTML attributes "disabled" or "readonly" are set to true.