Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
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 @@
<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"
>
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:head>
<title></title>
</h:head>
...
...
@@ -15,16 +16,8 @@
<h:form>
<h:panelGrid
comlumns=
"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:outputLabel
value=
"Password:"
/><h:inputSecret
value=
"#{userView.password}"
/>
<h:commandButton
action=
"#{userView.createUser()}"
value=
"Create"
/>
</h:panelGrid>
</h:form>
</ui:define>
...
...
code/LanBortalWeb/WebContent/user/edit.xhtml
View file @
c81728d
...
...
@@ -2,46 +2,32 @@
<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"
>
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition
template=
"/layout/default-template.xhtml"
>
<ui:define
name=
"title"
>
Edit
User
</ui:define>
<ui:define
name=
"header"
>
Edit
user
</ui:define>
<ui:define
name=
"title"
>
Create
User
</ui:define>
<ui:define
name=
"header"
>
Add new
user
</ui:define>
<ui:define
name=
"content"
>
<h:form>
<h:dataTable
id=
"user"
value=
"#{userView.user}"
var=
"user"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"Nick"
/>
</f:facet>
<h:inputText
value=
"#{user.nick}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"Real name"
/>
</f:facet>
<h:inputText
value=
"#{user.name}"
/>
</h:column>
<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:panelGrid
columns=
"2"
>
<h:outputLabel
value=
"Nick:"
/><h:outputLabel
value=
"#{userView.user.nick}"
/>
<h:outputLabel
value=
"Real name"
/><h:inputText
value=
"#{userView.user.name}"
/>
<h:outputLabel
value=
"Address"
/><h:inputText
value=
"#{userView.user.address}"
/>
<h:outputLabel
value=
"Zip Code"
/><h:inputText
value=
"#{userView.user.zip}"
/>
<h:outputLabel
value=
"Town"
/><h:inputText
value=
"#{userView.user.town}"
/>
<h:outputLabel
value=
"Sex"
/>
<h:selectOneRadio
id=
"sex"
value=
"#{userView.user.female}"
>
<f:selectItem
id=
"male"
itemLabel=
"Male"
itemValue=
"false"
/>
<f:selectItem
id=
"female"
itemLabel=
"Female"
itemValue=
"true"
/>
</h:selectOneRadio>
<h:commandButton
action=
"#{userView.saveUser()}"
value=
"Save"
/>
</h:panelGrid>
</h:form>
</ui:define>
<ui:define
name=
"footer"
>
footer
</ui:define>
</ui:composition>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/UserView.java
View file @
c81728d
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
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -22,193 +20,76 @@ 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
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
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserView
.
class
);
private
ListDataModel
<
User
>
items
;
private
User
item
;
public
UserBeanLocal
getUserBean
()
{
return
userBean
;
}
public
void
setUserBean
(
UserBeanLocal
userBean
)
{
this
.
userBean
=
userBean
;
}
private
User
user
;
public
Boolean
getFemale
()
{
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
;
}
private
ListDataModel
<
User
>
items
;
public
String
getAddress
()
{
return
address
;
}
private
String
nick
;
public
String
getTown
()
{
return
town
;
}
public
String
getPhone
()
{
return
phone
;
}
private
String
password
;
public
String
getZip
()
{
return
zip
;
public
String
edit
()
{
setUser
(
items
.
getRowData
());
return
"edit"
;
}
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserView
.
class
);
public
String
saveUser
()
{
public
String
createUser
()
{
logger
.
info
(
"Saving user"
);
// 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
)
{
setUser
(
userBean
.
createNewUser
(
nick
,
password
));
nick
=
""
;
password
=
""
;
if
(
getUser
()
==
null
)
{
logger
.
warn
(
"Could not create user. function returned null!"
);
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
name
;
return
"edit"
;
}
public
void
setRealname
(
String
realname
)
{
this
.
name
=
realname
;
public
String
saveUser
()
{
userBean
.
mergeChanges
(
getUser
());
return
"edit"
;
}
public
void
setCurrentUser
(
User
currentUser
)
{
this
.
currentUser
=
currentUser
;
public
ListDataModel
<
User
>
getUsers
()
{
List
<
User
>
users
=
userBean
.
getUsers
();
items
=
new
ListDataModel
<
User
>(
users
);
logger
.
info
(
"Fetching users. Found {}"
,
items
.
getRowCount
());
return
items
;
}
public
User
getCurrentUser
()
{
return
currentUser
;
}
// Getters and setters...
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
String
getNick
(
)
{
return
nick
;
}
public
void
setTown
(
String
town
)
{
this
.
town
=
town
;
public
void
setNick
(
String
nick
)
{
this
.
nick
=
nick
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
public
String
getPassword
(
)
{
return
password
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
ListDataModel
<
User
>
getUsers
()
{
List
<
User
>
users
=
userBean
.
getUsers
();
items
=
new
ListDataModel
<
User
>(
users
);
logger
.
info
(
"Fetching users. Found {}"
,
items
.
getRowCount
());
return
items
;
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
User
getUser
()
{
return
this
.
item
;
}
public
void
setItem
(
User
user
)
{
this
.
item
=
user
;
}
public
String
edit
()
{
setItem
(
items
.
getRowData
());
return
"edit"
;
return
user
;
}
}
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