show paper type

This commit is contained in:
Anton Romanov 2019-11-23 09:27:15 +04:00
parent 6c220355ee
commit 7587ff7a51
3 changed files with 34 additions and 4 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 = "paperTypeConverter")
public class PaperTypeConverter implements Converter {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
return Paper.PaperType.valueOf(value);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return ((Paper.PaperType) value).getTypeName();
}
}

View File

@ -39,4 +39,8 @@ public class PaperView implements Serializable {
public List<Paper.PaperStatus> getPaperStatuses() { public List<Paper.PaperStatus> getPaperStatuses() {
return Arrays.asList(Paper.PaperStatus.values()); return Arrays.asList(Paper.PaperStatus.values());
} }
public List<Paper.PaperType> getPaperTypes() {
return Arrays.asList(Paper.PaperType.values());
}
} }

View File

@ -13,7 +13,7 @@
<h:outputLabel for="name" value="Название:"/> <h:outputLabel for="name" value="Название:"/>
<p:inputText id="name" required="true" value="#{paperView.paper.title}"/> <p:inputText id="name" required="true" value="#{paperView.paper.title}"/>
<p:outputLabel for="status" value="Статус:"/> <p:outputLabel for="@next" value="Статус:"/>
<p:selectOneMenu id="status" required="true" value="#{paperView.paper.status}" <p:selectOneMenu id="status" required="true" value="#{paperView.paper.status}"
converter="paperStatusConverter"> converter="paperStatusConverter">
<f:selectItems value="#{paperView.paperStatuses}" <f:selectItems value="#{paperView.paperStatuses}"
@ -21,9 +21,14 @@
itemLabel="#{status.statusName}" itemLabel="#{status.statusName}"
itemValue="#{status}"/> itemValue="#{status}"/>
</p:selectOneMenu> </p:selectOneMenu>
<p:outputLabel for="@next" value="Тип:"/>
<p:outputLabel for="@next" value="Number:"/> <p:selectOneMenu id="type" value="#{paperView.paper.type}"
<p:spinner id="number" value="0"/> converter="paperTypeConverter">
<f:selectItems value="#{paperView.paperTypes}"
var="type"
itemLabel="#{type.typeName}"
itemValue="#{type}"/>
</p:selectOneMenu>
</h:panelGrid> </h:panelGrid>
</p:panel> </p:panel>
</ui:define> </ui:define>