Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2016-09-30 17:39:42 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8e0c63f38552787cc0a9fe5a661aea331c33e314
8e0c63f3
1 parent
15dc84d6
Ajout d'une entité et archi liée ainsi que de navigation.
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
181 additions
and
7 deletions
src/main/java/org/legrog/application/CountryService.java
src/main/java/org/legrog/application/UserService.java
src/main/java/org/legrog/application/UserServiceSpring.java
src/main/java/org/legrog/entities/UserRepository.java
src/main/java/org/legrog/presentation/CountryBean.java
src/main/java/org/legrog/presentation/UserBean.java
src/main/webapp/WEB-INF/faces-config.xml
src/main/webapp/addCountry.xhtml
src/main/webapp/addUser.xhtml
src/main/webapp/index.xhtml
src/main/webapp/listCountries.xhtml
src/main/webapp/listUsers.xhtml
src/main/java/org/legrog/application/CountryService.java
View file @
8e0c63f
...
...
@@ -8,5 +8,5 @@ public interface CountryService {
void
addCountry
(
Country
country
);
public
List
<
Country
>
getAllCountries
();
List
<
Country
>
getAllCountries
();
}
...
...
src/main/java/org/legrog/application/UserService.java
0 → 100644
View file @
8e0c63f
package
org
.
legrog
.
application
;
import
org.legrog.entities.User
;
import
java.util.List
;
public
interface
UserService
{
void
addUser
(
User
user
);
List
<
User
>
getAllUsers
();
}
src/main/java/org/legrog/application/UserServiceSpring.java
0 → 100644
View file @
8e0c63f
package
org
.
legrog
.
application
;
import
org.legrog.entities.User
;
import
org.legrog.entities.UserRepository
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
java.util.List
;
@Stateless
public
class
UserServiceSpring
implements
UserService
{
@Inject
UserRepository
repository
;
public
void
addUser
(
User
user
)
{
repository
.
save
(
user
);
}
public
List
<
User
>
getAllUsers
()
{
return
repository
.
findAll
();
}
}
src/main/java/org/legrog/entities/UserRepository.java
0 → 100644
View file @
8e0c63f
package
org
.
legrog
.
entities
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
UserRepository
extends
JpaRepository
<
User
,
Integer
>
{
}
src/main/java/org/legrog/presentation/CountryBean.java
View file @
8e0c63f
...
...
@@ -14,6 +14,10 @@ public class CountryBean {
@Inject
private
CountryService
service
;
private
List
<
Country
>
countries
;
private
String
countryName
;
public
List
<
Country
>
getCountries
()
{
return
countries
;
}
...
...
@@ -22,10 +26,6 @@ public class CountryBean {
this
.
countries
=
countries
;
}
private
List
<
Country
>
countries
;
private
String
countryName
;
public
String
getCountryName
()
{
return
countryName
;
}
...
...
src/main/java/org/legrog/presentation/UserBean.java
0 → 100644
View file @
8e0c63f
package
org
.
legrog
.
presentation
;
import
org.legrog.application.UserService
;
import
org.legrog.entities.User
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.util.List
;
@Named
@RequestScoped
public
class
UserBean
{
@Inject
private
UserService
service
;
private
String
username
;
private
List
<
User
>
users
;
public
List
<
User
>
getUsers
()
{
return
users
;
}
public
void
setUsers
(
List
<
User
>
users
)
{
this
.
users
=
users
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
add
()
{
User
user
=
new
User
();
user
.
setUsername
(
username
);
service
.
addUser
(
user
);
return
"success"
;
}
public
void
onload
()
{
users
=
service
.
getAllUsers
();
}
}
src/main/webapp/WEB-INF/faces-config.xml
View file @
8e0c63f
...
...
@@ -6,6 +6,14 @@
version=
"2.0"
>
<navigation-rule>
<from-view-id>
*
</from-view-id>
<navigation-case>
<from-outcome>
home
</from-outcome>
<to-view-id>
/index.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>
/index.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
addBook
</from-outcome>
...
...
@@ -23,6 +31,14 @@
<from-outcome>
listCountries
</from-outcome>
<to-view-id>
/listCountries.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
addUser
</from-outcome>
<to-view-id>
/addUser.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
listUsers
</from-outcome>
<to-view-id>
/listUsers.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
...
...
@@ -34,6 +50,14 @@
</navigation-rule>
<navigation-rule>
<from-view-id>
/addUser.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
success
</from-outcome>
<to-view-id>
/listUsers.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>
/book.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
success
</from-outcome>
...
...
src/main/webapp/addCountry.xhtml
View file @
8e0c63f
...
...
@@ -7,6 +7,10 @@
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<body>
<h:form>
<h:commandLink
action=
"home"
>
<h:outputText
value=
"Menu principal"
/>
</h:commandLink>
<h:panelGrid
columns=
"2"
>
<h:outputText
value=
'Nom du pays'
/>
<h:inputText
value=
'#{countryBean.countryName}'
/>
...
...
src/main/webapp/addUser.xhtml
0 → 100644
View file @
8e0c63f
<?xml version="1.0" encoding="UTF-8"?>
<!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:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<body>
<h:form>
<h:commandLink
action=
"home"
>
<h:outputText
value=
"Menu principal"
/>
</h:commandLink>
<h:panelGrid
columns=
"2"
>
<h:outputText
value=
"Username de l'utilisateur"
/>
<h:inputText
value=
'#{userBean.username}'
/>
<h:outputText
value=
'Add'
/>
<h:commandButton
action=
"#{userBean.add}"
value=
"Add"
/>
</h:panelGrid>
</h:form>
</body>
</html>
src/main/webapp/index.xhtml
View file @
8e0c63f
...
...
@@ -28,6 +28,16 @@
<h:outputText
value=
"List countries"
/>
</h:commandLink>
</li>
<li>
<h:commandLink
action=
"addUser"
>
<h:outputText
value=
"Add user"
/>
</h:commandLink>
</li>
<li>
<h:commandLink
action=
"listUsers"
>
<h:outputText
value=
"List users"
/>
</h:commandLink>
</li>
</ul>
</h:form>
</body>
...
...
src/main/webapp/listCountries.xhtml
View file @
8e0c63f
...
...
@@ -6,6 +6,11 @@
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<body>
<h:form>
<h:commandLink
action=
"home"
>
<h:outputText
value=
"Menu principal"
/>
</h:commandLink>
</h:form>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{countryBean.onload}"
/>
</f:metadata>
...
...
@@ -14,7 +19,5 @@
<li>
#{country.countryName}
</li>
</ui:repeat>
</ul>
<h:outputLabel
value=
"Hello, world"
/>
</body>
</html>
...
...
src/main/webapp/listUsers.xhtml
0 → 100644
View file @
8e0c63f
<?xml version="1.0" encoding="UTF-8"?>
<!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:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<f:view>
<h:form>
<h:commandLink
action=
"home"
>
<h:outputText
value=
"Menu principal"
/>
</h:commandLink>
</h:form>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{userBean.onload}"
/>
</f:metadata>
<ul>
<ui:repeat
value=
"#{userBean.users}"
var=
"user"
>
<li>
#{user.username}
</li>
</ui:repeat>
</ul>
</f:view>
</html>
Please
register
or
login
to post a comment