Custom JSP tags. Lets you present an annual calendar control in your applications. For example:
1. Simple form:
<y:AnnualCalendar />
and you will see some like this:
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2. You may add a header:
<y:AnnualCalendar header="true" />
Tag setHeaderBody lets you customize header.
For example:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3. Predefined variables for dates.
Within tag's body you can use predefined variables (types are java.lang.Integer). currYear is a current (not tag's!) year, currMonth is a current month (interval is 1-12), currDate is a current day and currDay is a day of week (interval is 1-7), nextMonth is a next (for this tag) month, prevMonth is a previous (for this tag) month, nextYear is currYear+1 if nextMonth == 1 and currYear otherwise, prevYear is currYear-1 if prevMonth == 12 and currYear otherwise.
4. You may add a hyperlink for any date (all dates):
<y:AnnualCalendar>
<y:setLink month="1" day="5">http://www.servletsuite.com</y:setLink>
<y:setLink month="12" day="15">http://www.servletsuite.com/jsp.htm</y:setLink>
</y:AnnualCalendar>
or let us see a link for the current date:
When you describe any hyperlink you may use meta symbols $d (will be
replaced by the selected day), $m (will be replaced by the selected month) and
$y (will be replaced by the selected year). For example this tag sets
hyperlinks for all days in February and for the each request day will be passed as a query
parameter:
You may define HTML settings for calendar's elements: describe CSS class or style.
Here is a bit more complex example with various attributes:
and you will see the following calendar:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Also you may set your own JSP code describes how to output (display) some
day (all days). By default it is just a day (with possible hyperlink). Body tag
setDateBody lets you customize this output. Within this tag you may
use predefined variables: D (type is java.lang.Integer, value is day for this tag),
M (type is java.lang.Integer, value is a month for calendar in 1-12 interval),
Y (type is java.lang.Integer, value is a year for calendar) and
LINK (type is java.lang.String, value is a hyperlink for day in tag).
For example, let us output a table for day 15 in the last example:
You can use your calendar just for date selection also. You may insert selected date into some field on your page. For example you may
use Calendar in javascript pop-up window and deploy setField tag instead of setLink.
Tag setField describes some field in your HTML form for selected date. Let us see an example:
So our data field is form1.dt (form name is form1, field name is dt and calendar uses a separate window).
In file calendar.jsp we will use AnnualCalendar tag:
Let us try this in action:
Tag setField lets you also define a format for selected date and describe location for your form.
Tags are:
AnnualCalendar
Displays an annual calendar. Parameters are:
1) year Optional parameter. Sets a year.
By default is current year.
2) locale Optional parameter. Describes a locale.
How to display days (what is a first day: Monday or Sunday) depends on the locale.
By default tag will use locale from browser's preferences.
3) header Optional parameter. Possible values are
true or false. Enables/disables header. Default value is false.
4) style Optional parameter. Describes your own CSS style for your calendar.
Default value is border: 2px inset; border-color: #000000.
5) className Optional parameter. Describes your own CSS class for your calendar.
6) columns Optional parameter. Describes how many monthes will be printer per row.
Possible values are 1, 2, 3, 4, 6, 12. Default value is 3.
7) monthClassName Optional parameter. Describes your own CSS class for the monthes.
8) monthStyle Optional parameter. Describes your own CSS style for the monthes.
Default value is border: 1px inset; border-color: #000000.
any tag described below is used in the context of Calendar tag:
setNextYear
Body tag. Body describes a hyperlink for the 'next month' view (could be a part of the header). By default (if tag's body is empty) this hyperlink will be the current URL and the following query string: year=YEAR_VALUE where YEAR_VALUE is a next year. Parameters are: none
setNextYearBody
Body tag. Body describes a body for the 'next year' hyperlink. By default it is >>.
setPrevYear
Body tag. Body describes a hyperlink for the 'previous month' view (could be a part of the header). By default (if tag's body is empty) this hyperlink will be the current URL and the following query string: year=YEAR_VALUE where YEAR_VALUE is a previous year. Parameters are: none
setPrevYearBody
Body tag. Body describes a body for the 'prev year' hyperlink. By default it is <<.
setLink
Body tag. Body describes a hyperlink for the particular day (all days). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this link will be assigned for all monthes.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this link will be assigned for all days.
setTarget
Body tag. Body describes a target frame for hyperlink (hyperlinks). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this frame will be assigned for all monthes.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this frame will be assigned for all days.
setField
Body tag. Body describes a field in some form that will be initialized by the selected date. Parameters are:
1) day Optional parameter. Describes some day.
Possible values are 1-31. By default this will be assigned for all days.
2) format Optional parameter. Describes a format for returned date.
E.g.: yyyy-MM-dd. By default tag will use MM/dd/yyyy or
dd/MM/yyyy format depends on locale.
3) window Optional parameter. Possible values are true or false.
You have to set this value to false if your form and calendar both are on the same page.
Default value is true (calendar uses a separate window).
4) multiple Optional parameter. Possible values are true or false.
If this value is true selected value will be concatenated to the current filed value. Also tag does not close window in this case. So you
will be able to select multiple dates and accumulate them as a space separated list in the given field.
Default value is false.
setHeaderClass
Body tag. Body describes a CSS class name for the header. Parameters are: none
setHeaderStyle
Body tag. Body describes a CSS style for the header. Parameters are: none
setHeaderBody
Body tag. Body describes a body for tag's header. By default it will be just a year. Parameters are: none
setMonthClass
Body tag. Body describes a CSS class name for the given month. Parameters are:
1) month Optional parameter. Describes a month. Possible values are 1-12. By default this class will be assigned for all monthes.
setMonthStyle
Body tag. Body describes a CSS style name for the given month. Parameters are:
1) month Optional parameter. Describes a month. Possible values are 1-12. By default this style will be assigned for all monthes.
setMonthHeaderClass
Body tag. Body describes a CSS class name for headers in monthes. Parameters are:
1) month Optional parameter. Describes a month. Possible values are 1-12. By default this class will be assigned for all monthes.
setMonthHeaderStyle
Body tag. Body describes a CSS style for headers in months. Parameters are:
1) month Optional parameter. Describes a month. Possible values are 1-12. By default this style will be assigned for all months.
setMonthHeaderFormat
Body tag. Body describes a format for headers in months. By default it is MMM. Parameters are:
1) month Optional parameter. Describes a month. Possible values are 1-12. By default this format will be assigned for all months.
setTitleClass
Body tag. Body describes a CSS class name for title (titles). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this class will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default link will be assigned for all days.
setTitleStyle
Body tag. Body describes a CSS style for title (titles). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this style will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default link will be assigned for all days.
setTitleFormat
Body tag. Body describes a format for title (titles). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default format will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-7. By default this format will be assigned for all days.
By default Calendar uses format EEE for titles (e.g. Mon, Tue, Wed etc.)
3) length Optional parameter. Describes a maximal length
for day's title. By default is undefined (unrestricted).
setDateClass
Body tag. Body describes a CSS class name for some day (all days). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this class will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this class will be assigned for all days.
setDateStyle
Body tag. Body describes a CSS style for some day (all days). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this style will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this style will be assigned for all days.
setLinkClass
Body tag. Body describes a CSS class name for day's hyperlink (for all days). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this class will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this class will be assigned for all days.
setLinkStyle
Body tag. Body describes a CSS style for day's hyperlink (for all days). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this style will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this style will be assigned for all days.
setSundayClass
Body tag. Body describes a CSS class name for Sunday (for all days). Parameters are:
1) prevail Optional parameter. Possible values are true or false. If this value is false than day's settings will prevail over the specified settings. Default value is true (this value will prevail).
setSundayStyle
Body tag. Body describes a CSS style for Sunday (for all days). Parameters are:
1) prevail Optional parameter. Possible values are true or false. If this value is false than day's settings will prevail over the specified settings. Default value is true (this value will prevail).
setSaturdayClass
Body tag. Body describes a CSS class name for Saturday (for all days). Parameters are:
1) prevail Optional parameter. Possible values are true or false. If this value is false than day's settings will prevail over the specified settings. Default value is true (this value will prevail).
setSaturdayStyle
Body tag. Body describes a CSS style for Saturday (for all days). Parameters are:
1) prevail Optional parameter. Possible values are true or false. If this value is false than day's settings will prevail over the specified settings. Default value is true (this value will prevail).
setDateBody
Body tag. Body describes your own JSP code for some day (all days). Parameters are:
1) month Optional parameter. Describes a month.
Possible values are 1-12. By default this value will be assigned for all months.
2) day Optional parameter. Describes some day.
Possible values are 1-31. By default this value will be assigned for all days.
Note: the evaluation version lets you display calendar for the current year only.
For downloading:
Evaluation version: annualtag.jar Description: taglib.tld
See also Coldtags suite - the largest collection of custom JSP tags.