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
Jai le Leu
2016-09-30 12:04:49 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
491cbf2ccb9225382b540ce8967bc127c0543d25
491cbf2c
1 parent
adff8692
renommage et ajout logs
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
24 deletions
src/main/java/org/legrog/application/CountryService.java → src/main/java/org/legrog/application/ParameterService.java
src/main/java/org/legrog/application/CountryServiceSpring.java → src/main/java/org/legrog/application/ParameterServiceSpring.java
src/main/java/org/legrog/presentation/CountryBean.java
src/main/webapp/listCountries.xhtml
src/main/java/org/legrog/application/
Country
Service.java
→
src/main/java/org/legrog/application/
Parameter
Service.java
View file @
491cbf2
...
...
@@ -4,7 +4,7 @@ import org.legrog.entities.Country;
import
java.util.List
;
public
interface
Country
Service
{
public
interface
Parameter
Service
{
void
addCountry
(
Country
country
);
...
...
src/main/java/org/legrog/application/
Country
ServiceSpring.java
→
src/main/java/org/legrog/application/
Parameter
ServiceSpring.java
View file @
491cbf2
...
...
@@ -2,22 +2,27 @@ package org.legrog.application;
import
org.legrog.entities.Country
;
import
org.legrog.entities.CountryRepository
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import
javax.ejb.Stateless
;
import
javax.enterprise.inject.Alternative
;
import
javax.inject.Inject
;
import
java.util.List
;
@Stateless
public
class
CountryServiceSpring
implements
CountryService
{
public
class
ParameterServiceSpring
implements
ParameterService
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
CountryRepository
repository
;
public
void
addCountry
(
Country
country
)
{
repository
.
save
(
country
);
logger
.
debug
(
"country added"
);
}
public
List
<
Country
>
getAllCountries
()
{
...
...
src/main/java/org/legrog/presentation/CountryBean.java
View file @
491cbf2
package
org
.
legrog
.
presentation
;
import
org.legrog.application.
Country
Service
;
import
org.legrog.application.
Parameter
Service
;
import
org.legrog.entities.Country
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
...
...
@@ -11,8 +14,40 @@ import java.util.List;
@Named
@RequestScoped
public
class
CountryBean
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
private
CountryService
service
;
private
ParameterService
parameterService
;
private
List
<
Country
>
countries
;
private
String
countryName
;
public
String
add
()
{
Country
country
=
new
Country
();
country
.
setCountryName
(
countryName
);
parameterService
.
addCountry
(
country
);
logger
.
debug
(
"add done"
);
return
"success"
;
}
@PostConstruct
public
void
init
()
{
countries
=
parameterService
.
getAllCountries
();
logger
.
debug
(
"init done"
);
}
public
ParameterService
getParameterService
()
{
return
parameterService
;
}
public
void
setParameterService
(
ParameterService
parameterService
)
{
this
.
parameterService
=
parameterService
;
}
public
List
<
Country
>
getCountries
()
{
return
countries
;
...
...
@@ -22,10 +57,6 @@ public class CountryBean {
this
.
countries
=
countries
;
}
private
List
<
Country
>
countries
;
private
String
countryName
;
public
String
getCountryName
()
{
return
countryName
;
}
...
...
@@ -33,16 +64,4 @@ public class CountryBean {
public
void
setCountryName
(
String
countryName
)
{
this
.
countryName
=
countryName
;
}
public
String
add
()
{
Country
country
=
new
Country
();
country
.
setCountryName
(
countryName
);
service
.
addCountry
(
country
);
return
"success"
;
}
public
void
onload
()
{
countries
=
service
.
getAllCountries
();
}
}
...
...
src/main/webapp/listCountries.xhtml
View file @
491cbf2
...
...
@@ -6,9 +6,7 @@
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<body>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{countryBean.onload}"
/>
</f:metadata>
<ul>
<ui:repeat
value=
"#{countryBean.countries}"
var=
"country"
>
<li>
#{country.countryName}
</li>
...
...
Please
register
or
login
to post a comment