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
JR Utily
2016-11-09 22:33:39 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4bc49c007bad59efffa8b72b6aa6f669de446733
4bc49c00
1 parent
3f8e0b60
fix error in validation (@PostConstruct / @ViewedScope problem )
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
179 deletions
src/main/java/org/legrog/presentation/ListPublisherRevisionsView.java
src/main/java/org/legrog/web/publisher/ListPublisherRevisionsBean.java
src/main/java/org/legrog/web/publisher/ListPublisherVersionsView.java
src/main/java/org/legrog/web/publisher/listPublisherVersions.xhtml
src/main/java/org/legrog/presentation/ListPublisherRevisionsView.java
deleted
100644 → 0
View file @
3f8e0b6
package
org
.
legrog
.
presentation
;
import
org.legrog.application.PublisherRevisionService
;
import
org.legrog.application.PublisherService
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherRevision
;
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
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
@Named
@RequestScoped
public
class
ListPublisherRevisionsView
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
PublisherRevisionService
publisherRevisionService
;
private
Integer
publisherId
;
private
boolean
viewAll
;
private
List
<
PublisherRevision
>
publisherRevisions
;
public
List
<
PublisherRevision
>
getPublisherRevisions
()
{
return
publisherRevisions
;
}
/*
if (!viewAll) {
logger.info("!viewAll");
ArrayList<PublisherRevision> filteredPublisherRevisions= new ArrayList<PublisherRevision>();
Iterator<PublisherRevision> publisherRevisionIterator = filteredPublisherRevisions.iterator();
while (publisherRevisionIterator.hasNext()) {
PublisherRevision publisherRevision = publisherRevisionIterator.next();
if (publisherRevision.getPublisher().getPublisherId() == publisherId.intValue()) {
filteredPublisherRevisions.add(publisherRevision);
}
}
publisherRevisions = filteredPublisherRevisions;
}
*/
@PostConstruct
public
void
init
()
{
publisherRevisions
=
publisherRevisionService
.
getAllPublisherRevisions
();
logger
.
info
(
"init"
);
}
public
void
setView
()
{
logger
.
info
(
"setView"
);
logger
.
info
(
"publisherId = "
+
publisherId
);
viewAll
=
false
;
if
(
publisherId
==
null
)
{
viewAll
=
true
;
}
}
public
Integer
getPublisherId
()
{
return
publisherId
;
}
public
void
setPublisherId
(
Integer
publisherId
)
{
this
.
publisherId
=
publisherId
;
}
public
boolean
isViewAll
()
{
return
viewAll
;
}
}
src/main/java/org/legrog/web/publisher/ListPublisherRevisionsBean.java
deleted
100644 → 0
View file @
3f8e0b6
package
org
.
legrog
.
web
.
publisher
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherRevision
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/*
Vue de listPublisherRevisions.xhtml
Permet de voir l'ensemble des versions des éditeurs.
Permet de voir l'ensemble des versions d'un éditeur et de valider l'une d'elles.
*/
@Named
@RequestScoped
public
class
ListPublisherRevisionsBean
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
PublisherService
publisherService
;
private
Integer
publisherId
;
private
boolean
viewAll
;
private
List
<
PublisherRevision
>
publisherRevisions
;
public
void
validate
()
{
logger
.
debug
(
"validate"
);
Publisher
publisher
=
publisherService
.
getPublisher
(
publisherId
);
logger
.
debug
(
"publisher (pre-validate) = {}"
,
publisher
);
Map
<
String
,
String
>
params
=
FacesContext
.
getCurrentInstance
().
getExternalContext
().
getRequestParameterMap
();
Integer
publisherRevisionId
=
new
Integer
(
params
.
get
(
"publisherRevisionId"
));
publisherService
.
validatePublisherRevision
(
publisher
,
publisherRevisionId
);
// TODO : comprendre pourquoi ceci est nécessaire
publisherRevisions
=
publisherService
.
getAllPublisherRevisions
();
publisherRevisions
=
filter
();
logger
.
debug
(
"publisher (post-validate) = {}"
,
publisher
);
}
@PostConstruct
public
void
init
()
{
publisherRevisions
=
publisherService
.
getAllPublisherRevisions
();
logger
.
debug
(
"init"
);
}
protected
List
<
PublisherRevision
>
filter
()
{
ArrayList
<
PublisherRevision
>
filteredPublisherRevisions
=
new
ArrayList
<
PublisherRevision
>();
for
(
PublisherRevision
publisherRevision
:
publisherRevisions
)
{
if
(
publisherRevision
.
getPublisher
().
getPublisherId
()
==
publisherId
)
{
filteredPublisherRevisions
.
add
(
publisherRevision
);
}
}
return
filteredPublisherRevisions
;
}
public
void
setView
()
{
logger
.
debug
(
"setView"
);
logger
.
debug
(
"publisherId = "
+
publisherId
);
viewAll
=
(
publisherId
==
null
)
;
if
(!
viewAll
)
{
logger
.
debug
(
"!viewAll"
);
publisherRevisions
=
filter
();
}
}
// get, set et is
public
List
<
PublisherRevision
>
getPublisherRevisions
()
{
return
publisherRevisions
;
}
public
Integer
getPublisherId
()
{
return
publisherId
;
}
public
void
setPublisherId
(
Integer
publisherId
)
{
this
.
publisherId
=
publisherId
;
}
public
boolean
isViewAll
()
{
return
viewAll
;
}
}
src/main/java/org/legrog/web/publisher/ListPublisherVersionsView.java
View file @
4bc49c0
...
...
@@ -5,12 +5,11 @@ import org.legrog.entities.PublisherVersion;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.view.ViewScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/*
...
...
@@ -19,8 +18,8 @@ import java.util.stream.Collectors;
Permet de voir l'ensemble des versions d'un éditeur et de valider l'une d'elles.
*/
@Named
@
Request
Scoped
public
class
ListPublisherVersionsView
{
@
View
Scoped
public
class
ListPublisherVersionsView
implements
Serializable
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
...
...
@@ -35,6 +34,7 @@ public class ListPublisherVersionsView {
this
.
publisherService
=
publisherService
;
}
// View Action being executed at view loading
public
void
setView
()
{
logger
.
trace
(
"setView"
);
...
...
@@ -54,12 +54,10 @@ public class ListPublisherVersionsView {
}
public
void
validate
()
{
public
void
validate
(
Integer
publisherVersionId
)
{
logger
.
trace
(
"validate"
);
Publisher
publisher
=
publisherService
.
getPublisher
(
publisherId
);
logger
.
debug
(
"publisher (pre-validate) = {}"
,
publisher
);
Map
<
String
,
String
>
params
=
FacesContext
.
getCurrentInstance
().
getExternalContext
().
getRequestParameterMap
();
Integer
publisherVersionId
=
new
Integer
(
params
.
get
(
"publisherVersionId"
));
publisherService
.
validatePublisherVersion
(
publisher
,
publisherVersionId
);
...
...
src/main/java/org/legrog/web/publisher/listPublisherVersions.xhtml
View file @
4bc49c0
...
...
@@ -39,9 +39,8 @@
<p
jsf:rendered=
"#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}"
>
Validé
</p>
<p
jsf:rendered=
"#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}"
>
Non validé
</p>
<!-- https://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ f:param, problème avec Method expression -->
<form
jsf:id=
"validateVersion"
action=
""
jsf:rendered=
"#{not listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}"
>
<button
jsf:action=
"#{listPublisherVersionsView.validate}"
>
Valider
<f:param
name=
"publisherVersionId"
value=
"#{version.publisherVersionId}"
/>
<form
action=
""
jsf:rendered=
"#{not listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}"
>
<button
jsf:action=
"#{listPublisherVersionsView.validate(version.publisherVersionId)}"
>
Valider
</button>
</form>
</h:column>
...
...
Please
register
or
login
to post a comment