jp.terasoluna.fw.web.taglib
Class InputCalendarTag

java.lang.Object
  Extend the above javax.servlet.jsp.tagext.TagSupport
      Extend the above jp.terasoluna.fw.web.taglib.InputCalendarTag
All implemented interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class InputCalendarTag
extends javax.servlet.jsp.tagext.TagSupport

Calendar input function for entering the selected date for the specified field.

Seetings of calendar input function can be changed by describing the following items into message resource file.
Message resource file name is considered to be fixed as "calendar".
Ex: "calendar.properties". "calendar_en.properties"

Functional details Calendar hoilidays can be specified by giving the following description in message resource file. In message resource key "calendar.holiday." part is fixed and thereafter, the serial number is assigned from "1". In parameter, "Month", "Date" and "Holiday Summary" should be separated by comma. Specify "0" in the "Year" parameter in case of the hoilday which is defined on the same date of every year. Specifying "0" in "Year" parameter is recognized as every year.
Configuration example calendar.holiday.1=0,1,1,New year's Day
calendar.holiday.2=0,2,11,National Foundation Day
calendar.holiday.3=0,4,29,Day of Showa
calendar.holiday.4=0,5,3,Constitution Memorial Day
calendar.holiday.5=0,5,4,Greenery Day
calendar.holiday.6=0,5,5,Children's Day
calendar.holiday.7=0,11,3,Culture Day
calendar.holiday.8=0,11,23,Labor Thanksgiving Day
calendar.holiday.9=0,12,23,The Emperor's Birthday
calendar.holiday.10=2009,1,12,Coming-of-Age Day
calendar.holiday.11=2009,3,20,Vernal Equinox Day
calendar.holiday.12=2009,7,20,Marine Day
calendar.holiday.13=2009,9,21,Senior Citizen's Day
calendar.holiday.14=2009,9,23,Autumnal Equinox Day
calendar.holiday.15=2009,10,12,National Sports Day
:

Functional Details String of button which displays the calendar can be changed by providing the following description in the message resource file. Message resource key is fixed as "calendar.button.string". Default is "Calendar".
Configuration example calendar.button.string=Calendar

Functional Details Prefix of the style sheet used in the calendar and the prefix of image file can be changed by providing the following description in the message resource file.
Message resource key is considered to be fixed as "calendar.style.themeprefix". Default is "BlueStyle".
Configuration example calendar.style.themeprefix=BlueStyle

Functional details String assigned to the current date which is displayed at the bottom of the calendar, can be changed by providing the following description in the message resource file.
Message resource key is considered to be fixed as "calendar.today.string". Default is "Today is".
Configuration example calendar.today.string=Today is

Functional details The storage location of the image which is used in the calendar input function, can be changed by providing the following description in the message resource file. It should end with "/". Storgae location of image can be changed.However, the name of the image file cannot be changed.
Message resource key is considered to be fixed as "calendar.img.dir". Default is "img/calendar/".
Configuration example calendar.img.dir=image/

Functional details The storage location of style sheet which is used in calendar input function, can be changed by providing the following description in the message resource file.It should end with "/". File name of style sheet used in this function is " + InputCalendar.css".
Message resource key is considered to be fixed as "calendar.stylesheet.dir". Default is "css/".
Configuration example calendar.stylesheet.dir=style/

Functional details The storage location of external JavaScript which is used in calendar input function, can be changed by providing the following description in the message resource file. It should end with "/". The file name of JavaScript used in this function is "InputCalendar.js".
Message resource key is considered to be fixed as "calendar.javascript.dir". Default is "js/".
Configuration example calendar.javascript.dir=javascript/

Usage example of calendar input function

Provide the following description for the input field. Specify the name of the target input field in the "for" attribute of calendar input function. In the following example, "property" attribute of "text" element becomes the name of input field. Therefore, the value same as "property" attribute of "text" element is specified in "for" attribute.

<html:text property="value" />
<t:inputCalendar for="value" format="yyyy-MM-dd" />

Attribute supported by tags

Calendar input function supports the following attribute.

