display some of paper

This commit is contained in:
Anton Romanov 2019-11-22 23:47:59 +04:00
parent 779f286988
commit 6c220355ee
7 changed files with 93 additions and 10 deletions

View File

@ -0,0 +1,21 @@
package ru.ulstu.paper.controller;
import ru.ulstu.paper.model.Paper;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
@FacesConverter(value = "paperStatusConverter")
public class PaperStatusConverter implements Converter {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
return Paper.PaperStatus.valueOf(value);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return ((Paper.PaperStatus) value).getStatusName();
}
}

View File

@ -4,25 +4,39 @@ import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.service.PaperService;
import javax.annotation.PostConstruct;
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.Arrays;
import java.util.List;
import java.util.Map;
@Named
@ViewScoped
public class PaperView {
public class PaperView implements Serializable {
@Inject
private PaperService paperService;
private List<Paper> papers;
private Paper paper;
@PostConstruct
public void init() {
papers = paperService.findAll();
Map<String, String> params = FacesContext.getCurrentInstance().
getExternalContext().getRequestParameterMap();
paper = paperService.findPaperById(Integer.valueOf(params.get("id")));
}
public List<Paper> getPapers() {
return papers;
public Paper getPaper() {
return paper;
}
public void setPaper(Paper paper) {
this.paper = paper;
}
public List<Paper.PaperStatus> getPaperStatuses() {
return Arrays.asList(Paper.PaperStatus.values());
}
}

View File

@ -0,0 +1,28 @@
package ru.ulstu.paper.controller;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.service.PaperService;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.List;
@Named
@ViewScoped
public class PapersView {
@Inject
private PaperService paperService;
private List<Paper> papers;
@PostConstruct
public void init() {
papers = paperService.findAll();
}
public List<Paper> getPapers() {
return papers;
}
}

View File

@ -7,7 +7,7 @@
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>NG-Tracker</title>
<title><ui:insert name="header">NG-Tracker</ui:insert></title>
<h:outputStylesheet name="css/style.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
</h:head>

View File

@ -1,11 +1,31 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
>
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/basicTemplate.xhtml">
<ui:define name="header">
Редактироваие статьи
</ui:define>
<ui:define name="content">
<p:panel id="panel" header="Статья" style="margin-bottom:10px;">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="name" value="Название:"/>
<p:inputText id="name" required="true" value="#{paperView.paper.title}"/>
<p:outputLabel for="status" value="Статус:"/>
<p:selectOneMenu id="status" required="true" value="#{paperView.paper.status}"
converter="paperStatusConverter">
<f:selectItems value="#{paperView.paperStatuses}"
var="status"
itemLabel="#{status.statusName}"
itemValue="#{status}"/>
</p:selectOneMenu>
<p:outputLabel for="@next" value="Number:"/>
<p:spinner id="number" value="0"/>
</h:panelGrid>
</p:panel>
</ui:define>
</ui:composition>
</html>

View File

@ -5,7 +5,7 @@
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/basicTemplate.xhtml">
<ui:define name="content">
<p:dataTable value="#{paperView.papers}" var="paper" paginator="true" rows="10">
<p:dataTable value="#{papersView.papers}" var="paper" paginator="true" rows="10">
<p:column headerText="Статус">
<ui:include src="paperStatusFragment.xhtml">
<ui:param name="paper" value="#{paper}"/>

View File

@ -16,7 +16,7 @@ logging.level.ru.ulstu=DEBUG
#HtmlUnit
logging.level.com.gargoylesoftware.htmlunit=ERROR
#jsf
joinfaces.primefaces.theme=bootstrap
joinfaces.primefaces.theme=casablanca
joinfaces.primefaces.font-awesome=true
# Mail Settings
spring.mail.host=smtp.yandex.ru