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
2017-01-25 17:50:09 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0a2c0b4f8297f9410ee37520eea6d8e871a54b0d
0a2c0b4f
1 parent
5ad5b9dd
Suppression de l'ancien exemple d'implémentation.
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
187 deletions
src/main/java/org/legrog/web/book/BookBean.java
src/main/java/org/legrog/web/book/BookService.java
src/main/java/org/legrog/web/book/BookServiceOld.java
src/main/java/org/legrog/web/book/BookServiceSpring.java
src/main/java/org/legrog/web/book/book.xhtml
src/main/java/org/legrog/web/book/result.xhtml
src/main/java/org/legrog/web/book/BookBean.java
deleted
100644 → 0
View file @
5ad5b9d
package
org
.
legrog
.
web
.
book
;
import
org.legrog.entities.Book
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.util.List
;
@Named
@RequestScoped
public
class
BookBean
{
@Inject
private
BookService
bookServiceSpring
;
private
List
<
Book
>
booksAvailable
;
private
String
bookTitle
;
public
String
getBookTitle
()
{
return
bookTitle
;
}
public
void
setBookTitle
(
String
bookTitle
)
{
this
.
bookTitle
=
bookTitle
;
}
public
List
<
Book
>
getBooksAvailable
()
{
return
booksAvailable
;
}
public
void
setBooksAvailable
(
List
<
Book
>
booksAvailable
)
{
this
.
booksAvailable
=
booksAvailable
;
}
public
String
fetchBooks
()
{
booksAvailable
=
bookServiceSpring
.
getAllBooks
();
return
"success"
;
}
public
String
add
()
{
Book
book
=
new
Book
();
book
.
setBookTitle
(
bookTitle
);
bookServiceSpring
.
addBook
(
book
);
return
"success"
;
}
}
src/main/java/org/legrog/web/book/BookService.java
deleted
100644 → 0
View file @
5ad5b9d
package
org
.
legrog
.
web
.
book
;
import
org.legrog.entities.Book
;
import
java.util.List
;
/**
* Created by jai on 27/08/16.
*/
public
interface
BookService
{
void
addBook
(
Book
book
);
List
<
Book
>
getAllBooks
();
}
src/main/java/org/legrog/web/book/BookServiceOld.java
deleted
100644 → 0
View file @
5ad5b9d
package
org
.
legrog
.
web
.
book
;
import
org.legrog.entities.Book
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.Stateless
;
import
javax.enterprise.inject.Alternative
;
import
javax.inject.Inject
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaQuery
;
import
java.util.List
;
@Stateless
@Alternative
public
class
BookServiceOld
implements
BookService
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
private
EntityManager
entityManager
;
public
void
addBook
(
Book
book
)
{
logger
.
debug
(
"old one"
);
entityManager
.
persist
(
book
);
}
public
List
<
Book
>
getAllBooks
()
{
CriteriaQuery
<
Book
>
cq
=
entityManager
.
getCriteriaBuilder
().
createQuery
(
Book
.
class
);
cq
.
select
(
cq
.
from
(
Book
.
class
));
return
entityManager
.
createQuery
(
cq
).
getResultList
();
}
public
BookServiceOld
()
{
}
// package only constructor dedicated to injection
BookServiceOld
(
EntityManager
entityManager
)
{
this
.
entityManager
=
entityManager
;
}
}
src/main/java/org/legrog/web/book/BookServiceSpring.java
deleted
100644 → 0
View file @
5ad5b9d
package
org
.
legrog
.
web
.
book
;
import
org.legrog.entities.Book
;
import
org.legrog.entities.BookRepository
;
import
org.legrog.web.book.BookService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
java.util.List
;
@Stateless
public
class
BookServiceSpring
implements
BookService
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
BookRepository
bookRepository
;
public
void
addBook
(
Book
book
)
{
logger
.
debug
(
"spring one"
);
bookRepository
.
save
(
book
);
}
public
List
<
Book
>
getAllBooks
()
{
return
bookRepository
.
findAll
();
}
}
src/main/java/org/legrog/web/book/book.xhtml
deleted
100644 → 0
View file @
5ad5b9d
<?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:f=
"http://java.sun.com/jsf/core"
xmlns:h=
"http://java.sun.com/jsf/html"
>
<h:body
bgcolor=
"white"
>
<f:view>
<h:form>
<h:panelGrid
columns=
"2"
>
<h:outputText
value=
'Enter book title'
/>
<h:inputText
value=
'#{bookBean.bookTitle}'
/>
<h:outputText
value=
'Add'
/>
<h:commandButton
action=
"#{bookBean.add}"
value=
"Add"
/>
</h:panelGrid>
</h:form>
</f:view>
</h:body>
</html>
src/main/java/org/legrog/web/book/result.xhtml
deleted
100644 → 0
View file @
5ad5b9d
<?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:f=
"http://xmlns.jcp.org/jsf/core"
xmlns:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
>
<h:body>
<f:view>
<h:form
id=
"mainForm"
>
<h2>
Book Added !
</h2>
<h:commandLink
action=
"back"
>
<h:outputText
value=
"Add more books"
/>
</h:commandLink>
<h:commandButton
action=
"#{bookBean.fetchBooks}"
value=
"View books present"
/>
<br/>
<ui:repeat
value=
"#{bookBean.booksAvailable}"
var=
"book"
>
#{book.bookTitle}
<br/>
</ui:repeat>
</h:form>
</f:view>
</h:body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment