UserView.java
2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package fi.insomnia.bortal.view;
import java.math.BigDecimal;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.ListDataModel;
import javax.persistence.Column;
import fi.insomnia.bortal.UserBeanLocal;
import fi.insomnia.bortal.db.User;
@ManagedBean(name="UserView")
@SessionScoped
public class UserView {
@EJB
private UserBeanLocal userBean;
//
// private String name;
// private String password;
// private String nick;
// private String email;
// private String address;
// @Column(length = 11)
// private String zip;
private User currentUser;
private String nick = "default";
private String password = "default";
private String realname = "default";
private String email = "default";
private String address = "default";
private String town = "default";
private String phone ="default";
private Boolean female = false;
private String zip = "default";
private ListDataModel<User> items;
public String saveUser()
{
// Luodaan uusi kyttj UserBeanin funktiolla createNewUser jolle
// annetaan parametrina pakolliset tiedot ( nick ja salasana )
// Paluuarvona saadaan uusi uljas kyttj-olio.
currentUser = userBean.createNewUser(nick, password);
if(currentUser == null)
{
return "fault";
}
// asetetaan muut kentt..
currentUser.setName(realname);
currentUser.setAddress(address);
currentUser.setNick(nick);
currentUser.setZip(zip);
currentUser.setEmail(email);
currentUser.setTown(town);
currentUser.setPhone(phone);
currentUser.setFemale(female);
currentUser.setPassword(password);
return "edit";
}
public void setNick(String nick) {
this.nick = nick;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public void setCurrentUser(User currentUser) {
this.currentUser = currentUser;
}
public User getCurrentUser() {
return currentUser;
}
public void setFemale(String sex) {
if(sex=="male") {
this.female = false;
}
else if(sex=="female") {
this.female = true;
}
}
public void setAddress(String address) {
this.address = address;
}
public void setZip(String zip) {
this.zip = zip;
}
public void setTown(String town) {
this.town = town;
}
public void setPhone(String phone) {
this.phone = phone;
}
public void setEmail(String email) {
this.email = email;
}
public ListDataModel<User> getUsers()
{
List<User> users = userBean.getUsers();
items = new ListDataModel<User>(users);
return items;
}
}