Custom JSP tags. Lets you present an annual calendar control in your applications. For example: 1. Simple form:
<%@ taglib uri="taglib.tld" prefix="y" %> <y:AnnualCalendar />
and you will see some like this:
2. You may add a header:
<%@ taglib uri="taglib.tld" prefix="y" %> <y:AnnualCalendar header="true" />
Tag setHeaderBody lets you customize header.
For example:
<y:AnnualCalendar header="true"> <y:setHeaderBody>2006 year</y:setHeaderBody> </y:AnnualCalendar>
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):
<%@ taglib uri="taglib.tld" prefix="y" %> <y:AnnualCalendar>
or let us see a link for the current date:
<y:setLink day="<%=currDate%>">http://www.servletsuite.com</y:setLink> 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:
<y:setLink month="2">http://www.servletsuite.com?$d</y:setLink>
You may define HTML settings for calendar's elements: describe CSS class or style.
Here is a bit more complex example with various attributes:
<style> .test { color:white; background:black; } </style> <y:AnnualCalendar locale="<%=java.util.Locale.GERMANY%>" header="true"> <y:setTitleStyle>font-size:10pt; color:#FF0000</y:setTitleStyle> <y:setHeaderStyle>color:#0000FF; text-decoration:none</y:setHeaderStyle> <y:setLink day="5">http://www.servletsuite.com</y:setLink> <y:setLink day="15">http://www.servletsuite.com/jsp.htm?$d</y:setLink> <y:setDateClass day="10">test</y:setDateClass> <y:setTarget>_blank</y:setTarget> <y:setNextYear>http://www.servletsuite.com?<%=nextYear%></y:setNextYear> <y:setPrevYear>http://www.servletsuite.com?<%=prevYear%></y:setPrevYear> </y:AnnualCalendar> 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:
... <y:setDateBody day="15"> <table border=1 width=25 height=25> <tr><td align=center><%=LINK%></td></tr> </table> </y:setDateBody> ... 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:
<form name=form1> <input type="text" name="dt"> <input type=button value="Set Date" onClick="window.open('calendar.jsp','date', 'width=400,height=200, toolbar=no,location=no,menubar=no');"> </form> 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:
<y:AnnualCalendar> <y:setField>form1.dt</y:setField> </y:AnnualCalendar> 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
|
Also in Coldtags:
|