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 java.net.URLEncoder;
21:
22: import com.salmonllc.examples.SiteMapConstants;
23: import com.salmonllc.html.events.SubmitEvent;
24: import com.salmonllc.html.events.SubmitListener;
25: import com.salmonllc.jsp.JspController;
26:
27: /**
28: * ContactReportsSelectionController: a SOFIA generated controller. This is used as a front end for the Jasper Report Viewer. It's job is to get selection criteria from the user and construct the appropriate URL line for the viewer applet or Web Start application.
29: */
30: public class ReportSelectionController extends JspController implements
31: SubmitListener, ReportParameterConstants {
32:
33: //Visual Components
34: public com.salmonllc.html.HtmlDropDownList _showResults;
35: public com.salmonllc.html.HtmlSubmitButton _runReport;
36: public com.salmonllc.html.HtmlTextEdit _eMail;
37: public com.salmonllc.html.HtmlTextEdit _firstName;
38: public com.salmonllc.html.HtmlTextEdit _lastName;
39:
40: //DataSources
41: public com.salmonllc.examples.example8.ContactQBE _contactQBE;
42:
43: /**
44: * Initialize the page. Set up listeners and perform other initialization activities.
45: */
46: public void initialize() {
47: _runReport.addSubmitListener(this );
48: }
49:
50: /**
51: * Process the given submit event
52: * @param event the submit event to be processed
53: * @return true to continue processing events, false to stop processing events
54: */
55: public boolean submitPerformed(SubmitEvent event) throws Exception {
56: String selectionCriteria = _contactQBE
57: .generateSQLFilter(new ContactModel(
58: getApplicationName()));
59: if (selectionCriteria != null)
60: selectionCriteria = URLEncoder.encode(selectionCriteria);
61: String reportURL = URLEncoder
62: .encode("/Jsp/example17/reportDefinition/ContactReportDef.jasper");
63: String imageURL = URLEncoder.encode("/Jsp/example17/images");
64: String modelClass = "com.salmonllc.examples.example17.ContactModel";
65:
66: String parms = "?" + SELECTION_CRITERIA + "="
67: + selectionCriteria + "&" + REPORT_URL + "="
68: + reportURL + "&" + IMAGE_BASE_URL + "=" + imageURL
69: + "&" + MODEL_CLASS + "=" + modelClass;
70:
71: if (_showResults.getValue().equals("application"))
72: gotoSiteMapPage(SiteMapConstants.JASPER_REPORT_WEB_START,
73: parms);
74: else
75: gotoSiteMapPage(SiteMapConstants.JASPER_REPORT_APPLET,
76: parms);
77: return true;
78: }
79:
80: }
|