Create your online calendar using JavaBean

zhaozj2021-02-17  81

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:

Wannian calendar </ title> </ head> <body bgcolor = "white"> // Settings page scripting language is Java, imported HTMLCALENDARNOTEPAD class, HTMLCALENDARNOTEPAD will tell <% @ page language = "java" import = "htmlcalendarnotepad"%> // Define a javabean, take the ID to htmlcal <jsp: usebean id = "htmlcal" scope = "session" class = "htmlcalendarnotepad" /> <% // Set the parameters, take the desired month in March, because the year is not set, the default is this year. Htmlcal.setMonth (3); // Set action, on March 24th, go to the sky, open in the new window (or open in other ways) htmlcal.setAction (24, "http: //www.yesky. COM / "," _ blank ");%> <table width = 300> <TR> <TD NOWRAP> <% = HTMLCAL.GETHTML ()%> // Output a month's calendar </ td> < / TR> </ table> </ body> </ html></p> <p>You will see the following output results</p> <p>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</p> <p>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</p> <p>I want to introduce some of the main methods in htmlcalendarnotepad, I believe everyone will help</p> <p>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</p> <p>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: <a href = "http://www.yesky.com/?date=20000621" Target = _BLANK> 21 </A></p> <p>Public void setActions (String ActionURL, String Target_frame) // You can also set a hyperlink for a month</p> <p>Now let me share the tempting beans (htmlcalendarnotepad.java). Import java.text.dateFormat; import java.text.SIMPLEDATEFORMAT; import java.util. *;</p> <p>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 [] = {</p> <p>"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";</p> <p>Public htmlcalendarnotepad () // Constructor</p> <p>{</p> <p>Sfont = NULL;</p> <p>Gregoriancalendar gcalendar = new gregoriancalendar (); // get the current calendar (Gri Gaoli)</p> <p>Config = new hashtable (); // Create a new hash table save configuration information</p> <p>NEWLINE = System.getProperty ("line.separator");</p> <p>Style = 2; // Settings per week for the first day of Sunday Month = gclendar.get (2); // Get the month</p> <p>Year = gclendar.get (1); // Take the year</p> <p>Loc = local.prc; // Set the country name, default is the People's Republic of China</p> <p>}</p> <p>Private string formatObject (string s, object obj)</p> <p>{</p> <p>String S1 = "";</p> <p>IF (Obj! = NULL)</p> <p>S1 = String.Valueof (String.Valueof (obj));</p> <p>IF (s == NULL)</p> <p>Return S1;</p> <p>Else</p> <p>RETURN S S1 "</ font>";</p> <p>}</p> <p>Private int getday (Calendar Calendar) / / get the location of a certain day in the calendar</p> <p>{</p> <p>IF (Style == 2)</p> <p>Return Calendar.get (7) - 1;</p> <p>Else</p> <p>Return (Calendar.get (7) 5)% 7;</p> <p>}</p> <p>Public String gethtml ()</p> <p>{</p> <p>Gregoriancalendar gclendar = New Gregoriancalendar (Year, Month - 1, 1);</p> <p>Gregoriancalendar gcalendar1 = New Gregoriancalendar (2001, 3, 24);</p> <p>SimpleDateFormat SimpleDateFormat = New SimpleDateFormat ("EEE", LOC);</p> <p>// Set the abbreviation format, Eee is the abbreviation of the week, such as Sun, if Eeee is Sunday.</p> <p>INT i = MONTH - 1;</p> <p>INT j = 0;</p> <p>StringBuffer stringbuffer = new stringbuffer ("); // Creating a new string buffer</p> <p>StringBuffer.Append ("<Table> <TR> / N"); // Add <Table> <TR> on StringBuffer, prepare for the form</p> <p>IF (style == 2) / / See explanation</p> <p>{</p> <p>StringBuffer.Append ("<th align = right>" formatObject (sfont, simledar1.gettime ())) "</ t> / n"); gclendar1.add (5, 1);</p> <p>For (int K = 1; K <7; k )</p> <p>{</p> <p>StringBuffer.Append ("<th align = right>" formatObject (sfont, simledar1.gettime ())) "</ t> / n");</p> <p>GCalendar1.Add (5, 1);</p> <p>}</p> <p>}</p> <p>Else</p> <p>{</p> <p>GCalendar1.Add (5, 1);</p> <p>StringBuffer.Append ("<th align = right>" formatObject (sfont, simledar1.gettime ())) "</ t> / n");</p> <p>For (int L = 2; l <8; l )</p> <p>{</p> <p>GCalendar1.Add (5, 1);</p> <p>StringBuffer.Append ("<th align = right>" formatObject (sfont, simledar1.gettime ())) "</ t> / n");</p> <p>}</p> <p>}</p> <p>StringBuffer.Append ("</ TR> / N");</p> <p>INT I1 = 0;</p> <p>J = 0;</p> <p>IF (getDay (gclendar)> 0)</p> <p>{</p> <p>StringBuffer.Append ("<tr>");</p> <p>For (; i1 <getday (gclendar); i1 )</p> <p>{</p> <p>StringBuffer.Append ("<td align = right>");</p> <p>IF (SFont! = NULL)</p> <p>StringBuffer.Append (sfont "</ font>");</p> <p>Else</p> <p>StringBuffer.Append ("");</p> <p>StringBuffer.Append ("</ td> / n");</p> <p>J ;</p> <p>}</p> <p>}</p> <p>For (; gclendar.get (2) == i; gclendar.Add (5, 1))</p> <p>{</p> <p>INT J1 = gclendar.get (5);</p> <p>INT K1 = (i1 j1)% 7;</p> <p>IF (k1 == 1)</p> <p>{</p> <p>StringBuffer.Append ("<tr>" newline);</p> <p>J = 0;</p> <p>}</p> <p>StringBuffer.Append ("<td align = right>");</p> <p>J ;</p> <p>IF (SFont! = NULL)</p> <p>StringBuffer.Append (sfont);</p> <p>String S;</p> <p>IF ((s = (string) config.get (String.Valueof (j1)))))! = NULL)</p> <p>{</p> <p>StringBuffer.Append ("<a href = /");</p> <p>IF (S.TOUPPERCASE (). StartSwith ("htt") || s.indexof (".")> 0) {</p> <p>StringBuffer.Append (s);</p> <p>IF (sindexof ("?") <0)</p> <p>StringBuffer.Append ("? Date =" StringDate (gclendar));</p> <p>Else</p> <p>StringBuffer.Append ("& Date =" StringDate (gclendar));</p> <p>}</p> <p>Else</p> <p>{</p> <p>StringBuffer.Append ("JavaScript:" S "('" StringDate (GCALENDAR) ");");</p> <p>}</p> <p>StringBuffer.Append ("/");</p> <p>IF ((s = (string) config.get (J1 Target "))! = null)</p> <p>StringBuffer.Append ("Target = /" s "/");</p> <p>StringBuffer.Append (">");</p> <p>StringBuffer.Append (gcalendar.get (5));</p> <p>StringBuffer.Append ("</a / n");</p> <p>}</p> <p>Else</p> <p>{</p> <p>StringBuffer.Append (String.Valueof (J1));</p> <p>}</p> <p>IF (SFont! = NULL)</p> <p>StringBuffer.Append ("</ font>");</p> <p>StringBuffer.Append ("</ td> / n");</p> <p>IF (k1 == 0)</p> <p>StringBuffer.Append ("</ TR> / N");</p> <p>}</p> <p>IF (j <7)</p> <p>{</p> <p>For (; J <7; J )</p> <p>{</p> <p>StringBuffer.Append ("<td align = right>");</p> <p>IF (SFont! = NULL)</p> <p>StringBuffer.Append (sfont);</p> <p>StringBuffer.Append ("");</p> <p>IF (SFont! = NULL)</p> <p>StringBuffer.Append ("</ font>");</p> <p>StringBuffer.Append ("</ td> / n");</p> <p>}</p> <p>StringBuffer.Append ("</ TR> / N");</p> <p>}</p> <p>StringBuffer.Append ("</ Table> / N");</p> <p>Return stringbuffer.tostring ();</p> <p>}</p> <p>Public Locale getLocale () // Get regional name</p> <p>{</p> <p>Return Loc;</p> <p>}</p> <p>Public int getYear () // gets the year</p> <p>{</p> <p>Return htmlcalendaryear;</p> <p>}</p> <p>Public int getMonth () // Give monthly</p> <p>{</p> <p>Return HTMLCALENDARMONTH;</p> <p>}</p> <p>Public int getStyle () // Get the style of the calendar</p> <p>{</p> <p>Return HTMLCALENDARSTYLE</p> <p>}</p> <p>/ / Set the URI of the action, the value of target_frame can be _blank, _parent, _top, _self.</p> <p>Public void setArtion (int day, string actionuri, string target_frame) {</p> <p>IF (Actionuri! = NULL)</p> <p>{</p> <p>Config.put (String.Valueof (day), actionuri;</p> <p>IF (target_frame! = null && target_frame.LENGTH ()> 0)</p> <p>Config.put (Day Target ", Target_Frame);</p> <p>}</p> <p>}</p> <p>// Set one month of all day hyperlinks</p> <p>Public void setActions (String Actionuri, String Target_frame)</p> <p>{</p> <p>For (int days = 1; day <= 31; day )</p> <p>SetAction (day, actionuri, target_frame);</p> <p>}</p> <p>// Set the area</p> <p>Public void setLocale (Locale Locale)</p> <p>{</p> <p>Loc = LOCALE;</p> <p>}</p> <p>// Set the year</p> <p>Public void setYear (int htmlcalendaryear)</p> <p>{</p> <p>IF (htmlcalendaryear> 0)</p> <p>{</p> <p>Year = htmlcalendaryear;</p> <p>CONFIG.CLEAR ();</p> <p>}</p> <p>}</p> <p>// Set the month</p> <p>Public void setmonth (int HTMLCALENDARMONTH)</p> <p>{</p> <p>IF (htmlcalendarmonth> = 1 && Htmlcalendarmonth <= 12)</p> <p>{</p> <p>Month = htmlcalendarmonth;</p> <p>CONFIG.CLEAR ();</p> <p>}</p> <p>}</p> <p>// Set the style of the calendar</p> <p>Public void setStyle (int htmlcalendarsty)</p> <p>{</p> <p>Style = htmlcalendarstyle;</p> <p>}</p> <p>Private string StringDate (Calendar Calendar)</p> <p>{</p> <p>String strday = string.valueof (Calendar.get (1));</p> <p>Return strDay Twodigits (Calendar.get (2) 1) Twodigits (Calendar.get (5));</p> <p>}</p> <p>Private String Twodigits (int day) // For the number of numbers in the calendar, it will add 0 before 1-9</p> <p>{</p> <p>String StringDay = String.Valueof (day); // Get the value of DAY</p> <p>IF (StringDay.Length () == 1) // If the string length is 1</p> <p>Return "0" StringDay; // add zero before the string</p> <p>Else</p> <p>Return StringDay;</p> <p>}</p> <p>}</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-31370.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="31370" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.064</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'RS_2FxvfKSPSfLZbdIlPtNTaPv_2FxzXvBeXliJLazrBcXk_2FuWqZ8_2BWbQ_2FR_2FzFNS7s9Lq9X5e70rErGq0rIXNB0nmQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>