Create | Calendars Some friends once said that if there is an online diary, or an online calendar can remind themselves to do things. Actually, you can do one of these calendars yourself. I don't believe you. See the following example:
〈html〉
〈head〉
〈title〉 million Calendar Notepad 〈/title〉
〈/head〉
〈body bgcolor = "white"
Set page scripting language is Java, import Htmlcalendarnotepad class, Htmlcalendarnotepad in the following will be mentioned
〈%@ page language= "java" import= "Htmlcalendarnotepad"%〉
Define a JavaBean whose ID is htmlcal
〈jsp:usebean id= "Htmlcal" scope= "session" class= "Htmlcalendarnotepad"/〉
〈%
Set the parameters, take the required month for March, because the year is not set, so the default for this year.
Htmlcal.setmonth (3);
Set action, March 24, go to Tenkine, open in a new window (or you can open it in a different way)
Htmlcal.setaction ("http://www.yesky.com/", "_blank");
%〉
〈table width=300〉
〈TR〉〈TD nowrap〉
〈%=htmlcal.gethtml ()%〉//prints a one month calendar in tabular form
〈/td〉〈/tr〉
〈/table〉
〈/body〉
〈/html〉
Isn't that the same as the calendar, but it's better than the calendar, with a preset link to remind you to go to a site, or to execute a JavaScript function, so you don't have a notepad anymore? Of course, you can also add some features to make it more powerful, such as adding a form, allowing users to fill in the diary sent to your system's database and so on. To accomplish this, let's take a look at how the JavaBean program is written.
JavaBean Program Analysis
I would like to introduce some of the main methods of Htmlcalendarnotepad, I believe that we will help
public void setyear (int years)//set year. The default value is the current year
public int getyear ()//Get year. The default value is the current year
This is standard Java program writing, because Java program is a class so often write this setxxx/getxxx
public void setmonth (int month)//Set month (1-12), default value is current month
public int getmonth ()//Get Month (1-12), default value is current month
public void SetStyle (int style)
public int GetStyle ()
Set/Get the style of the calendar (style)
Is the first day of the week in Sunday Htmlcalendarnotepad.sunday_first or the first day of the week in Monday Htmlcalendarnotepad.monday_first
The default value is Htmlcalendarnotepad.sunday_first
public void SetLocale (Locale loc)//Set region code (LOCALE), default value is LOCALE.PRC
Public Locale GetLocale ()//Get Region code (LOCALE), default value is LOCALE.PRC
public void setaction (int day, string actionurl, String target_frame)
Set up hyperlinks to process requests. If any errors are made, the method returns an empty string.
You can set an ordinary URL, such as "http://www.yesky.com/action.jsp"
or a JavaScript function name, such as "MyFunction"
The date will be passed as a parameter to the URL, or passed as a string value to JavaScript. The format is YYYYMMDD.
Target_frame can be an empty string.
Such as:
If you call Setaction ("http://www.yesky.com/", "_blank")
Hyperlink is: 〈a href= "http://www.yesky.com/?date=20000621" target=_blank〉21〈/a〉
public void Setactions (string actionurl, String target_frame)
You can also set a hyperlink for each day of the one month
Now let me share with you the tempting bean (bean): (Htmlcalendarnotepad.java).
Import Java.text.DateFormat;
Import Java.text.SimpleDateFormat;
Import java.util.*;
public class Htmlcalendarnotepad
{
public static final int monday_first = 1; Set each week to be Monday for the first day
public static final int sunday_first = 2; Set each week to be Sunday for the first day
Private Hashtable config;
private static final String mnth[] = {
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.