Commit d79a313d by Juho Juopperi

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

2 parents 31418a0f 74c80ebc
Showing with 212 additions and 71 deletions
...@@ -30,6 +30,8 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -30,6 +30,8 @@ public class ReaderBean implements ReaderBeanLocal {
private CardTemplateBeanLocal cardtemplatebean; private CardTemplateBeanLocal cardtemplatebean;
@EJB @EJB
private ReaderEventFacade readerEventFacade; private ReaderEventFacade readerEventFacade;
@EJB
private EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class); private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class);
...@@ -168,4 +170,13 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -168,4 +170,13 @@ public class ReaderBean implements ReaderBeanLocal {
return readerEventFacade.findLastEvents(reader, 20); 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; package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -27,7 +29,9 @@ public class VotingBean implements VotingBeanLocal { ...@@ -27,7 +29,9 @@ public class VotingBean implements VotingBeanLocal {
public void createCompo(Compo c) { public void createCompo(Compo c) {
compoFacade.create(c); compoFacade.create(c);
} }
public List<Compo> getCompoList() {
return compoFacade.getList();
}
} }
package fi.insomnia.bortal.facade; package fi.insomnia.bortal.facade;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; 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.Compo; import fi.insomnia.bortal.model.Compo;
import fi.insomnia.bortal.model.Compo_;
import fi.insomnia.bortal.model.NewsGroup;
import fi.insomnia.bortal.model.NewsGroup_;
@Stateless @Stateless
@LocalBean @LocalBean
public class CompoFacade extends IntegerPkGenericFacade<Compo> { public class CompoFacade extends IntegerPkGenericFacade<Compo> {
@EJB
private EventBeanLocal eventbean;
public CompoFacade() { public CompoFacade() {
super(Compo.class); super(Compo.class);
} }
} public List<Compo> getList() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Compo> cq = cb.createQuery(Compo.class);
Root<Compo> root = cq.from(Compo.class);
cq.where(cb.equal(root.get(Compo_.event), eventbean.getCurrentEvent()));
List<Compo> ret = getEm().createQuery(cq).getResultList();
return ret;
}
}
...@@ -23,4 +23,6 @@ public interface ReaderBeanLocal { ...@@ -23,4 +23,6 @@ public interface ReaderBeanLocal {
List<ReaderEvent> getReaderEvents(Integer readerId); List<ReaderEvent> getReaderEvents(Integer readerId);
ReaderEvent getEvent(Integer eventid);
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 6 (MacOS X Default)"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
......
...@@ -5,13 +5,17 @@ ...@@ -5,13 +5,17 @@
</h:head> </h:head>
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{pageOutputView.initView('index')}" />
</f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}"> <h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa. Development-tilassa.
Vaihda web.xml-tiedostosta ohjelman tila (javax.faces.PROJECT_STAGE) Productioniksi ennen kuin julkaiset ohjelman tuotantoon. Vaihda web.xml-tiedostosta ohjelman tila (javax.faces.PROJECT_STAGE) Productioniksi ennen kuin julkaiset ohjelman tuotantoon.
</h:outputLabel> </h:outputLabel>
<ui:repeat var="cont1" value="#{pageOutputView.contents}">
<h:outputText value="#{cont1.content}" escape="false" />
</ui:repeat>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -40,8 +40,13 @@ ...@@ -40,8 +40,13 @@
<h:outputText value="#{event.gamePoint}" /> <h:outputText value="#{event.gamePoint}" />
</h:column> </h:column>
<h:column> <h:column>
<h:commandButton rendered="#{empty event.printedCard}" action="#{readerView.selectEvent()}" value="#{i18n['readerevent.associateToUser']}" /> <h:link rendered="#{!empty event.printedCard}" outcome="/shop/shopToUser" value="#{i18n['readerevent.shopToUser']}">
<h:commandButton rendered="#{!empty event.printedCard}" action="#{readerView.selectEvent()}" 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:column>
</h:dataTable> </h:dataTable>
......
...@@ -22,7 +22,6 @@ body,html { ...@@ -22,7 +22,6 @@ body,html {
#logo h1 { #logo h1 {
margin: 5px; margin: 5px;
color: white: color: white:
} }
#logo a { #logo a {
...@@ -196,4 +195,8 @@ a:hover { ...@@ -196,4 +195,8 @@ a:hover {
margin: 0 7px; margin: 0 7px;
color: #fff; color: #fff;
float: left; float: left;
}
td ul {
margin: 0;
} }
\ No newline at end of file
...@@ -6,19 +6,19 @@ ...@@ -6,19 +6,19 @@
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" /> <f:viewParam name="eventid" value="#{readerView.eventid}" />
<f:event type="preRenderView" listener="#{productShopView.initView}" /> <f:event type="preRenderView" listener="#{readerView.initUserassocView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:outputText rendered="#{!empty readerView.rfidevent.event}" value="#{i18n['rfidevent.empty']}" /> <h:outputText rendered="#{empty readerView.event}" value="#{i18n['rfidevent.empty']}" />
<h:panelGrid columns="2" rendered="#{empty readerView.rfidevent.event}"> <h:panelGrid columns="2" rendered="#{!empty readerView.event}">
<h:outputLabel value="#{i18n['rfidevent.reader']}:" /> <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:outputLabel value="#{i18n['rfidevent.tag']}:" />
<h:outputText value="#{readerView.rfidevent.tag}" /> <h:outputText value="#{readerView.event.value}" />
<h:outputLabel value="#{i18n['rfidevent.insertplacecode']}" /> <h:outputLabel value="#{i18n['rfidevent.insertplacecode']}" />
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" /> <f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{productShopView.initView}" /> <f:event type="preRenderView" listener="#{productShopView.initBillView}" />
</f:metadata> </f:metadata>
<ui:define name="title"> <ui:define name="title">
<h1>#{i18n['page.product.createBill.header']}</h1> <h1>#{i18n['page.product.createBill.header']}</h1>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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" <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: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">
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <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> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.user']}" /> <h:outputLabel value="#{i18n['shop.user']}" />
<h:outputText value="#{productShopView.user.wholeName} #{productShopView.user.nick}" /> <h:outputText value="#{productShopView.user.wholeName} #{productShopView.user.nick}" />
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
<h:outputText value="#{i18n['product.shopInstant']}" /> <h:outputText value="#{i18n['product.shopInstant']}" />
<h:selectBooleanCheckbox value="#{productShopView.payInstant}" /> <h:selectBooleanCheckbox value="#{productShopView.payInstant}" />
<products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.shoppingcart}" <products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" />
commitValue="#{i18n['productshop.commit']}"
/>
</h:form> </h:form>
</ui:define> </ui:define>
......
...@@ -19,43 +19,43 @@ ...@@ -19,43 +19,43 @@
<div> <div>
<h:form> <h:form>
<h:panelGrid columns="3"> <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:inputText value="#{votingCreateView.name}" id="name" />
<h:message for="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:inputText value="#{votingCreateView.description}" id="desc" />
<h:message for="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:inputText value="#{votingCreateView.maxParticipants}" id="maxPar" />
<h:message for="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" /> <p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compoStart}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<h:message for="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" /> <p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compoEnd}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<h:message for="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" /> <p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<h:message for="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" /> <p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<h:message for="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" /> <p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<h:message for="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" /> <p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<h:message for="sEnd" /> <h:message for="sEnd" />
<h:commandButton value="Luo" /> <h:commandButton value="#{i18n['voting.create.createButton']}" />
</h:panelGrid> </h:panelGrid>
</h:form> </h:form>
......
...@@ -2,3 +2,5 @@ user.nickSizeMessage=Nick has to be at least {min} characters long. ...@@ -2,3 +2,5 @@ user.nickSizeMessage=Nick has to be at least {min} characters long.
user.emailregex=Field must contain an email address. user.emailregex=Field must contain an email address.
javax.validation.constraints.NotNull.message=Field can not be empty 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. ...@@ -2,3 +2,5 @@ user.nickSizeMessage=Nimimerkin pit olla vhintn {min} merkki pitk.
user.emailregex=Kentss pit olla shkpostiosoite. user.emailregex=Kentss pit olla shkpostiosoite.
javax.validation.constraints.NotNull.message=Kentt ei saa olla tyhj javax.validation.constraints.NotNull.message=Kentt ei saa olla tyhj
actionlog.message.tooshort=Kahva ei kelpaa! (Viestisi on liian lyhyt :) 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. ...@@ -525,3 +525,16 @@ userview.userExists = Username already exists! please select another.
viewexpired.body = Please login again. viewexpired.body = Please login again.
viewexpired.title = Login expired. 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 { ...@@ -90,6 +90,7 @@ public abstract class GenericCDIView implements Serializable {
} }
protected void addFaceMessage(String string, Object... params) { protected void addFaceMessage(String string, Object... params) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get(string, params))); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get(string, params)));
} }
......
...@@ -19,6 +19,7 @@ public class ActionLogCreateView extends GenericCDIView { ...@@ -19,6 +19,7 @@ public class ActionLogCreateView extends GenericCDIView {
@EJB @EJB
private ActionLogBeanLocal actionLogBean; private ActionLogBeanLocal actionLogBean;
@Size(min=4,message="{actionlog.message.tooshort}") @Size(min=4,message="{actionlog.message.tooshort}")
private String message; private String message;
private Role role; private Role role;
......
...@@ -30,6 +30,12 @@ public class PageOutputView extends GenericCDIView { ...@@ -30,6 +30,12 @@ public class PageOutputView extends GenericCDIView {
initView(); initView();
} }
public void initView(String name)
{
this.name = name;
initView();
}
public void initView() { public void initView() {
if (name == null || name.isEmpty()) { if (name == null || name.isEmpty()) {
setContents(pagebean.findContentsForUser(id)); setContents(pagebean.findContentsForUser(id));
...@@ -47,14 +53,6 @@ public class PageOutputView extends GenericCDIView { ...@@ -47,14 +53,6 @@ public class PageOutputView extends GenericCDIView {
return id; return id;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
......
...@@ -50,20 +50,24 @@ public class ProductShopView extends GenericCDIView { ...@@ -50,20 +50,24 @@ public class ProductShopView extends GenericCDIView {
@Inject @Inject
private BillListView billListView; private BillListView billListView;
public void initView() { public void initBillView()
boolean ok = true; {
if (!permbean.isCurrentUser(user)) { if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)) {
ok = requirePermissions(ShopPermission.SHOP_TO_OTHERS); 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)) { public void initShopView() {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
} if (requirePermissions(ShopPermission.SHOP_TO_OTHERS)) {
logger.info("Initialized shoppingcart to {}", shoppingcart); shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
logger.debug("Initialized shoppingcart to {}", shoppingcart);
this.beginConversation(); this.beginConversation();
} }
} }
public String add(Integer count) public String add(Integer count)
......
...@@ -4,13 +4,16 @@ import java.util.List; ...@@ -4,13 +4,16 @@ import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import fi.insomnia.bortal.beans.ReaderBeanLocal; import fi.insomnia.bortal.beans.ReaderBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission; 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.ReaderEvent;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.cdiview.GenericCDIView; import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named @Named
...@@ -19,29 +22,51 @@ public class ReaderView extends GenericCDIView { ...@@ -19,29 +22,51 @@ public class ReaderView extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L; private static final long serialVersionUID = 802344850073689859L;
private Integer eventid;
private String placecode;
private String usersearch;
private ListDataModel<User> userlist;
@Inject @Inject
private ReaderNameContainer namecontainer; private ReaderNameContainer namecontainer;
@EJB @EJB
private ReaderBeanLocal readerbean; private ReaderBeanLocal readerbean;
private List<Reader> readers; private ReaderEvent event;
public void initReaderList() { @EJB
super.requirePermissions(ShopPermission.SHOP_TO_OTHERS); 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() public void initReaderList() {
{ if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS)) {
if (readers == null) {
readers = readerbean.getReaders();
} }
return readers; }
public List<ReaderEvent> getReaderEvents()
{
return readerbean.getReaderEvents(namecontainer.getReaderId());
} }
public ReaderNameContainer getNamecontainer() { public ReaderNameContainer getNamecontainer() {
...@@ -52,4 +77,44 @@ public class ReaderView extends GenericCDIView { ...@@ -52,4 +77,44 @@ public class ReaderView extends GenericCDIView {
this.namecontainer = namecontainer; 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;
}
} }
...@@ -7,6 +7,9 @@ import javax.faces.bean.ManagedBean; ...@@ -7,6 +7,9 @@ import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped; import javax.faces.bean.RequestScoped;
import javax.inject.Named; import javax.inject.Named;
import javax.validation.constraints.Min; 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.beans.VotingBeanLocal;
import fi.insomnia.bortal.web.cdiview.GenericCDIView; import fi.insomnia.bortal.web.cdiview.GenericCDIView;
...@@ -24,10 +27,10 @@ public class VotingCreateView extends GenericCDIView { ...@@ -24,10 +27,10 @@ public class VotingCreateView extends GenericCDIView {
@EJB @EJB
private VotingBeanLocal votbean; 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 name;
private String description; private String description;
@Min(value=1, message="Min osallistujia 1.") @Min(value=1, message="{voting.create.participantsError}")
private Integer maxParticipants; private Integer maxParticipants;
private Date compoStart; private Date compoStart;
......
...@@ -10,11 +10,14 @@ import javax.faces.context.FacesContext; ...@@ -10,11 +10,14 @@ import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException; import javax.faces.validator.ValidatorException;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.servlet.jsp.tagext.ValidationMessage;
import org.eclipse.persistence.exceptions.ValidationException; import org.eclipse.persistence.exceptions.ValidationException;
import org.hibernate.validator.util.LoggerFactory; import org.hibernate.validator.util.LoggerFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import fi.insomnia.bortal.utilities.I18n;
@Named @Named
@RequestScoped @RequestScoped
...@@ -34,7 +37,8 @@ public class VotingDateValidator implements Serializable { ...@@ -34,7 +37,8 @@ public class VotingDateValidator implements Serializable {
//UIComponent foo = ui.findComponent("cStart"); //UIComponent foo = ui.findComponent("cStart");
//logger.info("uielement {} ", foo); //logger.info("uielement {} ", foo);
if(endDate.before(cStart)) { 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 { ...@@ -47,7 +51,7 @@ public class VotingDateValidator implements Serializable {
public void validateVote(FacesContext context, UIComponent ui, Object object) { public void validateVote(FacesContext context, UIComponent ui, Object object) {
Date endDate = (Date)object; Date endDate = (Date)object;
if(endDate.before(vStart)) { 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 { ...@@ -58,7 +62,7 @@ public class VotingDateValidator implements Serializable {
public void validateSubmit(FacesContext context, UIComponent ui, Object object) { public void validateSubmit(FacesContext context, UIComponent ui, Object object) {
Date endDate = (Date)object; Date endDate = (Date)object;
if(endDate.before(sStart)) { 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!