01: package com.salmonllc.examples.example4;
02:
03: //The Salmon Open Framework for Internet Applications (SOFIA)
04: //Copyright (C) 1999 - 2002, Salmon LLC
05: //
06: //This program is free software; you can redistribute it and/or
07: //modify it under the terms of the GNU General Public License version 2
08: //as published by the Free Software Foundation;
09: //
10: //This program is distributed in the hope that it will be useful,
11: //but WITHOUT ANY WARRANTY; without even the implied warranty of
12: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: //GNU General Public License for more details.
14: //
15: //You should have received a copy of the GNU General Public License
16: //along with this program; if not, write to the Free Software
17: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: //
19: //For more information please visit http://www.salmonllc.com
20:
21: import com.salmonllc.jsp.*;
22: import com.salmonllc.html.*;
23: import com.salmonllc.html.events.*;
24:
25: /**
26: * A controller for the Calendar.jsp (example 4)
27: */
28: public class CalendarController extends JspController implements
29: SubmitListener, CalendarListener {
30:
31: //Visual Components
32: public com.salmonllc.html.HtmlCalendar _calendar1;
33: public com.salmonllc.html.HtmlSubmitButton _submit1;
34: public com.salmonllc.html.HtmlText _sourceList;
35: public com.salmonllc.html.HtmlText _text1;
36:
37: /**
38: * Called when the page is first hit in the browser
39: */
40: public void initialize() {
41: _calendar1.addCalendarListener(this );
42: _submit1.addSubmitListener(this );
43: _text1.setVisible(false);
44: }
45:
46: /**
47: * Called when the user clicks the resize submit button
48: */
49: public boolean submitPerformed(SubmitEvent e) throws Exception {
50: if (_calendar1.getDisplaySize() == HtmlCalendar.SIZE_LARGE) {
51: _calendar1.setDisplaySize(HtmlCalendar.SIZE_SMALL);
52: _submit1.setDisplayName("Make Calendar Bigger");
53: } else {
54: _calendar1.setDisplaySize(HtmlCalendar.SIZE_LARGE);
55: _submit1.setDisplayName("Make Calendar Smaller");
56: }
57:
58: return true;
59: }
60:
61: /**
62: * This Event is fired when the user chooses a date from the calendar.
63: */
64: public void dateSelected(CalendarDateSelectedEvent e) {
65: _text1.setText("A Date Was Selected:" + e.getDateAsSQLDate());
66: _text1.setVisible(true);
67: }
68:
69: /**
70: * This Event is fired when the user changes the month or year in a calendar. Return true to allow the change or false to disallow it.
71: */
72: public boolean monthChanged(CalendarMonthChangeEvent e) {
73: _text1.setText("A Month Was Selected:"
74: + _calendar1.getMonthLongName(e.getNewMonth()) + " "
75: + e.getNewYear());
76: _text1.setVisible(true);
77: return true;
78: }
79:
80: }
|