Commit 36cd54be by Juho Salli

Compocreate UI toimii

1 parent c1253309
......@@ -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;
......
......@@ -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!