01: package com.salmonllc.examples.example6;
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.events.*;
23:
24: public class ProductSearchController extends JspController implements
25: SubmitListener {
26:
27: //Visual Components
28: public com.salmonllc.html.HtmlSubmitButton _searchButton;
29: public com.salmonllc.html.HtmlText _description;
30: public com.salmonllc.html.HtmlText _descriptionCap;
31: public com.salmonllc.html.HtmlText _headingText;
32: public com.salmonllc.html.HtmlText _parentID;
33: public com.salmonllc.html.HtmlText _parentIDCap;
34: public com.salmonllc.html.HtmlText _productCatID;
35: public com.salmonllc.html.HtmlText _productCatIDCap;
36: public com.salmonllc.html.HtmlText _returnToHomePageText;
37: public com.salmonllc.html.HtmlText _searchCap;
38: public com.salmonllc.html.HtmlText _rowCap;
39: public com.salmonllc.html.HtmlText _sourceList;
40: public com.salmonllc.html.HtmlText _title;
41: public com.salmonllc.html.HtmlTextEdit _search;
42: public com.salmonllc.jsp.JspBox _box1;
43: public com.salmonllc.jsp.JspDataTable _datatable1;
44: public com.salmonllc.html.HtmlText _selectionText;
45: public com.salmonllc.html.HtmlSubmitButton _submitSelectionButton;
46:
47: //DataSources
48: public com.salmonllc.examples.example5.ProductCategoryModel _productModel;
49: public com.salmonllc.sql.QBEBuilder _productQBE;
50:
51: /**
52: * Called when the page is created.
53: */
54: public void initialize() {
55: _searchButton.addSubmitListener(this );
56: _submitSelectionButton.addSubmitListener(this );
57: _box1.setVisible(false);
58: }
59:
60: /**
61: * Called when the search button is clicked.
62: */
63: public boolean submitPerformed(SubmitEvent e) throws Exception {
64: if (e.getComponent() == _searchButton) {
65: _box1.setVisible(true);
66: _productModel.retrieve(_productQBE);
67: boolean vis = _productModel.getRowCount() > 0;
68: _rowCap.setVisible(vis);
69: _submitSelectionButton.setVisible(vis);
70: _selectionText.setVisible(vis);
71: _selectionText.setText("No Categories Selected.");
72: } else {
73: StringBuffer selectedRows = new StringBuffer();
74: for (int i = 0; i < _productModel.getRowCount(); i++) {
75: if (_productModel.getSelected(i) == 1) {
76: selectedRows.append(new Integer(_productModel
77: .getProductCategoryProductCatId(i))
78: .toString());
79: selectedRows.append(",");
80: }
81: }
82:
83: if (selectedRows.length() > 0) {
84: selectedRows.setLength(selectedRows.length() - 1);
85: _selectionText.setText("Selected Categories:"
86: + selectedRows.toString());
87: } else
88: _selectionText.setText("No Categories Selected.");
89: }
90: return true;
91: }
92:
93: }
|