From 268a311a8706a7be7b1f5ff0f41e5070d4f554ea Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 26 Nov 2019 23:02:02 +0400 Subject: [PATCH] add filter --- .../controller/PaperStatusConverter.java | 2 +- .../ru/ulstu/paper/controller/PapersView.java | 5 ++++ .../META-INF/resources/paper/papers.xhtml | 28 +++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java b/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java index dce25e0..8f809b0 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperStatusConverter.java @@ -16,6 +16,6 @@ public class PaperStatusConverter implements Converter { @Override public String getAsString(FacesContext context, UIComponent component, Object value) { - return ((Paper.PaperStatus) value).name(); + return value == null ? "" : ((Paper.PaperStatus) value).name(); } } diff --git a/src/main/java/ru/ulstu/paper/controller/PapersView.java b/src/main/java/ru/ulstu/paper/controller/PapersView.java index d932b09..3539f51 100644 --- a/src/main/java/ru/ulstu/paper/controller/PapersView.java +++ b/src/main/java/ru/ulstu/paper/controller/PapersView.java @@ -7,6 +7,7 @@ import javax.annotation.PostConstruct; import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; +import java.util.Arrays; import java.util.List; @Named @@ -22,6 +23,10 @@ public class PapersView { papers = paperService.findAll(); } + public List getPaperStatuses() { + return Arrays.asList(Paper.PaperStatus.values()); + } + public List getPapers() { return papers; } diff --git a/src/main/resources/META-INF/resources/paper/papers.xhtml b/src/main/resources/META-INF/resources/paper/papers.xhtml index 02539b9..0e7e7af 100644 --- a/src/main/resources/META-INF/resources/paper/papers.xhtml +++ b/src/main/resources/META-INF/resources/paper/papers.xhtml @@ -5,14 +5,36 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> - - + + + + + + + + + #{paper.title} - + ' + + + + + +