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-29 17:00:15 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
adff869213ff0427b25f1764a89837492a385a6b
adff8692
1 parent
30cfbb6e
Liste qui ne marche pas
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
3 deletions
src/main/java/org/legrog/application/CountryService.java
src/main/java/org/legrog/application/CountryServiceSpring.java
src/main/java/org/legrog/presentation/CountryBean.java
src/main/webapp/index.xhtml
src/main/webapp/listCountries.xhtml
src/main/java/org/legrog/application/CountryService.java
View file @
adff869
...
...
@@ -2,8 +2,11 @@ package org.legrog.application;
import
org.legrog.entities.Country
;
import
java.util.List
;
public
interface
CountryService
{
void
addCountry
(
Country
country
);
public
List
<
Country
>
getAllCountries
();
}
...
...
src/main/java/org/legrog/application/CountryServiceSpring.java
View file @
adff869
...
...
@@ -8,7 +8,7 @@ import org.legrog.entities.CountryRepository;
import
javax.ejb.Stateless
;
import
javax.enterprise.inject.Alternative
;
import
javax.inject.Inject
;
//
import java.util.List;
import
java.util.List
;
@Stateless
public
class
CountryServiceSpring
implements
CountryService
{
...
...
@@ -20,4 +20,7 @@ public class CountryServiceSpring implements CountryService {
repository
.
save
(
country
);
}
public
List
<
Country
>
getAllCountries
()
{
return
repository
.
findAll
();
}
}
...
...
src/main/java/org/legrog/presentation/CountryBean.java
View file @
adff869
...
...
@@ -14,7 +14,18 @@ public class CountryBean {
@Inject
private
CountryService
service
;
public
List
<
Country
>
getCountries
()
{
return
countries
;
}
public
void
setCountries
(
List
<
Country
>
countries
)
{
this
.
countries
=
countries
;
}
private
List
<
Country
>
countries
;
private
String
countryName
;
public
String
getCountryName
()
{
return
countryName
;
}
...
...
@@ -30,4 +41,8 @@ public class CountryBean {
service
.
addCountry
(
country
);
return
"success"
;
}
public
void
onload
()
{
countries
=
service
.
getAllCountries
();
}
}
...
...
src/main/webapp/index.xhtml
View file @
adff869
...
...
@@ -23,13 +23,11 @@
<h:outputText
value=
"Add country"
/>
</h:commandLink>
</li>
<!--
<li>
<h:commandLink
action=
"listCountries"
>
<h:outputText
value=
"List countries"
/>
</h:commandLink>
</li>
-->
</ul>
</h:form>
</body>
...
...
src/main/webapp/listCountries.xhtml
View file @
adff869
...
...
@@ -6,6 +6,15 @@
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>
</ui:repeat>
</ul>
<h:outputLabel
value=
"Hello, world"
/>
</body>
</html>
...
...
Please
register
or
login
to post a comment