display some of paper
This commit is contained in:
parent
779f286988
commit
6c220355ee
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -4,25 +4,39 @@ import ru.ulstu.paper.model.Paper;
|
|||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.view.ViewScoped;
|
import javax.faces.view.ViewScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Named
|
@Named
|
||||||
@ViewScoped
|
@ViewScoped
|
||||||
public class PaperView {
|
public class PaperView implements Serializable {
|
||||||
@Inject
|
@Inject
|
||||||
private PaperService paperService;
|
private PaperService paperService;
|
||||||
|
|
||||||
private List<Paper> papers;
|
private Paper paper;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
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() {
|
public Paper getPaper() {
|
||||||
return papers;
|
return paper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaper(Paper paper) {
|
||||||
|
this.paper = paper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper.PaperStatus> getPaperStatuses() {
|
||||||
|
return Arrays.asList(Paper.PaperStatus.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
src/main/java/ru/ulstu/paper/controller/PapersView.java
Normal file
28
src/main/java/ru/ulstu/paper/controller/PapersView.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
|
||||||
<h:head>
|
<h:head>
|
||||||
<title>NG-Tracker</title>
|
<title><ui:insert name="header">NG-Tracker</ui:insert></title>
|
||||||
<h:outputStylesheet name="css/style.css"/>
|
<h:outputStylesheet name="css/style.css"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
||||||
</h:head>
|
</h:head>
|
||||||
|
@ -1,11 +1,31 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
<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:composition template="/basicTemplate.xhtml">
|
||||||
|
<ui:define name="header">
|
||||||
|
Редактироваие статьи
|
||||||
|
</ui:define>
|
||||||
<ui:define name="content">
|
<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:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
</html>
|
</html>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
|
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
<ui:composition template="/basicTemplate.xhtml">
|
<ui:composition template="/basicTemplate.xhtml">
|
||||||
<ui:define name="content">
|
<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="Статус">
|
<p:column headerText="Статус">
|
||||||
<ui:include src="paperStatusFragment.xhtml">
|
<ui:include src="paperStatusFragment.xhtml">
|
||||||
<ui:param name="paper" value="#{paper}"/>
|
<ui:param name="paper" value="#{paper}"/>
|
||||||
|
@ -16,7 +16,7 @@ logging.level.ru.ulstu=DEBUG
|
|||||||
#HtmlUnit
|
#HtmlUnit
|
||||||
logging.level.com.gargoylesoftware.htmlunit=ERROR
|
logging.level.com.gargoylesoftware.htmlunit=ERROR
|
||||||
#jsf
|
#jsf
|
||||||
joinfaces.primefaces.theme=bootstrap
|
joinfaces.primefaces.theme=casablanca
|
||||||
joinfaces.primefaces.font-awesome=true
|
joinfaces.primefaces.font-awesome=true
|
||||||
# Mail Settings
|
# Mail Settings
|
||||||
spring.mail.host=smtp.yandex.ru
|
spring.mail.host=smtp.yandex.ru
|
||||||
|
Loading…
Reference in New Issue
Block a user