01: //package statement
02: package com.salmonllc.examples.example19;
03:
04: //The Salmon Open Framework for Internet Applications (SOFIA)
05: //Copyright (C) 1999 - 2002, Salmon LLC
06: //
07: //This program is free software; you can redistribute it and/or
08: //modify it under the terms of the GNU General Public License version 2
09: //as published by the Free Software Foundation;
10: //
11: //This program is distributed in the hope that it will be useful,
12: //but WITHOUT ANY WARRANTY; without even the implied warranty of
13: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: //GNU General Public License for more details.
15: //
16: //You should have received a copy of the GNU General Public License
17: //along with this program; if not, write to the Free Software
18: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: //
20: //For more information please visit http://www.salmonllc.com
21:
22: //Salmon import statements
23: import com.salmonllc.jsp.*;
24: import com.salmonllc.html.HtmlLookUpComponent;
25: import com.salmonllc.html.events.*;
26:
27: /**
28: * This controller is for the Contact List popup component. It is used to seed the search based on the
29: * current value in the lookup component.
30: */
31: public class ContactLookupController extends JspController implements
32: PageListener {
33:
34: //Visual Components
35:
36: //Visual Components
37: public com.salmonllc.html.HtmlTextEdit _txtContactId;
38: public com.salmonllc.html.HtmlTextEdit _txtContactName;
39:
40: public com.salmonllc.jsp.JspListFormDisplayBox _listformdisplaybox1;
41: public com.salmonllc.jsp.JspSearchFormDisplayBox _searchformdisplaybox1;
42: public com.salmonllc.jsp.JspDataTable _datatable1;
43:
44: //DataSources
45: public com.salmonllc.sql.DataStore _dsContactList;
46: public com.salmonllc.sql.QBEBuilder _qbe1;
47:
48: /**
49: * Initialize the page. Set up listeners and perform other initialization activities.
50: */
51: public void initialize() {
52: addPageListener(this );
53: _datatable1.setScrollOnClickSort(false);
54: }
55:
56: /**
57: * Process the page requested event.
58: */
59: public void pageRequested(PageEvent event) throws Exception {
60: if (!isReferredByCurrentPage()) {
61: doSearch(HtmlLookUpComponent.getParentLookupValue(this ));
62: _txtContactId.setFocus();
63: }
64: }
65:
66: private void doSearch(String value) throws Exception {
67: //get the current value of the lookup component and run a search with it
68:
69: if (value != null) {
70: try {
71: Integer.parseInt(value);
72: _txtContactId.setValue(value);
73: _txtContactId.setFocus();
74: _txtContactName.setValue(null);
75: } catch (Exception ex) {
76: _txtContactName.setValue(value);
77: _txtContactName.setFocus();
78: _txtContactId.setValue(null);
79: }
80:
81: _searchformdisplaybox1.doSearch();
82: } else {
83: _txtContactId.setValue("");
84: _txtContactId.setFocus();
85: _searchformdisplaybox1.getDataStoreBuffer().reset();
86: }
87:
88: }
89:
90: public void pageRequestEnd(PageEvent event) {
91: }
92:
93: public void pageSubmitEnd(PageEvent event) {
94: }
95:
96: public void pageSubmitted(PageEvent event) {
97: }
98:
99: }
|