01: //The Salmon Open Framework for Internet Applications (SOFIA)
02: //Copyright (C) 1999 - 2002, Salmon LLC
03: //
04: //This program is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU General Public License version 2
06: //as published by the Free Software Foundation;
07: //
08: //This program is distributed in the hope that it will be useful,
09: //but WITHOUT ANY WARRANTY; without even the implied warranty of
10: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: //GNU General Public License for more details.
12: //
13: //You should have received a copy of the GNU General Public License
14: //along with this program; if not, write to the Free Software
15: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16: //
17: //For more information please visit http://www.salmonllc.com
18: package com.salmonllc.examples.example17;
19:
20: import com.salmonllc.jsp.*;
21: import com.salmonllc.html.events.*;
22:
23: /**
24: * ReportAppletController: a SOFIA generated controller. This controller passes URL line parameters to the applet tag so they can be communicated to the applet.
25: */
26: public class ReportAppletController extends JspController implements
27: PageListener, ReportParameterConstants {
28: public com.salmonllc.html.HtmlApplet _applet1;
29:
30: /**
31: * Initialize the page.
32: */
33: public void initialize() {
34: addPageListener(this );
35: }
36:
37: /**
38: * When the page is requested take parameters from the URL line and pass them to the applet. The parameters are set from the ReportSelection page/contntroller
39: */
40: public void pageRequested(PageEvent event) {
41: String reportURL = getCurrentRequest().getParameter(REPORT_URL);
42: String modelClass = getCurrentRequest().getParameter(
43: MODEL_CLASS);
44: String imageURL = getCurrentRequest().getParameter(
45: IMAGE_BASE_URL);
46: String selectionCriteria = getCurrentRequest().getParameter(
47: SELECTION_CRITERIA);
48:
49: _applet1.setParm(REPORT_URL, reportURL);
50: _applet1.setParm(IMAGE_BASE_URL, imageURL);
51: _applet1.setParm(MODEL_CLASS, modelClass);
52:
53: //if there are any double quotes in the criteria string it will mess up the HTML so replace them with "
54: _applet1.setParm(SELECTION_CRITERIA,
55: fixQuote(selectionCriteria));
56: }
57:
58: private String fixQuote(String criteria) {
59: StringBuffer sb = new StringBuffer(criteria.length());
60: for (int i = 0; i < criteria.length(); i++) {
61: char c = criteria.charAt(i);
62: if (c == '"')
63: sb.append(""");
64: else
65: sb.append(c);
66: }
67: return sb.toString();
68: }
69:
70: public void pageRequestEnd(PageEvent event) {
71: }
72:
73: public void pageSubmitEnd(PageEvent event) {
74: }
75:
76: public void pageSubmitted(PageEvent event) {
77: }
78:
79: }
|