add filter
This commit is contained in:
parent
a67eb23714
commit
268a311a87
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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<Paper.PaperStatus> getPaperStatuses() {
|
||||
return Arrays.asList(Paper.PaperStatus.values());
|
||||
}
|
||||
|
||||
public List<Paper> getPapers() {
|
||||
return papers;
|
||||
}
|
||||
|
@ -5,14 +5,36 @@
|
||||
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="#{papersView.papers}" var="paper" paginator="true" rows="10">
|
||||
<p:column headerText="Название">
|
||||
<style>
|
||||
.ui-datatable .ui-datatable-header {
|
||||
text-align: right !important;
|
||||
}
|
||||
</style>
|
||||
<p:dataTable value="#{papersView.papers}" var="paper" paginator="true" rows="10" id="papersTable"
|
||||
widgetVar="papersTable" emptyMessage="Не найдено подходящих статей">
|
||||
<f:facet name="header">
|
||||
<p:outputPanel>
|
||||
<h:outputText value="Поиск:"/>
|
||||
<p:inputText id="globalFilter" onkeyup="PF('papersTable').filter()" style="width:150px"
|
||||
placeholder="Строка поиска..."/>
|
||||
</p:outputPanel>
|
||||
</f:facet>
|
||||
<p:column headerText="Название" filterBy="#{paper.title}" filterMatchMode="contains">
|
||||
<h:outputLink value="/paper/paper.xhtml">
|
||||
#{paper.title}
|
||||
<f:param name="id" value="#{paper.id}"/>
|
||||
</h:outputLink>
|
||||
</p:column>
|
||||
<p:column headerText="Статус">
|
||||
<p:column headerText="Статус" filterBy="#{paper.status} #{paper.status.statusName}"
|
||||
filterMatchMode="contains">'
|
||||
<f:facet name="filter">
|
||||
<p:selectOneMenu onchange="PF('papersTable').filter()" styleClass="custom-filter"
|
||||
converter="paperStatusConverter">
|
||||
<f:selectItem itemLabel="Статус" itemValue="#{null}" noSelectionOption="true"/>
|
||||
<f:selectItems value="#{papersView.paperStatuses}" var="status" itemLabel="#{status.statusName}"
|
||||
itemValue="#{status}"/>
|
||||
</p:selectOneMenu>
|
||||
</f:facet>
|
||||
<ui:include src="paperStatusFragment.xhtml">
|
||||
<ui:param name="paper" value="#{paper}"/>
|
||||
</ui:include>
|
||||
|
Loading…
Reference in New Issue
Block a user