From 6c220355eedede275aee19e4abe02e7adef9b6ef Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 22 Nov 2019 23:47:59 +0400 Subject: [PATCH] display some of paper --- .../controller/PaperStatusConverter.java | 21 ++++++++++++++ .../ru/ulstu/paper/controller/PaperView.java | 24 ++++++++++++---- .../ru/ulstu/paper/controller/PapersView.java | 28 +++++++++++++++++++ .../META-INF/resources/basicTemplate.xhtml | 2 +- .../META-INF/resources/paper/paper.xhtml | 24 ++++++++++++++-- .../META-INF/resources/paper/papers.xhtml | 2 +- src/main/resources/application.properties | 2 +- 7 files changed, 93 insertions(+), 10 deletions(-) create mode 100644 src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java create mode 100644 src/main/java/ru/ulstu/paper/controller/PapersView.java diff --git a/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java b/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java new file mode 100644 index 0000000..02c729c --- /dev/null +++ b/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java @@ -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(); + } +} diff --git a/src/main/java/ru/ulstu/paper/controller/PaperView.java b/src/main/java/ru/ulstu/paper/controller/PaperView.java index 54f802f..1b54e3d 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperView.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperView.java @@ -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 papers; + private Paper paper; @PostConstruct public void init() { - papers = paperService.findAll(); + Map params = FacesContext.getCurrentInstance(). + getExternalContext().getRequestParameterMap(); + paper = paperService.findPaperById(Integer.valueOf(params.get("id"))); } - public List getPapers() { - return papers; + public Paper getPaper() { + return paper; + } + + public void setPaper(Paper paper) { + this.paper = paper; + } + + public List getPaperStatuses() { + return Arrays.asList(Paper.PaperStatus.values()); } } diff --git a/src/main/java/ru/ulstu/paper/controller/PapersView.java b/src/main/java/ru/ulstu/paper/controller/PapersView.java new file mode 100644 index 0000000..d932b09 --- /dev/null +++ b/src/main/java/ru/ulstu/paper/controller/PapersView.java @@ -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 papers; + + @PostConstruct + public void init() { + papers = paperService.findAll(); + } + + public List getPapers() { + return papers; + } +} diff --git a/src/main/resources/META-INF/resources/basicTemplate.xhtml b/src/main/resources/META-INF/resources/basicTemplate.xhtml index eccdb0a..8710ac9 100644 --- a/src/main/resources/META-INF/resources/basicTemplate.xhtml +++ b/src/main/resources/META-INF/resources/basicTemplate.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core"> - NG-Tracker + <ui:insert name="header">NG-Tracker</ui:insert> diff --git a/src/main/resources/META-INF/resources/paper/paper.xhtml b/src/main/resources/META-INF/resources/paper/paper.xhtml index cf96656..520fb29 100644 --- a/src/main/resources/META-INF/resources/paper/paper.xhtml +++ b/src/main/resources/META-INF/resources/paper/paper.xhtml @@ -1,11 +1,31 @@ + 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"> + + Редактироваие статьи + + + + + + + + + + + + + + diff --git a/src/main/resources/META-INF/resources/paper/papers.xhtml b/src/main/resources/META-INF/resources/paper/papers.xhtml index 5c5d5a7..7fcfb3f 100644 --- a/src/main/resources/META-INF/resources/paper/papers.xhtml +++ b/src/main/resources/META-INF/resources/paper/papers.xhtml @@ -5,7 +5,7 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> - + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c3b671e..756c3b3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -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