Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 b51d346f
authored
Mar 26, 2011
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
/user/list.jsf changed to cdi.
1 parent
452fe870
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
43 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/UserBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/GenericFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/UserFacade.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/UserBeanLocal.java
code/LanBortalWeb/WebContent/resources/tools/user/list.xhtml
code/LanBortalWeb/WebContent/user/list.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_en.properties
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/UserBean.java
View file @
b51d346
...
@@ -367,7 +367,12 @@ public class UserBean implements UserBeanLocal {
...
@@ -367,7 +367,12 @@ public class UserBean implements UserBeanLocal {
}
}
@Override
@Override
public
List
<
User
>
getUsers
(
int
page
,
int
pagesize
,
String
sort
)
{
public
List
<
User
>
getUsers
(
int
page
,
int
pagesize
,
String
sort
,
String
search
)
{
return
userFacade
.
findAll
(
page
,
pagesize
,
sort
);
return
userFacade
.
searchUser
(
page
,
pagesize
,
sort
,
search
);
}
@Override
public
long
getUsersCount
(
String
search
)
{
return
userFacade
.
searchUserCount
(
search
);
}
}
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/GenericFacade.java
View file @
b51d346
...
@@ -63,7 +63,7 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
...
@@ -63,7 +63,7 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
}
}
public
List
<
T
>
findAll
(
String
sort
)
{
public
List
<
T
>
findAll
(
String
sort
)
{
return
findAll
(
0
,
0
,
sort
);
return
search
(
0
,
0
,
null
,
null
,
sort
);
}
}
public
List
<
T
>
findRange
(
int
[]
range
)
{
public
List
<
T
>
findRange
(
int
[]
range
)
{
...
@@ -110,7 +110,9 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
...
@@ -110,7 +110,9 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
Root
<
T
>
root
=
cq
.
from
(
getEntityClass
());
Root
<
T
>
root
=
cq
.
from
(
getEntityClass
());
addPredicates
(
cb
,
cq
,
root
,
query
,
fields
);
if
(
query
!=
null
&&
!
query
.
isEmpty
())
{
addPredicates
(
cb
,
cq
,
root
,
query
,
fields
);
}
if
(
orderfield
!=
null
)
{
if
(
orderfield
!=
null
)
{
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
orderfield
)));
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
orderfield
)));
...
@@ -131,8 +133,9 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
...
@@ -131,8 +133,9 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
T
>
root
=
cq
.
from
(
getEntityClass
());
Root
<
T
>
root
=
cq
.
from
(
getEntityClass
());
if
(
query
!=
null
&&
!
query
.
isEmpty
())
{
addPredicates
(
cb
,
cq
,
root
,
query
,
fields
);
addPredicates
(
cb
,
cq
,
root
,
query
,
fields
);
}
cq
.
select
(
getEm
().
getCriteriaBuilder
().
count
(
root
));
cq
.
select
(
getEm
().
getCriteriaBuilder
().
count
(
root
));
TypedQuery
<
Long
>
q
=
getEm
().
createQuery
(
cq
);
TypedQuery
<
Long
>
q
=
getEm
().
createQuery
(
cq
);
...
@@ -149,24 +152,4 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
...
@@ -149,24 +152,4 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
}
}
public
List
<
T
>
findAll
(
int
page
,
int
pagesize
,
String
sort
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
T
>
cq
=
cb
.
createQuery
(
getEntityClass
());
Root
<
T
>
root
=
cq
.
from
(
getEntityClass
());
if
(
sort
!=
null
)
{
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
sort
)));
}
cq
.
select
(
cq
.
from
(
getEntityClass
()));
TypedQuery
<
T
>
q
=
getEm
().
createQuery
(
cq
);
if
(
pagesize
>
0
)
{
q
.
setFirstResult
(
page
*
pagesize
);
q
.
setMaxResults
(
pagesize
);
}
return
q
.
getResultList
();
}
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/UserFacade.java
View file @
b51d346
...
@@ -6,13 +6,11 @@ import javax.ejb.LocalBean;
...
@@ -6,13 +6,11 @@ import javax.ejb.LocalBean;
import
javax.ejb.Stateless
;
import
javax.ejb.Stateless
;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.Query
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.TypedQuery
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.model.LanEvent
;
import
fi.insomnia.bortal.model.User
;
import
fi.insomnia.bortal.model.User
;
@Stateless
@Stateless
...
@@ -32,6 +30,7 @@ public class UserFacade extends GenericFacade<Integer, User> {
...
@@ -32,6 +30,7 @@ public class UserFacade extends GenericFacade<Integer, User> {
super
(
User
.
class
);
super
(
User
.
class
);
}
}
@Override
protected
EntityManager
getEm
()
{
protected
EntityManager
getEm
()
{
return
em
;
return
em
;
}
}
...
@@ -49,7 +48,7 @@ public class UserFacade extends GenericFacade<Integer, User> {
...
@@ -49,7 +48,7 @@ public class UserFacade extends GenericFacade<Integer, User> {
return
getSingleNullableResult
(
q
);
return
getSingleNullableResult
(
q
);
}
}
private
static
final
String
[]
NAMEFIELDS
=
{
"nick"
,
"login"
,
"firstnames"
,
"lastname"
};
private
static
final
String
[]
NAMEFIELDS
=
{
"nick"
,
"login"
,
"firstnames"
,
"lastname"
,
"email"
};
public
List
<
User
>
searchForName
(
String
name
)
{
public
List
<
User
>
searchForName
(
String
name
)
{
return
this
.
search
(
name
,
NAMEFIELDS
,
"login"
);
return
this
.
search
(
name
,
NAMEFIELDS
,
"login"
);
...
@@ -66,4 +65,24 @@ public class UserFacade extends GenericFacade<Integer, User> {
...
@@ -66,4 +65,24 @@ public class UserFacade extends GenericFacade<Integer, User> {
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
return
super
.
merge
(
user
);
return
super
.
merge
(
user
);
}
}
public
List
<
User
>
searchUser
(
int
page
,
int
pagesize
,
String
sort
,
String
search
)
{
String
query
=
null
;
if
(
sort
==
null
||
sort
.
isEmpty
())
{
sort
=
"nick"
;
}
if
(
search
!=
null
)
{
query
=
new
StringBuilder
(
'%'
).
append
(
search
).
append
(
'%'
).
toString
();
}
return
this
.
search
(
page
,
pagesize
,
query
,
NAMEFIELDS
,
sort
);
}
public
long
searchUserCount
(
String
search
)
{
String
query
=
null
;
if
(
search
!=
null
)
{
query
=
new
StringBuilder
(
'%'
).
append
(
search
).
append
(
'%'
).
toString
();
}
return
this
.
searchCount
(
query
,
NAMEFIELDS
);
}
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/UserBeanLocal.java
View file @
b51d346
...
@@ -15,7 +15,7 @@ public interface UserBeanLocal {
...
@@ -15,7 +15,7 @@ public interface UserBeanLocal {
List
<
User
>
getUsers
();
List
<
User
>
getUsers
();
List
<
User
>
getUsers
(
int
page
,
int
pagesize
,
String
sort
);
List
<
User
>
getUsers
(
int
page
,
int
pagesize
,
String
sort
,
String
search
);
User
getUser
(
String
nick
);
User
getUser
(
String
nick
);
...
@@ -56,4 +56,6 @@ public interface UserBeanLocal {
...
@@ -56,4 +56,6 @@ public interface UserBeanLocal {
User
findById
(
Integer
integer
);
User
findById
(
Integer
integer
);
long
getUsersCount
(
String
search
);
}
}
code/LanBortalWeb/WebContent/resources/tools/user/list.xhtml
View file @
b51d346
...
@@ -3,14 +3,14 @@
...
@@ -3,14 +3,14 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
<composite:interface>
</composite:interface>
</composite:interface>
<composite:implementation>
<composite:implementation>
<tools:fatalPermission
target=
"USER_MANAGEMENT"
permission=
"READ"
/>
<h:form
id=
"userlistform"
>
<h:form
id=
"userlistform"
>
<h:dataTable
border=
"1"
id=
"user"
value=
"#{userView.users}"
var=
"user"
>
<h:dataTable
border=
"1"
id=
"user"
value=
"#{user
Search
View.users}"
var=
"user"
>
<h:column>
<h:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"Id"
/>
<h:outputText
value=
"Id"
/>
...
@@ -60,7 +60,8 @@
...
@@ -60,7 +60,8 @@
<h:outputText
value=
"#{i18n['user.image']}"
/>
<h:outputText
value=
"#{i18n['user.image']}"
/>
</f:facet>
</f:facet>
<h:commandLink
action=
"#{userView.showImage()}"
<h:commandLink
action=
"#{userView.showImage()}"
value=
"#{(empty user.currentImage)?i18n['user.noImage']:i18n['user.hasImage']}"
/>
value=
"#{(empty user.currentImage)?i18n['user.noImage']:i18n['user.hasImage']}"
/>
</h:column>
</h:column>
<h:column>
<h:column>
<h:commandButton
action=
"#{userView.edit()}"
value=
"#{i18n['user.edit']}"
/>
<h:commandButton
action=
"#{userView.edit()}"
value=
"#{i18n['user.edit']}"
/>
...
...
code/LanBortalWeb/WebContent/user/list.xhtml
View file @
b51d346
<!DOCTYPE html
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:h=
"http://java.sun.com/jsf/html"
>
xmlns:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<h:body>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:viewParam
name=
"page"
value=
"#{userSearchView.page}"
/>
<f:viewParam
name=
"pagesize"
value=
"#{userSearchView.pagesize}"
/>
<f:viewParam
name=
"sort"
value=
"#{userSearchView.sort}"
/>
<f:viewParam
name=
"search"
value=
"#{userSearchView.search}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userSearchView.initView}"
/>
</f:metadata>
<ui:param
name=
"thispage"
value=
"page.user.create"
/>
<ui:param
name=
"thispage"
value=
"page.user.create"
/>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<!-- <users:list /> -->
<h1>
#{i18n['userlist.header']}
</h1>
<h:form>
<h:inputText
value=
"#{userSearchView.search}"
/>
<h:commandButton
value=
"search"
/>
</h:form>
<users:list
/>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_en.properties
View file @
b51d346
...
@@ -330,6 +330,8 @@ user.validate.notUniqueUsername=Username already exists. Please select another.
...
@@ -330,6 +330,8 @@ user.validate.notUniqueUsername=Username already exists. Please select another.
user.wholeName
=
Name
user.wholeName
=
Name
user.zipCode
=
Postal nr.
user.zipCode
=
Postal nr.
userimage.webcam
=
Take picture with webcam
userimage.webcam
=
Take picture with webcam
userview.header
=
Users
userview.loginstringFaulty
=
Username has to be atleast 2 characters long!
userview.loginstringFaulty
=
Username has to be atleast 2 characters long!
userview.passwordTooShort
=
Password has to be atleast 5 characters long!
userview.passwordTooShort
=
Password has to be atleast 5 characters long!
userview.passwordsChanged
=
Password changed
userview.passwordsChanged
=
Password changed
...
...
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