01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2004 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package weblog;
19:
20: import java.awt.event.*;
21:
22: import javax.swing.*;
23:
24: import net.ar.webonswing.*;
25:
26: import org.wafer.weblog.om.*;
27: import org.wafer.weblog.servlet.*;
28:
29: public class RegisterPanel extends MultipleFieldsPanel {
30: JTextField usernameField;
31: JTextField emailField;
32: JTextField firstNameField;
33: JTextField lastNameField;
34: JTextField passwordField;
35:
36: public RegisterPanel() {
37: super (
38: new JLabel(
39: "Please fill in the following information to create a new account. All fields are required."));
40: }
41:
42: protected void initialize() {
43: super .initialize();
44:
45: submitButton.setText("Create User");
46: submitButton.addActionListener(new ActionListener() {
47: public void actionPerformed(ActionEvent arg0) {
48: try {
49: User newUser = WebLogSystem.getUserStore().create(
50: usernameField.getText(),
51: passwordField.getText());
52:
53: newUser.setFirstName(firstNameField.getText());
54: newUser.setLastName(lastNameField.getText());
55: newUser.setEmail(emailField.getText());
56: newUser.save();
57:
58: WosFramework.getSessionContext().put("activeUser",
59: newUser);
60: WosFramework.showChildWindow(getTopLevelAncestor(),
61: new Home());
62: WosFramework.hide(getTopLevelAncestor());
63: } catch (Exception e) {
64: e.printStackTrace();
65: }
66: }
67: });
68:
69: addFieldPanel("Username", usernameField = new JTextField());
70: addFieldPanel("Email", emailField = new JTextField());
71: addFieldPanel("First Name", firstNameField = new JTextField());
72: addFieldPanel("Last Name", lastNameField = new JTextField());
73: addFieldPanel("Password", passwordField = new JPasswordField());
74: }
75: }
|