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 15:44:11 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
30cfbb6ea3865e48cf93692125d0fb16022f3e84
30cfbb6e
1 parent
d6b1af5e
Ajout de pays
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
0 deletions
src/main/java/org/legrog/application/CountryService.java
src/main/java/org/legrog/application/CountryServiceSpring.java
src/main/java/org/legrog/entities/CountryRepository.java
src/main/java/org/legrog/presentation/CountryBean.java
src/main/webapp/WEB-INF/faces-config.xml
src/main/webapp/addCountry.xhtml
src/main/webapp/index.xhtml
src/main/webapp/listCountries.xhtml
src/main/java/org/legrog/application/CountryService.java
0 → 100644
View file @
30cfbb6
package
org
.
legrog
.
application
;
import
org.legrog.entities.Country
;
public
interface
CountryService
{
void
addCountry
(
Country
country
);
}
src/main/java/org/legrog/application/CountryServiceSpring.java
0 → 100644
View file @
30cfbb6
package
org
.
legrog
.
application
;
import
org.legrog.entities.Country
;
import
org.legrog.entities.CountryRepository
;
//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
{
@Inject
CountryRepository
repository
;
public
void
addCountry
(
Country
country
)
{
repository
.
save
(
country
);
}
}
src/main/java/org/legrog/entities/CountryRepository.java
0 → 100644
View file @
30cfbb6
package
org
.
legrog
.
entities
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
CountryRepository
extends
JpaRepository
<
Country
,
Integer
>
{
}
src/main/java/org/legrog/presentation/CountryBean.java
0 → 100644
View file @
30cfbb6
package
org
.
legrog
.
presentation
;
import
org.legrog.application.CountryService
;
import
org.legrog.entities.Country
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.util.List
;
@Named
@RequestScoped
public
class
CountryBean
{
@Inject
private
CountryService
service
;
private
String
countryName
;
public
String
getCountryName
()
{
return
countryName
;
}
public
void
setCountryName
(
String
countryName
)
{
this
.
countryName
=
countryName
;
}
public
String
add
()
{
Country
country
=
new
Country
();
country
.
setCountryName
(
countryName
);
service
.
addCountry
(
country
);
return
"success"
;
}
}
src/main/webapp/WEB-INF/faces-config.xml
View file @
30cfbb6
...
...
@@ -15,6 +15,22 @@
<from-outcome>
listBooks
</from-outcome>
<to-view-id>
/result.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
addCountry
</from-outcome>
<to-view-id>
/addCountry.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
listCountries
</from-outcome>
<to-view-id>
/listCountries.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>
/addCountry.xhtml
</from-view-id>
<navigation-case>
<from-outcome>
success
</from-outcome>
<to-view-id>
/listCountries.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
...
...
src/main/webapp/addCountry.xhtml
0 → 100644
View file @
30cfbb6
<?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:panelGrid
columns=
"2"
>
<h:outputText
value=
'Nom du pays'
/>
<h:inputText
value=
'#{countryBean.countryName}'
/>
<h:outputText
value=
'Add'
/>
<h:commandButton
action=
"#{bookBean.add}"
value=
"Add"
/>
</h:panelGrid>
</h:form>
</body>
</html>
src/main/webapp/index.xhtml
View file @
30cfbb6
...
...
@@ -18,6 +18,18 @@
<h:outputText
value=
"List books"
/>
</h:commandLink>
</li>
<li>
<h:commandLink
action=
"addCountry"
>
<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
0 → 100644
View file @
30cfbb6
<?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:outputLabel
value=
"Hello, world"
/>
</body>
</html>
Please
register
or
login
to post a comment