Commit 476241d7 by nicku

Käyttäjänhallintaa aloiteltu

git-svn-id: https://dev.intra.insomnia.fi/svn/trunk@22 8cf89bec-f6a3-4178-919f-364fb3449fe5
1 parent 66b28c13
......@@ -9,17 +9,24 @@
<h:body>
<ui:composition template="/layout/default-template.xhtml">
<ui:define name="title">CreateUser</ui:define>
<ui:define name="header">Header</ui:define>
<ui:define name="header">Add new user</ui:define>
<ui:define name="content">
<h:form>
<h:inputText value="#{userView.name}" />
<h:commandButton action="helloPage" value="Save" />
</h:form>
<h:form>
<h:panelGrid comluns="2">
<h:outputLabel value="Nick:" /><h:inputText value="#{userView.nick}" />
<h:outputLabel value="Real name" /><h:inputText value="#{userView.Realname}" />
<h:outputLabel value="Address" /><h:inputText value="#{userView.address}" />
<h:outputLabel value="Zip Code" /><h:inputText value="#{userView.zip}" />
<h:outputLabel value="Town" /><h:inputText value="#{userView.town}" />
<h:outputLabel value="Sex" />
<h:selectOneRadio id="sex" value="#{userView.female}">
<f:selectItem id="male" itemLabel="Male" itemValue="male" />
<f:selectItem id="female" itemLabel="Female" itemValue="female" />
</h:selectOneRadio>
<h:commandButton action="#{userView.saveUser()}" value="Save" />
</h:panelGrid>
</h:form>
</ui:define>
<ui:define name="footer">footer</ui:define>
</ui:composition>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/default-template.xhtml">
<ui:define name="title">Fail</ui:define>
<ui:define name="header"></ui:define>
<ui:define name="content">
<h:outputText value="User creation failed" />
<h:commandButton value="Back" action="create"/>
</ui:define>
<ui:define name="footer">footer</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
package fi.insomnia.bortal.view;
import java.math.BigDecimal;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.persistence.Column;
import fi.insomnia.bortal.UserBeanLocal;
import fi.insomnia.bortal.db.User;
@ManagedBean
@ManagedBean(name="UserView")
@SessionScoped
public class UserView {
@EJB
private UserBeanLocal bean;
//
// 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";
public String saveUser()
{
......@@ -33,17 +53,23 @@ public class UserView {
// asetetaan muut kentŠt..
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;
......@@ -58,31 +84,43 @@ public class UserView {
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;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!