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:
19: package com.salmonllc.examples.example13;
20:
21: import java.math.BigDecimal;
22: import java.sql.Timestamp;
23:
24: import com.salmonllc.jsp.*;
25: import com.salmonllc.html.events.*;
26:
27: public class BeanController extends JspController implements
28: SubmitListener {
29: public com.salmonllc.html.HtmlSubmitButton _submit1;
30: public com.salmonllc.sql.BeanDataStore _datasource1;
31: public com.salmonllc.jsp.JspDataTable _datatable1;
32:
33: private int _count;
34:
35: public void initialize() {
36: _submit1.addSubmitListener(this );
37: }
38:
39: public boolean submitPerformed(SubmitEvent e) throws Exception {
40: //when the page is submitted, make the table visible, create a few beans to populate the datasource
41: _datatable1.setVisible(true);
42:
43: //In this example, the bean is created with a new Bean(), but it could also be created by calling an EJB remote method
44: ExampleBean b = null;
45: for (int i = 0; i < 3; i++) {
46: b = new ExampleBean("Val" + _count++, new BigDecimal(
47: _count++ * 1.5), new Timestamp(System
48: .currentTimeMillis()), _count++, "Sub Value "
49: + _count++, "Sub Value " + _count++);
50: _datasource1.insertRow(b);
51: }
52: return true;
53: }
54:
55: }
|