Commit 91e9c541 by Antti Tonkyra

Merge branch 'master' of dev.insomnia.fi:/data/bortal

2 parents 1e6c8df6 d79a313d
Showing with 437 additions and 66 deletions
......@@ -30,6 +30,8 @@ public class ReaderBean implements ReaderBeanLocal {
private CardTemplateBeanLocal cardtemplatebean;
@EJB
private ReaderEventFacade readerEventFacade;
@EJB
private EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class);
......@@ -168,4 +170,13 @@ public class ReaderBean implements ReaderBeanLocal {
return readerEventFacade.findLastEvents(reader, 20);
}
@Override
public ReaderEvent getEvent(Integer eventid) {
ReaderEvent ret = readerEventFacade.find(eventid);
if (!ret.getReader().getEvent().equals(eventbean.getCurrentEvent()))
{
ret = null;
}
return ret;
}
}
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.annotation.security.DeclareRoles;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.apps.SalespointPermission;
import fi.insomnia.bortal.facade.SalespointFacade;
import fi.insomnia.bortal.model.salespoint.Salespoint;
/**
* Session Bean implementation class SalespointBean
*/
@Stateless
@LocalBean
@DeclareRoles({ SalespointPermission.S_VIEW, SalespointPermission.S_MODIFY })
public class SalespointBean implements SalespointBeanLocal {
private static final Logger logger = LoggerFactory
.getLogger(SalespointBean.class);
@EJB
SalespointFacade salespointFacade;
public SalespointBean() {
}
@Override
public List<Salespoint> findAll() {
List<Salespoint> list = salespointFacade.findAll();
if (list != null)
logger.debug("Found {} salespoints", list.size());
return list;
}
}
package fi.insomnia.bortal.facade;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.model.salespoint.Salespoint;
import fi.insomnia.bortal.model.salespoint.Salespoint_;
/**
* Session Bean implementation class SalespointFacade
*/
@Stateless
@LocalBean
public class SalespointFacade extends IntegerPkGenericFacade<Salespoint> {
@EJB
private EventBeanLocal eventbean;
public SalespointFacade() {
super(Salespoint.class);
}
public List<Salespoint> findAll() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Salespoint> cq = cb.createQuery(Salespoint.class);
Root<Salespoint> root = cq.from(Salespoint.class);
cq.where(cb.equal(root.get(Salespoint_.event),
eventbean.getCurrentEvent()));
return getEm().createQuery(cq).getResultList();
}
}
......@@ -23,4 +23,6 @@ public interface ReaderBeanLocal {
List<ReaderEvent> getReaderEvents(Integer readerId);
ReaderEvent getEvent(Integer eventid);
}
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.model.salespoint.Salespoint;
@Local
public interface SalespointBeanLocal {
List<Salespoint> findAll();
}
......@@ -6,6 +6,7 @@ import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.enums.apps.LayoutPermission;
import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.enums.apps.PollPermission;
import fi.insomnia.bortal.enums.apps.SalespointPermission;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.enums.apps.TerminalPermission;
import fi.insomnia.bortal.enums.apps.UserPermission;
......@@ -19,6 +20,7 @@ public enum BortalApplication {
CONTENT("News, pages and other dynamic content", ContentPermission.class),
TERMINAL("Sales and self help terminal roles", TerminalPermission.class),
LAYOUT("Layoutstuff", LayoutPermission.class),
SALESPOINT("Managing salespoints", SalespointPermission.class),
;
......
package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum SalespointPermission implements IAppPermission {
VIEW("View salespoints"), MODIFY("Modify salespoints");
public static final String S_VIEW = "SALESPOINT/VIEW";
public static final String S_MODIFY = "SALESPOINT/MODIFY";
private final String description;
private final String fullName;
private SalespointPermission(String desc) {
description = desc;
fullName = new StringBuilder().append(getParent().toString())
.append(DELIMITER).append(toString()).toString();
}
@Override
public BortalApplication getParent() {
return BortalApplication.SALESPOINT;
}
@Override
public String getDescription() {
return description;
}
@Override
public String getFullName() {
return fullName;
}
}
......@@ -5,13 +5,17 @@
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{pageOutputView.initView('index')}" />
</f:metadata>
<ui:define name="content">
<h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa.
Vaihda web.xml-tiedostosta ohjelman tila (javax.faces.PROJECT_STAGE) Productioniksi ennen kuin julkaiset ohjelman tuotantoon.
</h:outputLabel>
<ui:repeat var="cont1" value="#{pageOutputView.contents}">
<h:outputText value="#{cont1.content}" escape="false" />
</ui:repeat>
</ui:define>
</ui:composition>
</h:body>
......
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:outputText
rendered="#{salespointListView.salespoints.rowCount le 0}"
value="#{i18n['salespoint.noSalespoints']}" />
<h:form rendered="#{salespointListView.salespoints.rowCount gt 0}">
<h:dataTable styleClass="bordertable" id="salespointList"
value="#{salespointListView.salespoints}" var="salespoint">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['salespoint.name']}" />
</f:facet>
<h:outputText value="#{salespoint.name}" />
</h:column>
<h:column rendered="#{billListView.canEditSalespoint}">
<h:link outcome="/salespoint/edit"
value="#{i18n['salespoint.edit']}">
<f:param name="salespointid" value="#{salespoint.id}" />
</h:link>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
\ No newline at end of file
......@@ -40,8 +40,13 @@
<h:outputText value="#{event.gamePoint}" />
</h:column>
<h:column>
<h:commandButton rendered="#{empty event.printedCard}" action="#{readerView.selectEvent()}" value="#{i18n['readerevent.associateToUser']}" />
<h:commandButton rendered="#{!empty event.printedCard}" action="#{readerView.selectEvent()}" value="#{i18n['readerevent.shopToUser']}" />
<h:link rendered="#{!empty event.printedCard}" outcome="/shop/shopToUser" value="#{i18n['readerevent.shopToUser']}">
<f:param name="userid" value="#{event.printedCard.user.id}" />
</h:link>
<h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" />
</h:link>
</h:column>
</h:dataTable>
......
......@@ -22,7 +22,6 @@ body,html {
#logo h1 {
margin: 5px;
color: white:
}
#logo a {
......@@ -196,4 +195,8 @@ a:hover {
margin: 0 7px;
color: #fff;
float: left;
}
td ul {
margin: 0;
}
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:salespoint="http://java.sun.com/jsf/composite/cditools/salespoint"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{salespointListView.init}" />
</f:metadata>
<ui:define name="content">
<salespoint:list />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -6,19 +6,19 @@
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{productShopView.initView}" />
<f:viewParam name="eventid" value="#{readerView.eventid}" />
<f:event type="preRenderView" listener="#{readerView.initUserassocView}" />
</f:metadata>
<ui:define name="content">
<h:outputText rendered="#{!empty readerView.rfidevent.event}" value="#{i18n['rfidevent.empty']}" />
<h:panelGrid columns="2" rendered="#{empty readerView.rfidevent.event}">
<h:outputText rendered="#{empty readerView.event}" value="#{i18n['rfidevent.empty']}" />
<h:panelGrid columns="2" rendered="#{!empty readerView.event}">
<h:outputLabel value="#{i18n['rfidevent.reader']}:" />
<h:outputText value="#{readerView.rfidevent.reader}" />
<h:outputText value="#{readerView.event.reader.description}" />
<h:outputLabel value="#{i18n['rfidevent.tag']}:" />
<h:outputText value="#{readerView.rfidevent.tag}" />
<h:outputText value="#{readerView.event.value}" />
<h:outputLabel value="#{i18n['rfidevent.insertplacecode']}" />
......
......@@ -11,7 +11,7 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{productShopView.initView}" />
<f:event type="preRenderView" listener="#{productShopView.initBillView}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.product.createBill.header']}</h1>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{productShopView.initView}" />
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" />
<f:event type="preRenderView" listener="#{productShopView.initShopView}" />
</f:metadata>
<ui:define name="content">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.user']}" />
<h:outputText value="#{productShopView.user.wholeName} #{productShopView.user.nick}" />
......@@ -28,9 +28,7 @@
<h:outputText value="#{i18n['product.shopInstant']}" />
<h:selectBooleanCheckbox value="#{productShopView.payInstant}" />
<products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.shoppingcart}"
commitValue="#{i18n['productshop.commit']}"
/>
<products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" />
</h:form>
</ui:define>
......
......@@ -19,43 +19,43 @@
<div>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="Name" for="name"/>
<h:outputLabel value="#{i18n['voting.create.name']}:" for="name"/>
<h:inputText value="#{votingCreateView.name}" id="name" />
<h:message for="name" />
<h:outputLabel value="Kuvaus:" for="desc"/>
<h:outputLabel value="#{i18n['voting.create.description']}:" for="desc"/>
<h:inputText value="#{votingCreateView.description}" id="desc" />
<h:message for="desc" />
<h:outputLabel value="Max osallistujat:" for="maxPar" />
<h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" />
<h:inputText value="#{votingCreateView.maxParticipants}" id="maxPar" />
<h:message for="maxPar" />
<h:outputLabel value="Compo start" for="cStart" />
<h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" />
<p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compoStart}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<h:message for="cStart" />
<h:outputLabel value="Compo end" for="cEnd"/>
<h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd"/>
<p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compoEnd}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<h:message for="cEnd" />
<h:outputLabel value="Vote start" for="vStart" />
<h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" />
<p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<h:message for="vStart" />
<h:outputLabel value="Vote end" for="vEnd" />
<h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" />
<p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<h:message for="vEnd" />
<h:outputLabel value="Submit start" for="sStart" />
<h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" />
<p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<h:message for="sStart" />
<h:outputLabel value="Submit end" for="sEnd" />
<h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" />
<p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<h:message for="sEnd" />
<h:commandButton value="Luo" />
<h:commandButton value="#{i18n['voting.create.createButton']}" />
</h:panelGrid>
</h:form>
......
......@@ -2,3 +2,5 @@ user.nickSizeMessage=Nick has to be at least {min} characters long.
user.emailregex=Field must contain an email address.
javax.validation.constraints.NotNull.message=Field can not be empty
voting.create.participantsError=Value must be 1 or over.
voting.create.nameError=Name must be longer than 3 chars.
......@@ -2,3 +2,5 @@ user.nickSizeMessage=Nimimerkin pit olla vhintn {min} merkki pitk.
user.emailregex=Kentss pit olla shkpostiosoite.
javax.validation.constraints.NotNull.message=Kentt ei saa olla tyhj
actionlog.message.tooshort=Kahva ei kelpaa! (Viestisi on liian lyhyt :)
voting.create.participantsError=Osallistujia pit olla yksi tai enemmn.
voting.create.nameError=Nimen pit olla yli 3 merkki pitk.
......@@ -525,3 +525,16 @@ userview.userExists = Username already exists! please select another.
viewexpired.body = Please login again.
viewexpired.title = Login expired. Please login again.
voting.create.compoEnd = End time
voting.create.compoStart = Start time
voting.create.createButton = Create
voting.create.dateValidatorEndDate = End time before start time.
voting.create.description = Description
voting.create.header = Create compo
voting.create.maxParticipants = Max participants
voting.create.name = Name
voting.create.submitEnd = Submit close
voting.create.submitStart = Submit start
voting.create.voteEnd = Voting close
voting.create.voteStart = Voting start
......@@ -90,6 +90,7 @@ public abstract class GenericCDIView implements Serializable {
}
protected void addFaceMessage(String string, Object... params) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get(string, params)));
}
......
......@@ -19,6 +19,7 @@ public class ActionLogCreateView extends GenericCDIView {
@EJB
private ActionLogBeanLocal actionLogBean;
@Size(min=4,message="{actionlog.message.tooshort}")
private String message;
private Role role;
......
......@@ -30,6 +30,12 @@ public class PageOutputView extends GenericCDIView {
initView();
}
public void initView(String name)
{
this.name = name;
initView();
}
public void initView() {
if (name == null || name.isEmpty()) {
setContents(pagebean.findContentsForUser(id));
......@@ -47,14 +53,6 @@ public class PageOutputView extends GenericCDIView {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setId(Integer id) {
this.id = id;
}
......
......@@ -50,20 +50,24 @@ public class ProductShopView extends GenericCDIView {
@Inject
private BillListView billListView;
public void initView() {
boolean ok = true;
if (!permbean.isCurrentUser(user)) {
ok = requirePermissions(ShopPermission.SHOP_TO_OTHERS);
public void initBillView()
{
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
logger.debug("Initialized billing shoppingcart to {}", shoppingcart);
this.beginConversation();
}
if (ok && shoppingcart == null) {
if (permbean.hasPermission(ShopPermission.LIST_ALL_PRODUCTS)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.getProducts()));
} else if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
}
logger.info("Initialized shoppingcart to {}", shoppingcart);
}
public void initShopView() {
if (requirePermissions(ShopPermission.SHOP_TO_OTHERS)) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
logger.debug("Initialized shoppingcart to {}", shoppingcart);
this.beginConversation();
}
}
public String add(Integer count)
......
......@@ -4,13 +4,16 @@ import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.ReaderBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.Reader;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.model.ReaderEvent;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
......@@ -19,29 +22,51 @@ public class ReaderView extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L;
private Integer eventid;
private String placecode;
private String usersearch;
private ListDataModel<User> userlist;
@Inject
private ReaderNameContainer namecontainer;
@EJB
private ReaderBeanLocal readerbean;
private List<Reader> readers;
private ReaderEvent event;
public void initReaderList() {
super.requirePermissions(ShopPermission.SHOP_TO_OTHERS);
@EJB
private UserBeanLocal userbean;
public void initUserassocView() {
if (super.requirePermissions(UserPermission.CREATE_NEW)) {
event = readerbean.getEvent(eventid);
super.beginConversation();
}
}
public List<ReaderEvent> getReaderEvents()
public String searchforuser()
{
return readerbean.getReaderEvents(namecontainer.getReaderId());
if (usersearch == null || usersearch.length() < 2) {
super.addFaceMessage("user.tooShortSearch");
} else {
userlist = new ListDataModel<User>(userbean.getUsers(0, 0, null, usersearch).getResults());
}
return null;
}
public List<Reader> getReaders()
{
if (readers == null) {
readers = readerbean.getReaders();
public void initReaderList() {
if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS)) {
}
return readers;
}
public List<ReaderEvent> getReaderEvents()
{
return readerbean.getReaderEvents(namecontainer.getReaderId());
}
public ReaderNameContainer getNamecontainer() {
......@@ -52,4 +77,44 @@ public class ReaderView extends GenericCDIView {
this.namecontainer = namecontainer;
}
public Integer getEventid() {
return eventid;
}
public void setEventid(Integer eventid) {
this.eventid = eventid;
}
public ReaderEvent getEvent() {
return event;
}
public void setEvent(ReaderEvent event) {
this.event = event;
}
public String getPlacecode() {
return placecode;
}
public void setPlacecode(String placecode) {
this.placecode = placecode;
}
public String getUsersearch() {
return usersearch;
}
public void setUsersearch(String usersearch) {
this.usersearch = usersearch;
}
public ListDataModel<User> getUserlist() {
return userlist;
}
public void setUserlist(ListDataModel<User> userlist) {
this.userlist = userlist;
}
}
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import fi.insomnia.bortal.beans.SalespointBeanLocal;
import fi.insomnia.bortal.enums.apps.SalespointPermission;
import fi.insomnia.bortal.model.salespoint.Salespoint;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
/**
* Session Bean implementation class SalespointListView
*/
@Named
@ConversationScoped
public class SalespointListView extends GenericCDIView {
@EJB
private SalespointBeanLocal salespointBean;
private static final long serialVersionUID = -8990414681240360892L;
private ListDataModel<Salespoint> salespoints;
private boolean modifySalespoint;
public SalespointListView() {
}
public void init() {
if (super.requirePermissions(SalespointPermission.VIEW)) {
beginConversation();
salespoints = new ListDataModel<Salespoint>(
salespointBean.findAll());
modifySalespoint = permbean
.hasPermission(SalespointPermission.MODIFY);
}
}
public ListDataModel<Salespoint> getSalespoints() {
return salespoints;
}
public void setSalespoints(ListDataModel<Salespoint> salespoints) {
this.salespoints = salespoints;
}
public boolean canEditSalespoint() {
return modifySalespoint;
}
}
......@@ -7,6 +7,9 @@ import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Named;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Length;
import fi.insomnia.bortal.beans.VotingBeanLocal;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
......@@ -24,10 +27,10 @@ public class VotingCreateView extends GenericCDIView {
@EJB
private VotingBeanLocal votbean;
@Min(value=4,message="Nimen pitää olla pidempi kuin 4 merkkiä.")
@Size(min=4, message="{voting.create.nameError}")
private String name;
private String description;
@Min(value=1, message="Min osallistujia 1.")
@Min(value=1, message="{voting.create.participantsError}")
private Integer maxParticipants;
private Date compoStart;
......
......@@ -10,11 +10,14 @@ import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.jsp.tagext.ValidationMessage;
import org.eclipse.persistence.exceptions.ValidationException;
import org.hibernate.validator.util.LoggerFactory;
import org.slf4j.Logger;
import fi.insomnia.bortal.utilities.I18n;
@Named
@RequestScoped
......@@ -34,7 +37,8 @@ public class VotingDateValidator implements Serializable {
//UIComponent foo = ui.findComponent("cStart");
//logger.info("uielement {} ", foo);
if(endDate.before(cStart)) {
message(new FacesMessage("Loppumispvm ennen alkua. KORJAA SE."));
message(new FacesMessage(I18n.get("voting.create.dateValidatorEndDate")));
}
}
......@@ -47,7 +51,7 @@ public class VotingDateValidator implements Serializable {
public void validateVote(FacesContext context, UIComponent ui, Object object) {
Date endDate = (Date)object;
if(endDate.before(vStart)) {
message(new FacesMessage("Loppumispvm ennen alkua. NOT VALID."));
message(new FacesMessage(I18n.get("voting.create.dateValidatorEndDate")));
}
}
......@@ -58,7 +62,7 @@ public class VotingDateValidator implements Serializable {
public void validateSubmit(FacesContext context, UIComponent ui, Object object) {
Date endDate = (Date)object;
if(endDate.before(sStart)) {
message(new FacesMessage("Loppumispvm ennen aloitusta. IS AN ERROR."));
message(new FacesMessage(I18n.get("voting.create.dateValidatorEndDate")));
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!