| java.lang.Object org.apache.turbine.util.DateSelector
DateSelector | public class DateSelector (Code) | | DateSelector is a utility class to handle the creation of a set of
date popup menus. The code is broken into a set of static methods
for quick and easy access to the individual select objects:
ElementContainer ec dateSelect = new ElementContainer();
String myName = "mydate";
ec.addElement(DateSelector.getMonthSelector(myName));
ec.addElement(DateSelector.getDaySelector(myName));
ec.addElement(DateSelector.getYearSelector(myName));
There are also methods which will use attributes to build a
complete month,day,year selector:
DateSelector ds = new DateSelector(myName);
dateSelect = ds.ecsOutput();
The above element container would use the onChange setting and may
hide the selected day if set via showDays().
author: Jeffrey D. Brekke author: Jon S. Stevens author: Leon Atkinson version: $Id: DateSelector.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public ElementContainer | ecsOutput() | public static Select | getDaySelector(String name) Return a day selector.
Parameters: name - The name to use for the selected day. | public static Select | getDaySelector(String name, Calendar now) Return a day selector.
Parameters: name - The name to use for the selected day. Parameters: now - Calendar to start with. | public static Select | getMonthSelector(String name) Return a month selector.
Parameters: name - The name to use for the selected month. | public static Select | getMonthSelector(String name, Calendar now) Return a month selector.
Note: The values of the month placed into the select list are
the month integers starting at 0 (ie: if the user selects
February, the selected value will be 1).
Parameters: name - The name to use for the selected month. Parameters: now - Calendar to start with. | public String | getSelName() Get the selector name prefix. | public static Select | getYearSelector(String name) Return a year selector.
Parameters: name - The name to use for the selected year. | public static Select | getYearSelector(String name, Calendar now) Return a year selector.
Parameters: name - The name to use for the selected year. Parameters: now - Calendar to start with. | public static Select | getYearSelector(String name, int firstYear, int lastYear, int selectedYear) Return a year selector.
Parameters: name - The name to use for the selected year. Parameters: firstYear - the first (earliest) year in the selector. Parameters: lastYear - the last (latest) year in the selector. Parameters: selectedYear - the year initially selected in the Select html. | public String | output() Used to build the popupmenu in HTML. | public DateSelector | setDay(int day) Select the day to be selected if the showDays(false) behavior
is used. | public DateSelector | setOnChange(String onChange) Adds the onChange to all of <SELECT> tags. | public void | setSelName(String selName) Set the selector name prefix. | public DateSelector | setShowDay(boolean show) Whether or not to show the days as a popup menu. | public boolean | setYear(int firstYear, int lastYear, int selectedYear) Select the day to be selected if the showDays(false) behavior
is used. | public String | toString() Used to build the popupmenu in HTML. |
DAY_SUFFIX | final public static String DAY_SUFFIX(Code) | | Suffix for day parameter.
|
DEFAULT_PREFIX | final public static String DEFAULT_PREFIX(Code) | | Prefix for date names.
|
MONTH_SUFFIX | final public static String MONTH_SUFFIX(Code) | | Suffix for month parameter.
|
YEAR_SUFFIX | final public static String YEAR_SUFFIX(Code) | | Suffix for year parameter.
|
DateSelector | public DateSelector()(Code) | | Constructor defaults to current date and uses the default
prefix: DateSelector.DEFAULT
|
DateSelector | public DateSelector(String selName, Calendar useDate)(Code) | | Constructor, uses the date set in a calendar that has been
already passed in (with the date set correctly).
Parameters: selName - A String with the selector name. Parameters: useDate - A Calendar with a date. |
DateSelector | public DateSelector(String selName)(Code) | | Constructor defaults to current date.
Parameters: selName - A String with the selector name. |
ecsOutput | public ElementContainer ecsOutput()(Code) | | |
getDaySelector | public static Select getDaySelector(String name)(Code) | | Return a day selector.
Parameters: name - The name to use for the selected day. A select object with all the days in a month. |
getDaySelector | public static Select getDaySelector(String name, Calendar now)(Code) | | Return a day selector.
Parameters: name - The name to use for the selected day. Parameters: now - Calendar to start with. A select object with all the days in a month. |
getMonthSelector | public static Select getMonthSelector(String name)(Code) | | Return a month selector.
Parameters: name - The name to use for the selected month. A select object with all the months. |
getMonthSelector | public static Select getMonthSelector(String name, Calendar now)(Code) | | Return a month selector.
Note: The values of the month placed into the select list are
the month integers starting at 0 (ie: if the user selects
February, the selected value will be 1).
Parameters: name - The name to use for the selected month. Parameters: now - Calendar to start with. A select object with all the months. |
getSelName | public String getSelName()(Code) | | Get the selector name prefix.
A String with the select name prefix. |
getYearSelector | public static Select getYearSelector(String name)(Code) | | Return a year selector.
Parameters: name - The name to use for the selected year. A select object with all the years starting five yearsfrom now and five years before this year. |
getYearSelector | public static Select getYearSelector(String name, Calendar now)(Code) | | Return a year selector.
Parameters: name - The name to use for the selected year. Parameters: now - Calendar to start with. A select object with all the years starting five yearsfrom now and five years before this year. |
getYearSelector | public static Select getYearSelector(String name, int firstYear, int lastYear, int selectedYear)(Code) | | Return a year selector.
Parameters: name - The name to use for the selected year. Parameters: firstYear - the first (earliest) year in the selector. Parameters: lastYear - the last (latest) year in the selector. Parameters: selectedYear - the year initially selected in the Select html. A select object with all the years from firstyearto lastyear.. |
output | public String output()(Code) | | Used to build the popupmenu in HTML. The properties set in the
object are used to generate the correct HTML. The selName
attribute is used to seed the names of the select lists. The
names will be generated as follows:
- selName + "_month"
- selName + "_day"
- selName + "_year"
If onChange was set it is also used in the generation of the
output. The output HTML will list the select lists in the
following order: month day year.
A String with the correct HTML for the date selector. |
setDay | public DateSelector setDay(int day)(Code) | | Select the day to be selected if the showDays(false) behavior
is used. Individual getMonth, getDay, getYear static methods
will not use this setting.
Parameters: day - The day. A DateSelector (self). |
setOnChange | public DateSelector setOnChange(String onChange)(Code) | | Adds the onChange to all of <SELECT> tags. This is limited to
one function for all three popups and is only used when the
output() methods are used. Individual getMonth, getDay,
getYear static methods will not use this setting.
Parameters: string - A String to use for onChange attribute. If null,then nothing will be set. A DateSelector (self). |
setSelName | public void setSelName(String selName)(Code) | | Set the selector name prefix. Individual getMonth, getDay,
getYear static methods will not use this setting.
Parameters: selname - A String with the select name prefix. |
setShowDay | public DateSelector setShowDay(boolean show)(Code) | | Whether or not to show the days as a popup menu. The days will
be a hidden parameter and the value set with setDay is used.
Individual getMonth, getDay, getYear static methods will not
use this setting.
Parameters: show - True if the day should be shown. A DateSelector (self). |
setYear | public boolean setYear(int firstYear, int lastYear, int selectedYear)(Code) | | Select the day to be selected if the showDays(false) behavior
is used. Individual getMonth, getDay, getYear static methods
will not use this setting.
Parameters: day - The day. A DateSelector (self). |
toString | public String toString()(Code) | | Used to build the popupmenu in HTML. The properties set in the
object are used to generate the correct HTML. The selName
attribute is used to seed the names of the select lists. The
names will be generated as follows:
- selName + "_month"
- selName + "_day"
- selName + "_year"
The output HTML will list the select lists in the following
order: month day year.
A String with the correct HTML for the date selector. |
|
|