Jean-Francois Leveque
......@@ -4,28 +4,72 @@ 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 ListPublisherRevisionsBean {
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;
}
}
......
......@@ -39,10 +39,6 @@
<from-outcome>listUsers</from-outcome>
<to-view-id>/listUsers.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>addPublisher</from-outcome>
<to-view-id>/addPublisher.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/addPublisher.xhtml</from-view-id>
......
......@@ -39,14 +39,14 @@
</h:commandLink>
</li>
<li>
<h:commandLink action="addPublisher">
<h:outputText value="Add Publisher"/>
</h:commandLink>
<h:link outcome="/addPublisher.xhtml">
<h:outputText value="Add a Publisher"/>
</h:link>
</li>
<li>
<h:commandLink action="listPublisherRevisions">
<h:link outcome="/listPublisherRevisions.xhtml">
<h:outputText value="List Publisher Revisions"/>
</h:commandLink>
</h:link>
</li>
</ul>
</h:form>
......
......@@ -5,6 +5,10 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:metadata>
<f:viewParam name="publisherId" value="#{listPublisherRevisionsBean.publisherId}"/>
<f:viewAction action="#{listPublisherRevisionsBean.setView}"/>
</f:metadata>
<h:body>
<h:form>
<h:commandLink action="home">
......@@ -12,6 +16,7 @@
</h:commandLink>
</h:form>
<h:link rendered="#{not listPublisherRevisionsBean.viewAll}" outcome="/listPublisherRevisions.xhtml">Voir tous les éditeurs</h:link>
<h:outputText rendered="#{listPublisherRevisionsBean.publisherRevisions.isEmpty()}">Liste des révisions est vide</h:outputText>
<h:dataTable value="#{listPublisherRevisionsBean.publisherRevisions}" var="revision">
<h:column>
......@@ -20,9 +25,12 @@
<f:param name="publisherRevisionId" value="#{revision.publisherRevisionId}"/>
</h:link>
</h:column>
<h:column>
<h:column rendered="#{listPublisherRevisionsBean.viewAll}">
<f:facet name="header">Editeur</f:facet>
#{revision.publisher.publisherId}
<h:link outcome="/listPublisherRevisions.xhtml">
<f:param name="publisherId" value="#{revision.publisher.publisherId}"/>
</h:link>
</h:column>
<h:column>
<f:facet name="header">Name</f:facet>
......