Jean-Francois Leveque
...@@ -4,28 +4,72 @@ import org.legrog.application.PublisherRevisionService; ...@@ -4,28 +4,72 @@ import org.legrog.application.PublisherRevisionService;
4 import org.legrog.application.PublisherService; 4 import org.legrog.application.PublisherService;
5 import org.legrog.entities.Publisher; 5 import org.legrog.entities.Publisher;
6 import org.legrog.entities.PublisherRevision; 6 import org.legrog.entities.PublisherRevision;
7 +import org.slf4j.Logger;
8 +import org.slf4j.LoggerFactory;
7 9
8 import javax.annotation.PostConstruct; 10 import javax.annotation.PostConstruct;
9 import javax.enterprise.context.RequestScoped; 11 import javax.enterprise.context.RequestScoped;
10 import javax.inject.Inject; 12 import javax.inject.Inject;
11 import javax.inject.Named; 13 import javax.inject.Named;
14 +import java.util.ArrayList;
15 +import java.util.Iterator;
12 import java.util.List; 16 import java.util.List;
13 17
14 @Named 18 @Named
15 @RequestScoped 19 @RequestScoped
16 public class ListPublisherRevisionsBean { 20 public class ListPublisherRevisionsBean {
21 + Logger logger = LoggerFactory.getLogger(getClass());
22 +
17 @Inject 23 @Inject
18 PublisherRevisionService publisherRevisionService; 24 PublisherRevisionService publisherRevisionService;
19 25
26 + private Integer publisherId;
27 +
28 + private boolean viewAll;
29 +
20 private List<PublisherRevision> publisherRevisions; 30 private List<PublisherRevision> publisherRevisions;
21 31
22 public List<PublisherRevision> getPublisherRevisions() { 32 public List<PublisherRevision> getPublisherRevisions() {
23 return publisherRevisions; 33 return publisherRevisions;
24 } 34 }
25 - 35 +/*
36 + if (!viewAll) {
37 + logger.info("!viewAll");
38 + ArrayList<PublisherRevision> filteredPublisherRevisions= new ArrayList<PublisherRevision>();
39 + Iterator<PublisherRevision> publisherRevisionIterator = filteredPublisherRevisions.iterator();
40 + while (publisherRevisionIterator.hasNext()) {
41 + PublisherRevision publisherRevision = publisherRevisionIterator.next();
42 + if (publisherRevision.getPublisher().getPublisherId() == publisherId.intValue()) {
43 + filteredPublisherRevisions.add(publisherRevision);
44 + }
45 + }
46 + publisherRevisions = filteredPublisherRevisions;
47 + }
48 +*/
26 @PostConstruct 49 @PostConstruct
27 public void init() { 50 public void init() {
28 publisherRevisions = publisherRevisionService.getAllPublisherRevisions(); 51 publisherRevisions = publisherRevisionService.getAllPublisherRevisions();
52 + logger.info("init");
53 + }
54 +
55 + public void setView() {
56 + logger.info("setView");
57 + logger.info("publisherId = " + publisherId);
58 + viewAll = false;
59 + if (publisherId == null) {
60 + viewAll = true;
61 + }
62 + }
63 +
64 + public Integer getPublisherId() {
65 + return publisherId;
29 } 66 }
30 67
68 + public void setPublisherId(Integer publisherId) {
69 + this.publisherId = publisherId;
70 + }
71 +
72 + public boolean isViewAll() {
73 + return viewAll;
74 + }
31 } 75 }
......
...@@ -39,10 +39,6 @@ ...@@ -39,10 +39,6 @@
39 <from-outcome>listUsers</from-outcome> 39 <from-outcome>listUsers</from-outcome>
40 <to-view-id>/listUsers.xhtml</to-view-id> 40 <to-view-id>/listUsers.xhtml</to-view-id>
41 </navigation-case> 41 </navigation-case>
42 - <navigation-case>
43 - <from-outcome>addPublisher</from-outcome>
44 - <to-view-id>/addPublisher.xhtml</to-view-id>
45 - </navigation-case>
46 </navigation-rule> 42 </navigation-rule>
47 <navigation-rule> 43 <navigation-rule>
48 <from-view-id>/addPublisher.xhtml</from-view-id> 44 <from-view-id>/addPublisher.xhtml</from-view-id>
......
...@@ -39,14 +39,14 @@ ...@@ -39,14 +39,14 @@
39 </h:commandLink> 39 </h:commandLink>
40 </li> 40 </li>
41 <li> 41 <li>
42 - <h:commandLink action="addPublisher"> 42 + <h:link outcome="/addPublisher.xhtml">
43 - <h:outputText value="Add Publisher"/> 43 + <h:outputText value="Add a Publisher"/>
44 - </h:commandLink> 44 + </h:link>
45 </li> 45 </li>
46 <li> 46 <li>
47 - <h:commandLink action="listPublisherRevisions"> 47 + <h:link outcome="/listPublisherRevisions.xhtml">
48 <h:outputText value="List Publisher Revisions"/> 48 <h:outputText value="List Publisher Revisions"/>
49 - </h:commandLink> 49 + </h:link>
50 </li> 50 </li>
51 </ul> 51 </ul>
52 </h:form> 52 </h:form>
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
5 xmlns:h="http://xmlns.jcp.org/jsf/html" 5 xmlns:h="http://xmlns.jcp.org/jsf/html"
6 xmlns:ui="http://xmlns.jcp.org/jsf/facelets" 6 xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
7 xmlns:f="http://xmlns.jcp.org/jsf/core"> 7 xmlns:f="http://xmlns.jcp.org/jsf/core">
8 +<f:metadata>
9 + <f:viewParam name="publisherId" value="#{listPublisherRevisionsBean.publisherId}"/>
10 + <f:viewAction action="#{listPublisherRevisionsBean.setView}"/>
11 +</f:metadata>
8 <h:body> 12 <h:body>
9 <h:form> 13 <h:form>
10 <h:commandLink action="home"> 14 <h:commandLink action="home">
...@@ -12,6 +16,7 @@ ...@@ -12,6 +16,7 @@
12 </h:commandLink> 16 </h:commandLink>
13 </h:form> 17 </h:form>
14 18
19 + <h:link rendered="#{not listPublisherRevisionsBean.viewAll}" outcome="/listPublisherRevisions.xhtml">Voir tous les éditeurs</h:link>
15 <h:outputText rendered="#{listPublisherRevisionsBean.publisherRevisions.isEmpty()}">Liste des révisions est vide</h:outputText> 20 <h:outputText rendered="#{listPublisherRevisionsBean.publisherRevisions.isEmpty()}">Liste des révisions est vide</h:outputText>
16 <h:dataTable value="#{listPublisherRevisionsBean.publisherRevisions}" var="revision"> 21 <h:dataTable value="#{listPublisherRevisionsBean.publisherRevisions}" var="revision">
17 <h:column> 22 <h:column>
...@@ -20,9 +25,12 @@ ...@@ -20,9 +25,12 @@
20 <f:param name="publisherRevisionId" value="#{revision.publisherRevisionId}"/> 25 <f:param name="publisherRevisionId" value="#{revision.publisherRevisionId}"/>
21 </h:link> 26 </h:link>
22 </h:column> 27 </h:column>
23 - <h:column> 28 + <h:column rendered="#{listPublisherRevisionsBean.viewAll}">
24 <f:facet name="header">Editeur</f:facet> 29 <f:facet name="header">Editeur</f:facet>
25 #{revision.publisher.publisherId} 30 #{revision.publisher.publisherId}
31 + <h:link outcome="/listPublisherRevisions.xhtml">
32 + <f:param name="publisherId" value="#{revision.publisher.publisherId}"/>
33 + </h:link>
26 </h:column> 34 </h:column>
27 <h:column> 35 <h:column>
28 <f:facet name="header">Name</f:facet> 36 <f:facet name="header">Name</f:facet>
......