Attribute name Default value Required Execution time format Overview
for - true true Specify the input field wherein selected date is entered.
format yyyy/MM/dd false true Specify the calendar format.
Date format could be specified as "y(year), "M(Month" and "d(date)" and seperator could be any among the "/", "-", "." and "half-width space". Only a single character should be used as a separator. Multiple separators cannot be used like "yyyy/MM-dd".
formatKey - false true Specify the key value to fetch the calendar format from the message resource.

See Also:
Serialized form

Field Summary
protected static java.lang.String CALENDAR_BUTTON_VALUE
          Key to fetch the button display string which is used in the calendar input function, from the message resource.
protected static java.lang.String CALENDAR_DEFAULT_BUTTON_VALUE
          Default calendar button display string.
protected static java.lang.String CALENDAR_DEFAULT_FORMAT
          default format.
protected static java.lang.String CALENDAR_DEFAULT_IMAGE_PATH
          Default image storage location path.
protected static java.lang.String CALENDAR_DEFAULT_JAVASCRIPT_DIR
          Default calendar external JavaScript storage location.
protected static java.lang.String CALENDAR_DEFAULT_STYLEPREFIX_NAME
          Default style prefix name.
protected static java.lang.String CALENDAR_DEFAULT_STYLESHEET_DIR
          Default style sheet storage location.
protected static java.lang.String CALENDAR_HOLIDAY_PREFIX
          Key to fetch the holiday definition information which is used in calendar input function, from the mesage resource.
protected static java.lang.String CALENDAR_IMG_DIR
          Key to fetch the calendar image storage location which is used in calendar input function, from the message resource.
protected static java.lang.String CALENDAR_JAVASCRIPT_DIR
          Key to fetch the calendar external JavaScript storage location which is used in calendar input function, from message resource.
protected static java.lang.String CALENDAR_JAVASCRIPT_FILE_NAME
          File name of JavaScript which is used in calendar input function.
protected static java.lang.String CALENDAR_STYLE_THEMEPREFIX
          Key to fetch the style prefix which is used in calendar input function, from the message resource.
protected static java.lang.String CALENDAR_STYLESHEET_DIR
          ;Key to fetch the style sheet storage location which is used in calendar input function, from the message resource.
protected static java.lang.String CALENDAR_STYLESHEET_FILE_NAME
          File name (without prefix) of the style sheet which is used in calendar input function.
protected static java.lang.String CALENDAR_TODAY_STRING
          Key to fetch the string assigned to current date which is used in calendar input function, from the message resource.
private  java.lang.String forId
          Attribute specifying target text field.
private  java.lang.String format
           Attribute specifying the format.
protected static java.lang.String FORMAT_VALUE
          Corresponding format string group.
private  java.lang.String formatKey
          Attribute specifying format key.
protected static java.lang.String INPUTCALENDAR_FLG
          Output status flag key.
private static long serialVersionUID
          Serial version ID
 
Field inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Field inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Field inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
InputCalendarTag()
           
 
Method Summary
protected  java.lang.String createFormat(java.lang.String format)
          Thouroughly check the date format for the argument string.
protected  java.lang.String defineArrayVariable(java.lang.String arrayName, java.lang.String[] array)
          Converts the array, passed as an argument, to type Array of JavaScript and returns.
protected  void defineButton(java.util.ResourceBundle calendarBundle)
          Output the button to display the calendar screen.
protected  void defineJavaScript(java.util.ResourceBundle calendarBundle)
          Output the defined part of JavaScript.
protected  java.lang.String defineObjectVariable(java.lang.String name, java.lang.String value)
          Returns the value, which is passed as an argument, as the Object declaration of JavaScript.
protected  java.lang.String defineStringVariable(java.lang.String name, java.lang.String value)
          Returns the value, which is passed as an argument, as the String declaration of JavaScript.
 int doStartTag()
          Method which is called while starting the tag evaluation.
 java.lang.String getFor()
          Return the value of attribute specifying target textfield.
 java.lang.String getFormat()
          Return the value of attribute specifying the format.
 java.lang.String getFormatKey()
          Return the value of attribute specifying format key.
protected  java.util.List<java.util.Map<java.lang.String,java.lang.String>> getHolidayList(java.util.ResourceBundle calendarBundle)
          Fetch the holiday definition which is defined in message resource.
protected  boolean getPageContextFlg(javax.servlet.jsp.PageContext pageContext, java.lang.String key)
          Convert the value which is fetched by the specified KEY into true-value and return.
protected  java.lang.String getParameter(java.util.ResourceBundle calendarBundle, java.lang.String key, java.lang.String def)
          Fetch the value based on the key from the message resource and return.
protected  java.lang.String[] mapMonths(java.text.DateFormatSymbols symbols)
          Fetch the "Month" from the specififed date format symbol and return.
protected  java.lang.String[] mapWeekdays(java.text.DateFormatSymbols symbols)
          Fetch the "Day" from the specified date format symbol and return.
 void release()
          Release all allocated resources.
 void setFor(java.lang.String forId)
          Set the value of attribute specifying target text field.
 void setFormat(java.lang.String format)
          Set the value of attribute specifying the format.
 void setFormatKey(java.lang.String formatKey)
          Set the value of attribute specifying format key.
protected  void setPageContextFlg(javax.servlet.jsp.PageContext pageContext, java.lang.String key)
          Set the flag of the specified KEY for page context.
 
Method which is inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
ethod which is inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Details

serialVersionUID

private static final long serialVersionUID
Serial version ID

See Also:
Constant field value

forId

private java.lang.String forId
Attribute specifying target text field. Specify the field name wherein the selected date is entered.


format

private java.lang.String format
Attribute specifying the format. Specify the format of date to be entered in the field. Use the three characters namely "y", "M" and "d". "/", "-", "." and " " could be used as separators.


formatKey

private java.lang.String formatKey
Attribute specifying format key. Specify the key for the message resource of the date format to be entered in the field.


CALENDAR_IMG_DIR

protected static final java.lang.String CALENDAR_IMG_DIR
Key to fetch the calendar image storage location which is used in calendar input function, from the message resource.

See Also:
Constant field value

CALENDAR_TODAY_STRING

protected static final java.lang.String CALENDAR_TODAY_STRING
Key to fetch the string assigned to the current date which is used in calendar input function, from the message resource.

See Also:
Constant field value

CALENDAR_BUTTON_VALUE

protected static final java.lang.String CALENDAR_BUTTON_VALUE
Key to fetch the button display string which is used in calendar input function, from the message resource.

See Also:
Constant field value

CALENDAR_STYLE_THEMEPREFIX

protected static final java.lang.String CALENDAR_STYLE_THEMEPREFIX
Key to fetch the style prefix which is used in calendar input functions, from the message resource.

See Also:
Constant field value

CALENDAR_STYLESHEET_DIR

protected static final java.lang.String CALENDAR_STYLESHEET_DIR
Key to fetch the style sheet storage location which is used in calendar input function, from the message resource.

See Also:
Constant field value

CALENDAR_JAVASCRIPT_DIR

protected static final java.lang.String CALENDAR_JAVASCRIPT_DIR
Key to fetch the calendar external JavaScript storage location which is used in calendar input function, from message resource.

See Also:
Constant field value

CALENDAR_HOLIDAY_PREFIX

protected static final java.lang.String CALENDAR_HOLIDAY_PREFIX
Key to fetch the holiday definition information which is used in calendar input function, from the message resource.

See Also:
Constant field value

CALENDAR_DEFAULT_FORMAT

protected static final java.lang.String CALENDAR_DEFAULT_FORMAT
Default format.

See Also:
Constant field value

CALENDAR_DEFAULT_STYLEPREFIX_NAME

protected static final java.lang.String CALENDAR_DEFAULT_STYLEPREFIX_NAME
Default style prefix name.

See Also:
Constant field value

CALENDAR_DEFAULT_IMAGE_PATH

protected static final java.lang.String CALENDAR_DEFAULT_IMAGE_PATH
Default image storage location path.

See Also:
Constant field value

CALENDAR_DEFAULT_BUTTON_VALUE

protected static final java.lang.String CALENDAR_DEFAULT_BUTTON_VALUE
Default calendar button display string.

See Also:
Constant field value

CALENDAR_DEFAULT_STYLESHEET_DIR

protected static final java.lang.String CALENDAR_DEFAULT_STYLESHEET_DIR
Default style sheet storage location.

See Also:
Constant field value

CALENDAR_DEFAULT_JAVASCRIPT_DIR

protected static final java.lang.String CALENDAR_DEFAULT_JAVASCRIPT_DIR
Default calendar external JavaScript storage location.

See Also:
Constant field value

CALENDAR_JAVASCRIPT_FILE_NAME

protected static final java.lang.String CALENDAR_JAVASCRIPT_FILE_NAME
File name of JavaScript which is used in calendar input function.

See Also:
Constant field value

CALENDAR_STYLESHEET_FILE_NAME

protected static final java.lang.String CALENDAR_STYLESHEET_FILE_NAME
File name (without prefix) of style sheet which is used in calendar input function.

See Also:
Constant field value

INPUTCALENDAR_FLG

protected static final java.lang.String INPUTCALENDAR_FLG
Output status flag key.

See Also:
Constant field value

FORMAT_VALUE

protected static final java.lang.String FORMAT_VALUE
Corresponding formatcharacter group.

See Also:
Constant field value
Constructor Details

InputCalendarTag

public InputCalendarTag()
Method Details

getFor

public java.lang.String getFor()
Return the value of attribute specifying target text field.

Returns:
Value of attribute specifying target text field

setFor

public void setFor(java.lang.String forId)
Set the value of attribute specifying target text field.

Parameter:
forId - Value to be set

getFormat

public java.lang.String getFormat()
Return the value of attribute specifying the format.

Returns:
Value of attribute specifying the format

setFormat

public void setFormat(java.lang.String format)
Set the value of attribute specifying the format.

Parameter:
format - Value to be set

getFormatKey

public java.lang.String getFormatKey()
Retrun the value of attribute specifying format key.

Returns:
Value of attribute specifying format key.

setFormatKey

public void setFormatKey(java.lang.String formatKey)
Set the value of attribute specifying format key.

Parameter:
formatKey - Value to be set

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Method which is called while starting the tag evaluation. Fetch the resource bundle for internationalization support exclusively for this functionality. Output the JavaScript and button to use this function.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Process control instructions
Exception:
javax.servlet.jsp.JspException - JSP exception

defineJavaScript

protected void defineJavaScript(java.util.ResourceBundle calendarBundle)
                         throws javax.servlet.jsp.JspException
Output the defiend part of JavaScript. Output Japanese locale flag, string where current date is appended, style prefix, calendar image location specification, calendar style sheet location specification and calendar JavaScript location specification. Further, output <link> element of style sheet and <script> element of calendar input function.

Parameter:
calendarBundle - Resource bundle for calendar input function
Exception:
javax.servlet.jsp.JspException - JSP exception

getHolidayList

protected java.util.List<java.util.Map<java.lang.String,java.lang.String>> getHolidayList(java.util.ResourceBundle calendarBundle)
Fetch the holiday definition which is defined in message resource.

Parameter:
calendarBundle - Resource bundle for the calendar input function
Returns:
Holiday definition list which is fetched

defineButton

protected void defineButton(java.util.ResourceBundle calendarBundle)
                     throws javax.servlet.jsp.JspException
Output the button to display calendar screen.

Parameter:
calendarBundle - Resource bundle for calendar input function
Exception:
javax.servlet.jsp.JspException - JSP excepton

getParameter

protected java.lang.String getParameter(java.util.ResourceBundle calendarBundle,
                                        java.lang.String key,
                                        java.lang.String def)
Fetch the value based on the key from the message resource and return. When the key is null or blank, return default value when fetched value is null.

Parameter:
calendarBundle - Resource bundle for calendar input function
key - Key of message resource
def - Default value
Returns:
Value fetched from message resource or default value

defineStringVariable

protected java.lang.String defineStringVariable(java.lang.String name,
                                                java.lang.String value)
Return the value, which is passed as an argument, as the String declaration of JavaScript.
Example:Varibale name "kanji", Value "Kanji"-> "var kanji = "Kanji";\n".

Parameter:
name - Variable name declared by JavaScript
value - Value of variable
Returns:
Edited string

defineObjectVariable

protected java.lang.String defineObjectVariable(java.lang.String name,
                                                java.lang.String value)
Return the value, which is passed as an argument, as the Object declaration of JavaScript.
Example:Variable name "obj1", value "document.forms[0]" -> var obj1 = document.forms[0];\n".

Parameter:
name - Variable name declared by JavaScript
value - Value of variable
Returns:
Edited string

defineArrayVariable

protected java.lang.String defineArrayVariable(java.lang.String arrayName,
                                               java.lang.String[] array)
Convert the array, passed as an argument, to type Array of JavaScript and return.
Example:Variable name"array", Value"10,20,30" ->"var obj1 = new Array("10","20","30");\n"
When argument array is null, NullPointerException occurs.

Parameter:
arrayName - Variable name declared by JavaScript
array - Array that retains the value which is created as Array
Returns:
Edited string

mapWeekdays

protected java.lang.String[] mapWeekdays(java.text.DateFormatSymbols symbols)
Fetch the "day" from the specified date format symbol and return.

Parameter:
symbols - Date format symbol (Locale settings done)
Returns:
Array wherein fetched "Day" is stored

mapMonths

protected java.lang.String[] mapMonths(java.text.DateFormatSymbols symbols)
Fetch the "Month" from the specified date format symbol and return.

Parameter:
symbols - Date format symbol(Locale setting done)
Returns:
Array wherein fetched "Month" is stored

getPageContextFlg

protected boolean getPageContextFlg(javax.servlet.jsp.PageContext pageContext,
                                    java.lang.String key)
Convert the value fetched by specified KEY into tru-value and return. When argument key is null, NullPointerException occurs.

Parameter:
pageContext - Page context
key - KEY that fetches FLG
Returns:
Output status flag that is fetched by specified KEY

setPageContextFlg

protected void setPageContextFlg(javax.servlet.jsp.PageContext pageContext,
                                 java.lang.String key)
Set the flag of specified KEY for the page context. When arguments key is null, NullPointerException occurs.

Parameter:
pageContext - Page context
key - KEY that sets FLG

createFormat

protected java.lang.String createFormat(java.lang.String format)
Check the date format for the strings of arguments. When string is null or blank, return it as it is. When the string does not correspond to date format, ignore.

Parameter:
format - Date format
Returns:
Format string after peforming check

release

public void release()
Release all allocated resources.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport