Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c81728d2
authored
Feb 27, 2010
by
tuomari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git-svn-id:
https://dev.intra.insomnia.fi/svn/trunk@28
8cf89bec-f6a3-4178-919f-364fb3449fe5
1 parent
d37a1b59
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
196 deletions
code/LanBortalWeb/WebContent/user/create.xhtml
code/LanBortalWeb/WebContent/user/edit.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/view/UserView.java
code/LanBortalWeb/WebContent/user/create.xhtml
View file @
c81728d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
<html
xmlns=
"http://www.w3.org/1999/xhtml"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:head>
<h:head>
<title></title>
<title></title>
</h:head>
</h:head>
...
@@ -15,16 +16,8 @@
...
@@ -15,16 +16,8 @@
<h:form>
<h:form>
<h:panelGrid
comlumns=
"2"
>
<h:panelGrid
comlumns=
"2"
>
<h:outputLabel
value=
"Nick:"
/><h:inputText
value=
"#{userView.nick}"
/>
<h:outputLabel
value=
"Nick:"
/><h:inputText
value=
"#{userView.nick}"
/>
<h:outputLabel
value=
"Real name"
/><h:inputText
value=
"#{userView.realname}"
/>
<h:outputLabel
value=
"Password:"
/><h:inputSecret
value=
"#{userView.password}"
/>
<h:outputLabel
value=
"Address"
/><h:inputText
value=
"#{userView.address}"
/>
<h:commandButton
action=
"#{userView.createUser()}"
value=
"Create"
/>
<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:panelGrid>
</h:form>
</h:form>
</ui:define>
</ui:define>
...
...
code/LanBortalWeb/WebContent/user/edit.xhtml
View file @
c81728d
...
@@ -2,46 +2,32 @@
...
@@ -2,46 +2,32 @@
<html
xmlns=
"http://www.w3.org/1999/xhtml"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
>
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:head>
<h:head>
<title></title>
<title></title>
</h:head>
</h:head>
<h:body>
<h:body>
<ui:composition
template=
"/layout/default-template.xhtml"
>
<ui:composition
template=
"/layout/default-template.xhtml"
>
<ui:define
name=
"title"
>
Edit
User
</ui:define>
<ui:define
name=
"title"
>
Create
User
</ui:define>
<ui:define
name=
"header"
>
Edit
user
</ui:define>
<ui:define
name=
"header"
>
Add new
user
</ui:define>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<h:form>
<h:form>
<h:dataTable
id=
"user"
value=
"#{userView.user}"
var=
"user"
>
<h:panelGrid
columns=
"2"
>
<h:column>
<h:outputLabel
value=
"Nick:"
/><h:outputLabel
value=
"#{userView.user.nick}"
/>
<f:facet
name=
"header"
>
<h:outputLabel
value=
"Real name"
/><h:inputText
value=
"#{userView.user.name}"
/>
<h:outputText
value=
"Nick"
/>
<h:outputLabel
value=
"Address"
/><h:inputText
value=
"#{userView.user.address}"
/>
</f:facet>
<h:outputLabel
value=
"Zip Code"
/><h:inputText
value=
"#{userView.user.zip}"
/>
<h:inputText
value=
"#{user.nick}"
/>
<h:outputLabel
value=
"Town"
/><h:inputText
value=
"#{userView.user.town}"
/>
</h:column>
<h:outputLabel
value=
"Sex"
/>
<h:column>
<h:selectOneRadio
id=
"sex"
value=
"#{userView.user.female}"
>
<f:facet
name=
"header"
>
<f:selectItem
id=
"male"
itemLabel=
"Male"
itemValue=
"false"
/>
<h:outputText
value=
"Real name"
/>
<f:selectItem
id=
"female"
itemLabel=
"Female"
itemValue=
"true"
/>
</f:facet>
</h:selectOneRadio>
<h:inputText
value=
"#{user.name}"
/>
<h:commandButton
action=
"#{userView.saveUser()}"
value=
"Save"
/>
</h:column>
</h:panelGrid>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"Address"
/>
</f:facet>
<h:inputText
value=
"#{user.address}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"Town"
/>
</f:facet>
<h:inputText
value=
"#{user.town}"
/>
</h:column>
</h:dataTable>
<h:commandButton
action=
"#{userView.saveEdited()}"
value=
"Save"
/>
</h:form>
</h:form>
</ui:define>
</ui:define>
<ui:define
name=
"footer"
>
footer
</ui:define>
<ui:define
name=
"footer"
>
footer
</ui:define>
</ui:composition>
</ui:composition>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/UserView.java
View file @
c81728d
package
fi
.
insomnia
.
bortal
.
view
;
package
fi
.
insomnia
.
bortal
.
view
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.SessionScoped
;
import
javax.faces.bean.SessionScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.faces.model.ListDataModel
;
import
javax.persistence.Column
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -22,193 +20,76 @@ public class UserView {
...
@@ -22,193 +20,76 @@ public class UserView {
@EJB
@EJB
private
UserBeanLocal
userBean
;
private
UserBeanLocal
userBean
;
//
private
static
final
Logger
logger
=
LoggerFactory
// private String name;
.
getLogger
(
UserView
.
class
);
// 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
name
=
"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
;
private
User
user
;
private
User
item
;
public
UserBeanLocal
getUserBean
()
{
return
userBean
;
}
public
void
setUserBean
(
UserBeanLocal
userBean
)
{
this
.
userBean
=
userBean
;
}
public
Boolean
getFemale
()
{
private
ListDataModel
<
User
>
items
;
return
female
;
}
public
void
setFemale
(
Boolean
female
)
{
this
.
female
=
female
;
}
public
ListDataModel
<
User
>
getItems
()
{
return
items
;
}
public
void
setItems
(
ListDataModel
<
User
>
items
)
{
this
.
items
=
items
;
}
public
String
getNick
()
{
return
nick
;
}
public
String
getEmail
()
{
return
email
;
}
public
String
getAddress
()
{
private
String
nick
;
return
address
;
}
public
String
getTown
()
{
private
String
password
;
return
town
;
}
public
String
getPhone
()
{
return
phone
;
}
public
String
getZip
()
{
public
String
edit
()
{
return
zip
;
setUser
(
items
.
getRowData
());
return
"edit"
;
}
}
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserView
.
class
);
public
String
createUser
()
{
public
String
saveUser
()
{
logger
.
info
(
"Saving user"
);
logger
.
info
(
"Saving user"
);
// Luodaan uusi kyttj UserBeanin funktiolla createNewUser jolle
// Luodaan uusi kyttj UserBeanin funktiolla createNewUser jolle
// annetaan parametrina pakolliset tiedot ( nick ja salasana )
// annetaan parametrina pakolliset tiedot ( nick ja salasana )
// Paluuarvona saadaan uusi uljas kyttj-olio.
// Paluuarvona saadaan uusi uljas kyttj-olio.
currentUser
=
userBean
.
createNewUser
(
nick
,
password
);
setUser
(
userBean
.
createNewUser
(
nick
,
password
));
if
(
currentUser
==
null
)
{
nick
=
""
;
password
=
""
;
if
(
getUser
()
==
null
)
{
logger
.
warn
(
"Could not create user. function returned null!"
);
logger
.
warn
(
"Could not create user. function returned null!"
);
return
"fault"
;
return
"fault"
;
}
}
// asetetaan muut kentt..
currentUser
.
setName
(
name
);
currentUser
.
setAddress
(
address
);
currentUser
.
setNick
(
nick
);
currentUser
.
setZip
(
zip
);
currentUser
.
setEmail
(
email
);
currentUser
.
setTown
(
town
);
currentUser
.
setPhone
(
phone
);
currentUser
.
setFemale
(
female
);
currentUser
.
setPassword
(
password
);
userBean
.
mergeChanges
(
currentUser
);
logger
.
info
(
"Saved current users town to {}"
,
town
);
return
"list"
;
}
public
String
saveEdited
()
{
this
.
item
.
setName
(
name
);
this
.
item
.
setAddress
(
address
);
this
.
item
.
setNick
(
nick
);
this
.
item
.
setZip
(
zip
);
this
.
item
.
setEmail
(
email
);
this
.
item
.
setTown
(
town
);
this
.
item
.
setPhone
(
phone
);
this
.
item
.
setFemale
(
female
);
this
.
item
.
setPassword
(
password
);
userBean
.
mergeChanges
(
this
.
item
);
return
"list"
;
}
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
"edit"
;
return
name
;
}
}
public
void
setRealname
(
String
realname
)
{
public
String
saveUser
()
{
this
.
name
=
realname
;
userBean
.
mergeChanges
(
getUser
());
return
"edit"
;
}
}
public
void
setCurrentUser
(
User
currentUser
)
{
public
ListDataModel
<
User
>
getUsers
()
{
this
.
currentUser
=
currentUser
;
List
<
User
>
users
=
userBean
.
getUsers
();
items
=
new
ListDataModel
<
User
>(
users
);
logger
.
info
(
"Fetching users. Found {}"
,
items
.
getRowCount
());
return
items
;
}
}
public
User
getCurrentUser
()
{
// Getters and setters...
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
)
{
public
String
getNick
(
)
{
this
.
zip
=
zip
;
return
nick
;
}
}
public
void
setTown
(
String
town
)
{
public
void
setNick
(
String
nick
)
{
this
.
town
=
town
;
this
.
nick
=
nick
;
}
}
public
void
setPhone
(
String
phone
)
{
public
String
getPassword
(
)
{
this
.
phone
=
phone
;
return
password
;
}
}
public
void
setEmail
(
String
email
)
{
public
void
setPassword
(
String
password
)
{
this
.
email
=
email
;
this
.
password
=
password
;
}
}
public
ListDataModel
<
User
>
getUsers
()
{
public
void
setUser
(
User
user
)
{
List
<
User
>
users
=
userBean
.
getUsers
();
this
.
user
=
user
;
items
=
new
ListDataModel
<
User
>(
users
);
logger
.
info
(
"Fetching users. Found {}"
,
items
.
getRowCount
());
return
items
;
}
}
public
User
getUser
()
{
public
User
getUser
()
{
return
this
.
item
;
return
user
;
}
public
void
setItem
(
User
user
)
{
this
.
item
=
user
;
}
public
String
edit
()
{
setItem
(
items
.
getRowData
());
return
"edit"
;
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment