Jean-Francois Leveque

Debut ajout Editeur

package org.legrog.application;
import org.legrog.entities.Publisher;
import java.util.List;
public interface PublisherService {
void addPublisher(Publisher publisher);
List<Publisher> getAllPublishers();
}
package org.legrog.application;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRepository;
import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;
@Stateless
public class PublisherServiceSpring implements PublisherService {
@Inject
PublisherRepository publisherRepository;
public void addPublisher(Publisher publisher) {
publisherRepository.save(publisher);
}
public List<Publisher> getAllPublishers() {
return publisherRepository.findAll();
}
}
......@@ -3,9 +3,7 @@ package org.legrog.entities;
import javax.persistence.*;
@Entity
//@Table(name="pays")
public class Country /* extends org.roliste.data.DbEntity */ {
// @Column(name = "ID_PAYS")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */
@Column(name="COUNTRY_ID")
......
package org.legrog.entities;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PublisherRepository extends JpaRepository<Publisher, Integer> {
}
package org.legrog.presentation;
import org.legrog.application.SharedService;
import org.legrog.entities.Country;
import org.legrog.entities.User;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.sql.Timestamp;
import java.util.List;
@Named
@RequestScoped
public class AddPublisherBean {
@Inject
private SharedService sharedService;
private String publisherName;
private String publisherStreetAddress;
private String publisherPostalCode;
private String publisherPostOfficeBoxNumber;
private String publisherAddressRegion;
private String publisherAddressLocality;
private Country publisherAddressCountry;
private String publisherTelephone;
private String publisherEmail;
private String publisherURL;
private boolean publisherActive;
private String publisherHistory;
private User publisherRevisionAuthor;
private Timestamp publisherRevisionDatetime;
private List<Country> availableCountries;
public String add() {
return "success";
}
@PostConstruct
public void init() {
availableCountries = sharedService.getAllCountries();
}
public String getPublisherName() {
return publisherName;
}
public void setPublisherName(String publisherName) {
this.publisherName = publisherName;
}
public String getPublisherStreetAddress() {
return publisherStreetAddress;
}
public void setPublisherStreetAddress(String publisherStreetAddress) {
this.publisherStreetAddress = publisherStreetAddress;
}
public String getPublisherPostalCode() {
return publisherPostalCode;
}
public void setPublisherPostalCode(String publisherPostalCode) {
this.publisherPostalCode = publisherPostalCode;
}
public String getPublisherPostOfficeBoxNumber() {
return publisherPostOfficeBoxNumber;
}
public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) {
this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber;
}
public String getPublisherAddressRegion() {
return publisherAddressRegion;
}
public void setPublisherAddressRegion(String publisherAddressRegion) {
this.publisherAddressRegion = publisherAddressRegion;
}
public String getPublisherAddressLocality() {
return publisherAddressLocality;
}
public void setPublisherAddressLocality(String publisherAddressLocality) {
this.publisherAddressLocality = publisherAddressLocality;
}
public Country getPublisherAddressCountry() {
return publisherAddressCountry;
}
public void setPublisherAddressCountry(Country publisherAddressCountry) {
this.publisherAddressCountry = publisherAddressCountry;
}
public String getPublisherTelephone() {
return publisherTelephone;
}
public void setPublisherTelephone(String publisherTelephone) {
this.publisherTelephone = publisherTelephone;
}
public String getPublisherEmail() {
return publisherEmail;
}
public void setPublisherEmail(String publisherEmail) {
this.publisherEmail = publisherEmail;
}
public String getPublisherURL() {
return publisherURL;
}
public void setPublisherURL(String publisherURL) {
this.publisherURL = publisherURL;
}
public boolean isPublisherActive() {
return publisherActive;
}
public void setPublisherActive(boolean publisherActive) {
this.publisherActive = publisherActive;
}
public String getPublisherHistory() {
return publisherHistory;
}
public void setPublisherHistory(String publisherHistory) {
this.publisherHistory = publisherHistory;
}
public List<Country> getAvailableCountries() {
return availableCountries;
}
public void setAvailableCountries(List<Country> availableCountries) {
this.availableCountries = availableCountries;
}
}
\ No newline at end of file
......@@ -39,6 +39,10 @@
<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>
......
<?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">
<f:view>
<h:form>
<h:commandLink action="home">
<h:outputText value="Menu principal"/>
</h:commandLink>
<h:panelGrid columns="2">
<h:outputText value='publisherName'/>
<h:inputText value='#{addPublisherBean.publisherName}'/>
<h:outputText value='publisherStreetAddress'/>
<h:inputText value='#{addPublisherBean.publisherStreetAddress}'/>
<h:outputText value='publisherPostalCode'/>
<h:inputText value='#{addPublisherBean.publisherPostalCode}'/>
<h:outputText value='publisherPostOfficeBoxNumber'/>
<h:inputText value='#{addPublisherBean.publisherPostOfficeBoxNumber}'/>
<h:outputText value='publisherAddressRegion'/>
<h:inputText value='#{addPublisherBean.publisherAddressRegion}'/>
<h:outputText value='publisherAddressLocality'/>
<h:inputText value='#{addPublisherBean.publisherAddressLocality}'/>
<h:outputText value='publisherAddressCountry'/>
<h:selectOneMenu value="#{addPublisherBean.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter">
<f:selectItems value="#{addPublisherBean.availableCountries}" var="country" itemLabel="#{country.countryName}"/>
</h:selectOneMenu>
<h:outputText value='publisherTelephone'/>
<h:inputText value='#{addPublisherBean.publisherTelephone}'/>
<h:outputText value='publisherEmail'/>
<h:inputText value='#{addPublisherBean.publisherEmail}'/>
<h:outputText value='publisherURL'/>
<h:inputText value='#{addPublisherBean.publisherURL}'/>
<h:outputText value='publisherActive'/>
<h:selectBooleanCheckbox value="#{addPublisherBean.publisherActive}"/>
<h:outputText value='publisherHistory'/>
<h:inputTextarea value='#{addPublisherBean.publisherHistory}'/>
<h:outputText value='Add'/>
<h:commandButton action="#{addPublisherBean.add}" value="Add"/>
</h:panelGrid>
</h:form>
</f:view>
</html>
......@@ -38,6 +38,11 @@
<h:outputText value="List users"/>
</h:commandLink>
</li>
<li>
<h:commandLink action="addPublisher">
<h:outputText value="Add Publisher"/>
</h:commandLink>
</li>
</ul>
</h:form>
</body>
......