Java bean lets you generate Calendar for your HTML pages.
Let we see one example.
<html>
<head>
<title>Calendar demo</title>
</head>
<body bgcolor="white">
<jsp:useBean id="HtmlCal" scope="session" class="com.cj.htmlcal.HtmlCalendar" />
<%
// set parameters
HtmlCal.setMonth(6);
HtmlCal.setAction(24,"http://www.servletsuite.com","_blank");
%>
<table width=300>
<tr><td nowrap>
<%=HtmlCal.getHtml()%>
</td></tr>
</table>
</body>
</html>
And you will get the following output:
|
Bean methods:
constructor:
HtmlCalendar ()
methods:
// set/get year. Default value is current
year
public void setYear(int year)
public int getYear()
// set/get month (1-12). Default value is current
month
public void setMonth(int month)
public int getMonth()
// set/get style. HtmlCalendar.SUNDAY_FIRST or
HtmlCalendar.MONDAY_FIRST
// Default value is HtmlCalendar.SUNDAY_FIRST
public void setStyle(int style)
public int getStyle()
// set/get Locale. Default value is Locale.US
public void setLocale(Locale loc)
public Locale getLocale()
// set hyperlink. proceed request. Method returns
empty string in case any error.
// You can set hyperlink as a some url, e.g.
"http://your_host/action.htm"
// or as a name of javascript function, e.g.
"myFunction"
// Date will be passed as a get parameter to
url request or as string value
// to javascript. Format is yyyymmdd.
// target_frame may be null or empty string.
public void setAction(int day, String url_or_javascript,
String target_frame)
E.g.:
for the call setAction(24,"http://www.servletsuite.com","_blank")
hyperlink is: <a href="http://www.acme.com?date=20000624"
target=_blank>24</a>
for the call setAction(24,"myfunction","")
hyperlink is: <a href="javascript:myfunction('20000624');">24</a>
// you can set hyperlinks for all days of month
public void setActions(String url_or_javascript,
String target_frame)
Note: See also Calendar taglib
For downloading: htmlcal.jar (you have to put this file into WEB-INF/lib).
See also Coldtags suite - the largest collection of custom JSP tags.