Create your online calendar using JavaBean 2001-04-05 · Wayne · Yesky
Some friends have said that if there is an online diary, or a network that can remind himself to do what is going to do. Actually, such a calendar can be a one. Don't believe you look at the example below:
<% = HTMLCAL.GETHTML ()%> // Output a month's calendar td> < / TR> table> body> html>
You will see the following output results Mon Tue Wed Thu Fri Sat Sun 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 24 25 25 26 27 28 29 30 31 This is not the same as the calendar, but it is better than the calendar, there is a pre-set link to remind you to a site, or a JavaScript function, this is not a notepad. Is there a role? Of course, you can also add some functions 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. In order to complete this purpose, let's take a look at how the JavaBean program is written. JavaBean program analysis I want to introduce some of the main methods in htmlcalendarnotepad, I believe everyone will help Public void setYear (int year) // Set the year. The default value is the current year public int gameEear () //. The default value is current year // This is a standard Java program to write, because the Java program is a class, so often write this setXX / getXxxpublic void setMonth // set the month (1-12), the default is current Month () (1-12), the default value for the current month public void setStyle () // style // is Sunday Publici HtmlCalendarNotePad.SUNDAY_FIRST first day of the week or in the first day of the week is Monday HtmlCalendarNotePad.MONDAY_FIRST // default value HtmlCalendarNotePad.SUNDAY_FIRST public void setLocale (Locale loc) // set the region code (Locale), the default value Get regional code () // for local () //, the default value is Locale.prc Public Void SetAction (int Day, String ActionURL, String Target_frame) // Sets the hyperlink to process the request. If you have any errors, this 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 "// will be passed as a parameter to the URL Alternatively, as a string value to javascript. Format is YYYYMMDD. // target_frame can be an empty string. Such as: If the setAction (21, "http://www.yesky.com/", "_blank") hyperlink is: 21 Public void setActions (String ActionURL, String Target_frame) // You can also set a hyperlink for a month Now let me share the tempting beans (htmlcalendarnotepad.java). Import java.text.dateFormat; import java.text.SIMPLEDATEFORMAT; import java.util. *; Public class htmlcalendarnotepad {public static final int mondyn_first = 1; // Setting per week is on Monday as the first day PUBLIC Static Final Int sunday_first = 2; // Setting per week is the first day of Sunday Private HashTable Config; Private Static firm string mnth [] = { "Jan", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; private int year; private int style; private intelect; private locale loc; private static string newline = "/ n"; Public htmlcalendarnotepad () // Constructor { Sfont = NULL; Gregoriancalendar gcalendar = new gregoriancalendar (); // get the current calendar (Gri Gaoli) Config = new hashtable (); // Create a new hash table save configuration information NEWLINE = System.getProperty ("line.separator"); Style = 2; // Settings per week for the first day of Sunday Month = gclendar.get (2); // Get the month Year = gclendar.get (1); // Take the year Loc = local.prc; // Set the country name, default is the People's Republic of China } Private string formatObject (string s, object obj) { String S1 = ""; IF (Obj! = NULL) S1 = String.Valueof (String.Valueof (obj)); IF (s == NULL) Return S1; Else RETURN S S1 " font>"; } Private int getday (Calendar Calendar) / / get the location of a certain day in the calendar { IF (Style == 2) Return Calendar.get (7) - 1; Else Return (Calendar.get (7) 5)% 7; } Public String gethtml () { Gregoriancalendar gclendar = New Gregoriancalendar (Year, Month - 1, 1); Gregoriancalendar gcalendar1 = New Gregoriancalendar (2001, 3, 24); SimpleDateFormat SimpleDateFormat = New SimpleDateFormat ("EEE", LOC); // Set the abbreviation format, Eee is the abbreviation of the week, such as Sun, if Eeee is Sunday. INT i = MONTH - 1; INT j = 0; StringBuffer stringbuffer = new stringbuffer ("); // Creating a new string buffer StringBuffer.Append (" |