Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
March 2012
- 3 participants
- 68 discussions
r3221 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/bean pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by fdesbois@users.chorem.org 30 Mar '12
by fdesbois@users.chorem.org 30 Mar '12
30 Mar '12
Author: fdesbois
Date: 2012-03-30 12:32:15 +0200 (Fri, 30 Mar 2012)
New Revision: 3221
Url: http://chorem.org/repositories/revision/pollen/3221
Log:
- resolve issue on create poll with choiceType date and image
- create ChoiceHelper
- improve AddChoice validation
Added:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/CreatePoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java 2012-03-30 10:32:15 UTC (rev 3221)
@@ -0,0 +1,59 @@
+package org.chorem.pollen.bean;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.common.ChoiceType;
+
+import java.util.Date;
+
+/**
+ * Created: 30/03/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public final class ChoiceHelper {
+
+ private ChoiceHelper() {
+ }
+
+ public static Object toValue(Choice choice, ChoiceType choiceType) {
+ Object result;
+ switch (choiceType) {
+ case DATE:
+ if (choice instanceof PollDateChoice) {
+ result = ((PollDateChoice)choice).getDate();
+ } else {
+ result = new Date(Long.parseLong(choice.getName()));
+ }
+ break;
+ case IMAGE:
+ if (choice instanceof PollImageChoice) {
+ result = ((PollImageChoice)choice).getLocation();
+ } else {
+ result = choice.getName();
+ }
+ break;
+ case TEXT:
+ default:
+ result = choice.getName();
+ }
+ return result;
+ }
+
+ public static Function<Choice, Object> toValue(final ChoiceType type) {
+ return new Function<Choice, Object>() {
+
+ @Override
+ public Object apply(Choice input) {
+ return toValue(input, type);
+ }
+ };
+ }
+
+ public static Iterable<Object> toValues(Iterable<Choice> choices,
+ ChoiceType choiceType) {
+ return Iterables.transform(choices, toValue(choiceType));
+ }
+
+}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-03-29 15:13:38 UTC (rev 3220)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-03-30 10:32:15 UTC (rev 3221)
@@ -23,17 +23,15 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import com.google.common.collect.Iterables;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.apache.commons.lang3.StringUtils;
-import org.chorem.pollen.bean.PollDateChoice;
-import org.chorem.pollen.bean.PollImageChoice;
+import org.chorem.pollen.bean.ChoiceHelper;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import java.util.Date;
-
/**
* To add a poll comment.
*
@@ -63,19 +61,26 @@
public void validate() {
ChoiceType choiceType = getPoll().getChoiceType();
- switch (choiceType) {
- case DATE:
- validateChoiceDate();
- break;
+ String typeKey = choiceType.name().toLowerCase();
+
+ Object value = ChoiceHelper.toValue(choice, choiceType);
- case IMAGE:
- validateChoiceImage();
- break;
+ // -- Validate value notEmpty
+ if (value == null || (value instanceof String && StringUtils.isBlank((String) value))) {
+ String typeLabel = getText(choiceType.getI18nKey());
+ addFieldError("choice." + typeKey,
+ _("pollen.error.choice.empty", typeLabel));
+ } else {
- case TEXT:
- default:
- validateChoice();
+ // Retrieve existing values to check if the new choice not already exists
+ Iterable<Object> pollChoiceValues = ChoiceHelper.toValues(getPoll().getChoice(), choiceType);
+
+ // -- Validate value notExists
+ if (Iterables.contains(pollChoiceValues, value)) {
+ addFieldError("choice." + typeKey,
+ _("pollen.error.poll.detected.duplicate.choice.name"));
+ }
}
}
@@ -88,25 +93,4 @@
return SUCCESS;
}
- protected void validateChoiceDate() {
- Date date = ((PollDateChoice) choice).getDate();
- if (date == null) {
- addFieldError("choice.date", _("pollen.error.choice.empty", _("pollen.common.choice.date")));
- }
- }
-
- protected void validateChoiceImage() {
- String location = ((PollImageChoice) choice).getLocation();
- if (StringUtils.isBlank(location)) {
- addFieldError("choice.image", _("pollen.error.choice.empty", _("pollen.common.choice.image")));
- }
- }
-
- protected void validateChoice() {
- String name = choice.getName();
- if (StringUtils.isBlank(name)) {
- addFieldError("choice.text", _("pollen.error.choice.empty", _("pollen.common.choice.text")));
- }
- }
-
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/CreatePoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/CreatePoll.java 2012-03-29 15:13:38 UTC (rev 3220)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/CreatePoll.java 2012-03-30 10:32:15 UTC (rev 3221)
@@ -34,6 +34,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ParameterAware;
+import org.chorem.pollen.bean.ChoiceHelper;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
import org.chorem.pollen.business.persistence.Choice;
@@ -333,6 +334,11 @@
tokenSuffix;
ChoiceType pollChoiceType = getPoll().getChoiceType();
+ if (pollChoiceType == null) {
+ // Retrieve choiceType from parameters, the poll object will be updated after prepare
+ String choiceTypeParam = getNonEmptyParameterValue("poll.choiceType");
+ pollChoiceType = ChoiceType.valueOf(choiceTypeParam);
+ }
if (log.isInfoEnabled()) {
log.info("choice type " + pollChoiceType);
@@ -387,19 +393,29 @@
addFieldError("poll.choices",
_("pollen.error.poll.required.one.choice"));
} else {
+//
+// //TODO tchemit improve this (from different cases text-date-image)
+// // check there is no choice with same name
+// boolean duplicateNameDetected = false;
+// Set<String> names = Sets.newHashSet();
+// for (Choice choice : orderedChoices.values()) {
+// String choiceName = choice.getName();
+// if (!names.add(choiceName)) {
+// duplicateNameDetected = true;
+// break;
+// }
+// }
+// if (duplicateNameDetected) {
+// addFieldError("poll.choices",
+// _("pollen.error.poll.detected.duplicate.choice.name"));
+// }
- //TODO tchemit improve this (from different cases text-date-image)
- // check there is no choice with same name
- boolean duplicateNameDetected = false;
- Set<String> names = Sets.newHashSet();
- for (Choice choice : orderedChoices.values()) {
- String choiceName = choice.getName();
- if (!names.add(choiceName)) {
- duplicateNameDetected = true;
- break;
- }
- }
- if (duplicateNameDetected) {
+ ChoiceType choiceType = poll.getChoiceType();
+ int inputChoicesSize = orderedChoices.size();
+ Set<Object> choiceValues =
+ Sets.newHashSet(ChoiceHelper.toValues(orderedChoices.values(), choiceType));
+
+ if (inputChoicesSize > choiceValues.size()) {
addFieldError("poll.choices",
_("pollen.error.poll.detected.duplicate.choice.name"));
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-29 15:13:38 UTC (rev 3220)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-30 10:32:15 UTC (rev 3221)
@@ -47,10 +47,9 @@
private static final long serialVersionUID = 1L;
@Override
- public String input() throws Exception {
+ public void prepare() throws Exception {
- //TODO DO me!
- return INPUT;
+ prepareVotePage();
}
@Override
@@ -117,10 +116,4 @@
}
return SUCCESS;
}
-
- @Override
- public void prepare() throws Exception {
-
- prepareVotePage();
- }
}
1
0
r3220 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 29 Mar '12
by fdesbois@users.chorem.org 29 Mar '12
29 Mar '12
Author: fdesbois
Date: 2012-03-29 17:13:38 +0200 (Thu, 29 Mar 2012)
New Revision: 3220
Url: http://chorem.org/repositories/revision/pollen/3220
Log:
- resolve issues with deleteChoice
- resolve issues with deleteComment
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-29 15:13:30 UTC (rev 3219)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-29 15:13:38 UTC (rev 3220)
@@ -647,6 +647,8 @@
}
ChoiceDAO dao = getDAO(Choice.class);
+
+ poll.removeChoice(choice);
delete(dao, choice);
commitTransaction("Could not delete choice " + choice.getName());
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-03-29 15:13:30 UTC (rev 3219)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-03-29 15:13:38 UTC (rev 3220)
@@ -64,7 +64,6 @@
service.deleteComment(commentId);
- resetCommentName();
return SUCCESS;
}
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp 2012-03-29 15:13:30 UTC (rev 3219)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp 2012-03-29 15:13:38 UTC (rev 3220)
@@ -28,7 +28,7 @@
<s:form method="POST" namespace="/poll" action="deleteChoice">
<s:hidden key="uriId" label=''/>
- <s:hidden key="choiceId" label=''/>
+ <s:hidden key="choiceId" value="%{choice.topiaId}" label=''/>
<s:text name="pollen.information.confirmDeletePollChoice">
<s:param>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-29 15:13:30 UTC (rev 3219)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-29 15:13:38 UTC (rev 3220)
@@ -199,7 +199,7 @@
</s:else>
<s:if test="pollChoiceRunning">
<s:if test="creatorUser">
- <s:a action="deleteChoice" namespace="/poll">
+ <s:a action="deleteChoice" namespace="/poll" onclick="return openDeleteChoiceDialog('%{#choice.topiaId}');">
<s:param name="choiceId"><s:property value="id"/></s:param>
<img src="<s:url value="/img/delete.png"/>"
title="<s:text name="pollen.action.deleteChoice"/>"
@@ -433,7 +433,7 @@
<!-- Ajout de choix -->
<s:if test="pollChoiceRunning">
<div id="choiceFormDiv">
- <s:form id="choiceForm" method="POST" namespace="/poll" validate="true">
+ <s:form id="choiceForm" method="POST" namespace="/poll">
<h4><s:text name="pollen.action.addChoice"/></h4>
<s:if test="textType">
<s:textfield key="choice.name"
1
0
r3219 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/config pollen-ui-struts2/src/main/resources/i18n pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 29 Mar '12
by fdesbois@users.chorem.org 29 Mar '12
29 Mar '12
Author: fdesbois
Date: 2012-03-29 17:13:30 +0200 (Thu, 29 Mar 2012)
New Revision: 3219
Url: http://chorem.org/repositories/revision/pollen/3219
Log:
- add AddChoice action (validation redirection failed)
- missing addChoiceAllowed flag save in createPoll
- resolve issue on AddComment (validation doesn't work)
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-29 15:13:30 UTC (rev 3219)
@@ -124,6 +124,7 @@
result.setAnonymous(poll.isAnonymous());
result.setAnonymousVoteAllowed(poll.isAnonymousVoteAllowed());
+ result.setChoiceAddAllowed(poll.isChoiceAddAllowed());
result.setBeginChoiceDate(poll.getBeginChoiceDate());
result.setBeginDate(poll.getBeginDate());
result.setChoiceType(poll.getChoiceType());
@@ -211,40 +212,42 @@
// create choices
- ChoiceType choiceType = result.getChoiceType();
-
- ChoiceDAO choiceDAO = getDAO(Choice.class);
-
+// ChoiceType choiceType = result.getChoiceType();
+//
+// ChoiceDAO choiceDAO = getDAO(Choice.class);
+//
for (Choice choice : poll.getChoice()) {
- Choice choiceCreated = create(choiceDAO);
- result.addChoice(choiceCreated);
-
- if (choiceType == ChoiceType.IMAGE) {
-
- // copy image where it belong and generate the thumb
-
- PollImageChoice imageChoice = (PollImageChoice) choice;
- imageChoice.toChoice(choiceCreated);
- try {
- saveImages(result, imageChoice);
- } catch (IOException e) {
- throw new PollenTechnicalException(
- "Could not create image choice", e);
- }
- } else if (choiceType == ChoiceType.DATE) {
-
- // date choice
-
- PollDateChoice dateChoice = (PollDateChoice) choice;
- dateChoice.toChoice(choiceCreated);
- } else {
-
- // text choice
- choiceCreated.setDescription(choice.getDescription());
- choiceCreated.setValidate(choice.isValidate());
- choiceCreated.setName(choice.getName());
- }
+ addChoice(result, choice);
+//
+// Choice choiceCreated = create(choiceDAO);
+// result.addChoice(choiceCreated);
+//
+// if (choiceType == ChoiceType.IMAGE) {
+//
+// // copy image where it belong and generate the thumb
+//
+// PollImageChoice imageChoice = (PollImageChoice) choice;
+// imageChoice.toChoice(choiceCreated);
+// try {
+// saveImages(result, imageChoice);
+// } catch (IOException e) {
+// throw new PollenTechnicalException(
+// "Could not create image choice", e);
+// }
+// } else if (choiceType == ChoiceType.DATE) {
+//
+// // date choice
+//
+// PollDateChoice dateChoice = (PollDateChoice) choice;
+// dateChoice.toChoice(choiceCreated);
+// } else {
+//
+// // text choice
+// choiceCreated.setDescription(choice.getDescription());
+// choiceCreated.setValidate(choice.isValidate());
+// choiceCreated.setName(choice.getName());
+// }
}
}
@@ -556,7 +559,79 @@
commitTransaction("Could not close poll " + poll.getTitle());
}
+
+ public Choice getNewChoice(ChoiceType choiceType) {
+ Choice result;
+ switch (choiceType) {
+
+ case DATE:
+ result = new PollDateChoice();
+ break;
+
+ case IMAGE:
+ result = new PollImageChoice();
+ break;
+
+ case TEXT:
+ default:
+ ChoiceDAO dao = getDAO(Choice.class);
+ result = newInstance(dao);
+ }
+ return result;
+ }
+
+ public void createChoice(String pollId, Choice choice) throws PollNotFoundException {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(choice);
+
+ Poll poll = getPollByPollId(pollId);
+
+ if (poll == null) {
+ throw new PollNotFoundException();
+ }
+
+ addChoice(poll, choice);
+
+ commitTransaction("Can't create new choice [" + poll.getChoiceType() + "] for poll '" + pollId + "'");
+ }
+
+ protected void addChoice(Poll poll, Choice choice) {
+
+ ChoiceType choiceType = poll.getChoiceType();
+ ChoiceDAO dao = getDAO(Choice.class);
+ Choice choiceCreated = create(dao);
+ poll.addChoice(choiceCreated);
+ if (choiceType == ChoiceType.IMAGE) {
+
+ // copy image where it belong and generate the thumb
+
+ PollImageChoice imageChoice = (PollImageChoice) choice;
+ imageChoice.toChoice(choiceCreated);
+ try {
+ saveImages(poll, imageChoice);
+ } catch (IOException e) {
+ throw new PollenTechnicalException(
+ "Could not create image choice", e);
+ }
+
+ } else if (choiceType == ChoiceType.DATE) {
+
+ // date choice
+
+ PollDateChoice dateChoice = (PollDateChoice) choice;
+ dateChoice.toChoice(choiceCreated);
+
+ } else {
+
+ // text choice
+ choiceCreated.setDescription(choice.getDescription());
+ choiceCreated.setValidate(choice.isValidate());
+ choiceCreated.setName(choice.getName());
+ }
+ }
+
public void deleteChoice(String pollId, String choiceId)
throws PollNotFoundException, PollChoiceNotFoundException {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-29 15:13:30 UTC (rev 3219)
@@ -262,9 +262,6 @@
public void prepareVotePage() throws Exception {
- // Ensure uri for poll and pollAccount loading
- preparePollUri(parameters);
-
loadPoll();
setDateFormat(DateFormat.getDateTimeInstance(
@@ -374,6 +371,9 @@
}
protected void loadPoll() throws PollNotFoundException {
+
+ // Ensure uri for poll and pollAccount loading
+ preparePollUri(parameters);
String pollId = getPollId();
if (StringUtils.isNotEmpty(pollId)) {
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-03-29 15:13:30 UTC (rev 3219)
@@ -0,0 +1,112 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.actions.poll;
+
+import com.opensymphony.xwork2.Preparable;
+import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
+import org.apache.commons.lang3.StringUtils;
+import org.chorem.pollen.bean.PollDateChoice;
+import org.chorem.pollen.bean.PollImageChoice;
+import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.common.ChoiceType;
+import org.chorem.pollen.services.exceptions.PollNotFoundException;
+
+import java.util.Date;
+
+/**
+ * To add a poll comment.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2.6
+ */
+public class AddChoice extends AbstractVoteAction implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Choice choice;
+
+ public Choice getChoice() {
+ return choice;
+ }
+
+ @Override
+ public void prepare() throws PollNotFoundException {
+
+ loadPoll();
+
+ ChoiceType choiceType = getPoll().getChoiceType();
+ choice = getPollService().getNewChoice(choiceType);
+ }
+
+ @Override
+ public void validate() {
+
+ ChoiceType choiceType = getPoll().getChoiceType();
+ switch (choiceType) {
+
+ case DATE:
+ validateChoiceDate();
+ break;
+
+ case IMAGE:
+ validateChoiceImage();
+ break;
+
+ case TEXT:
+ default:
+ validateChoice();
+ }
+ }
+
+ @InputConfig(methodName = "prepareVotePage")
+ @Override
+ public String execute() throws Exception {
+
+ getPollService().createChoice(getPollId(), choice);
+
+ return SUCCESS;
+ }
+
+ protected void validateChoiceDate() {
+ Date date = ((PollDateChoice) choice).getDate();
+ if (date == null) {
+ addFieldError("choice.date", _("pollen.error.choice.empty", _("pollen.common.choice.date")));
+ }
+ }
+
+ protected void validateChoiceImage() {
+ String location = ((PollImageChoice) choice).getLocation();
+ if (StringUtils.isBlank(location)) {
+ addFieldError("choice.image", _("pollen.error.choice.empty", _("pollen.common.choice.image")));
+ }
+ }
+
+ protected void validateChoice() {
+ String name = choice.getName();
+ if (StringUtils.isBlank(name)) {
+ addFieldError("choice.text", _("pollen.error.choice.empty", _("pollen.common.choice.text")));
+ }
+ }
+
+}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-03-29 15:13:30 UTC (rev 3219)
@@ -71,7 +71,6 @@
// create the comment
service.createComment(getPoll(), comment);
- resetCommentName();
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-29 15:13:30 UTC (rev 3219)
@@ -97,21 +97,6 @@
<result>/WEB-INF/jsp/poll/resume.jsp</result>
</action>
- <!-- vote poll -->
- <action name="vote/*" method="execute"
- class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
- <param name="uriId">{1}</param>
- <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
- <result type="redirectToVote"/>
- </action>
-
- <!-- vote poll (input) -->
- <action name="votefor/*" method="input"
- class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
- <param name="uriId">{1}</param>
- <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
- </action>
-
<!-- confirm clone poll -->
<action name="confirmClonePoll/*"
class="org.chorem.pollen.ui.actions.poll.ConfirmPollAction">
@@ -182,9 +167,33 @@
<result>/WEB-INF/jsp/poll/confirmDeletePollComment.jsp</result>
</action>
+ <!-- vote poll -->
+ <action name="vote/*" method="execute"
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ <result type="redirectToVote"/>
+ </action>
+
+ <!-- vote poll (input) -->
+ <action name="votefor/*" method="input"
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ </action>
+
+ <!-- add a choice -->
+ <action name="addChoice/*"
+ class="org.chorem.pollen.ui.actions.poll.AddChoice">
+ <param name="uriId">{1}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ <result type="redirectToVote"/>
+ </action>
+
<!-- add a poll comment -->
- <action name="addComment"
+ <action name="addComment/*"
class="org.chorem.pollen.ui.actions.poll.AddComment">
+ <param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
<result type="redirectToVote"/>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-29 15:13:30 UTC (rev 3219)
@@ -50,6 +50,9 @@
pollen.common.chartType-pie3d=Pie 3D
pollen.common.chartType-ring=Ring
pollen.common.choice=Choice
+pollen.common.choice.date=Date
+pollen.common.choice.image=Image
+pollen.common.choice.text=Label
pollen.common.commentName=Name
pollen.common.commentText=Comment
pollen.common.comments=Comments about this poll
@@ -116,6 +119,7 @@
pollen.common.votingList=Group
pollen.common.weight=Weight
pollen.error.accountNotFound=
+pollen.error.choice.empty=%s mandatory
pollen.error.comment.name.empty=Comment name mandatory
pollen.error.comment.text.empty=Comment text mandatory
pollen.error.email.required=You must provide an email
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-29 15:13:30 UTC (rev 3219)
@@ -55,6 +55,9 @@
pollen.common.chartType-pie3d=Camembert 3D
pollen.common.chartType-ring=Anneau
pollen.common.choice=Choix
+pollen.common.choice.date=Date
+pollen.common.choice.image=Image
+pollen.common.choice.text=Libellé
pollen.common.commentName=Nom
pollen.common.commentText=Commentaire
pollen.common.comments=Commentaire à propos du sondage
@@ -123,6 +126,7 @@
pollen.common.weight=Poids
pollen.common.x=Dépouillement
pollen.error.accountNotFound=
+pollen.error.choice.empty=%s obligatoire
pollen.error.comment.name.empty=Nom du commentaire obligatoire
pollen.error.comment.text.empty=Texte du commentaire obligatoire
pollen.error.email.required=Courriel obligatoire
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:40:09 UTC (rev 3218)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-29 15:13:30 UTC (rev 3219)
@@ -423,14 +423,51 @@
<%--<t:label for="anonymousVote"/>--%>
<br/>
</s:if>
- <s:submit action="vote/%{uriId}" key="pollen.action.pollVote"/>
+ <s:submit action="vote/%{uriId}" key="pollen.action.pollVote" align="center"/>
<%--<input id="submitVote" t:type="Submit" t:value="${message:submitVote}"/>--%>
</div>
</s:if>
</s:form>
</div>
+
+<!-- Ajout de choix -->
+<s:if test="pollChoiceRunning">
+ <div id="choiceFormDiv">
+ <s:form id="choiceForm" method="POST" namespace="/poll" validate="true">
+ <h4><s:text name="pollen.action.addChoice"/></h4>
+ <s:if test="textType">
+ <s:textfield key="choice.name"
+ label="%{getText('pollen.common.choice')}"
+ required="true"/>
+ </s:if>
+ <s:if test="dateType">
+ <s:label id="choice.date-label" for="choice.date" key="pollen.common.choice" theme="simple"/>
+ <br/>
+ <s:fielderror fieldName="choice.date"/>
+ <br/>
+ <sj:datepicker id="choice.date" name="choice.date" changeMonth="true"
+ changeYear="true" labelSeparator="" theme="simple" label=""
+ timepicker="true" displayFormat="dd/mm/yy" required="true"/>
+ <br/>
+ </s:if>
+ <s:if test="imageType">
+ <s:label id="choice.location-label" for="choice.location" key="pollen.common.choice" theme="simple"/>
+ <br/>
+ <s:fielderror fieldName="choice.location"/>
+ <br/>
+ <s:file id="choice.location" name="" label="choice.location" theme="simple" cssClass="nameField" required="true"/>
+ <br/>
+ </s:if>
+ <br/>
+ <s:textarea cols="30" key="choice.description"
+ label="%{getText('pollen.common.description')}"/>
+ <br/>
+ <s:submit action="addChoice/%{uriId}" key="pollen.action.addChoice" align="center"/>
+ </s:form>
+ </div>
+</s:if>
+
<!-- Ajout de commentaires -->
-
<h3><s:text name="pollen.common.comments"/></h3>
<div id="commentZone">
@@ -497,16 +534,15 @@
<div id="commentFormDiv">
- <s:form id='addCommentForm' method="POST" namespace="/poll">
- <s:hidden key="uriId" label=''/>
+ <s:form id='addCommentForm' method="POST" namespace="/poll" validate="true">
<s:textfield key="commentName" required="true" size="78"
label="%{getText('pollen.common.commentName')}"/>
<s:textarea key="commentText" required="true" value=''
label="%{getText('pollen.common.commentText')}"/>
<div class="cleanBoth">
- <s:submit action="addComment" key="pollen.action.addComment"
- align="left"/>
+ <s:submit action="addComment/%{uriId}" key="pollen.action.addComment"
+ align="center"/>
</div>
</s:form>
1
0
r3218 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 28 Mar '12
by fdesbois@users.chorem.org 28 Mar '12
28 Mar '12
Author: fdesbois
Date: 2012-03-28 18:40:09 +0200 (Wed, 28 Mar 2012)
New Revision: 3218
Url: http://chorem.org/repositories/revision/pollen/3218
Log:
add voteAllowed check for restricted poll
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 16:40:01 UTC (rev 3217)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 16:40:09 UTC (rev 3218)
@@ -169,16 +169,12 @@
// -- PollAccount -- //
PollAccount pollAccount = vote.getPollAccount();
String pollAccountId = pollAccount.getTopiaId();
- PollAccount pollAccountLoaded = null;
+ PollAccount pollAccountLoaded;
// Load existing account (restricted poll)
if (pollAccountId != null) {
pollAccountLoaded = getEntityById(PollAccount.class, pollAccountId);
- if (pollAccountLoaded == null) {
- throw new PollAccountNotFound();
- }
-
// Create new account
} else {
PollAccountDAO pollAccountDAO = getDAO(PollAccount.class);
@@ -354,6 +350,36 @@
throw new PollenTechnicalException("Could not obtain votes", e);
}
}
+
+ /**
+ * Vote is allowed if {@code poll} is running and {@code pollAccount} is
+ * defined in the {@code poll} restricted list if it's not a {@link PollType#FREE}
+ * poll. The account must be defined previously using
+ * {@link PollService#getPollAccountEditable(String, UserAccount, Poll)} to
+ * have a proper link between userAccount and pollAccount even if not already
+ * created in dabase.
+ *
+ * @param poll Poll
+ * @param accountEditable Account to check
+ * @return true if vote is allowed, false otherwise
+ */
+ public boolean isVoteAllowed(Poll poll, PollAccount accountEditable) {
+
+ Preconditions.checkNotNull(poll);
+ Preconditions.checkNotNull(accountEditable);
+
+ Date now = serviceContext.getCurrentTime();
+
+ boolean result = poll.isRunning(now);
+ if (poll.getPollType() != PollType.FREE) {
+
+ PersonToListDAO personToListDAO = getDAO(PersonToList.class);
+ PersonToList personToList = personToListDAO.findByPollAndAccount(poll, accountEditable);
+
+ result &= personToList != null;
+ }
+ return result;
+ }
public boolean isUpdateAllowed(Poll poll, String voteId, String accountId, UserAccount userConnected) {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 16:40:01 UTC (rev 3217)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 16:40:09 UTC (rev 3218)
@@ -186,11 +186,6 @@
return poll.isAddChoiceRunning(now);
}
- public boolean isPollRunning() {
- Date now = serviceContext.getCurrentTime();
- return poll.isRunning(now);
- }
-
public String getCreatorName() {
return poll.getCreator().getVotingId();
}
@@ -320,9 +315,10 @@
resetCommentName();
if (log.isInfoEnabled()) {
+ Date now = serviceContext.getCurrentTime();
log.info("pollChoiceOrVoteStarted = " + isPollChoiceOrVoteStarted());
log.info("pollChoiceRunning = " + isPollChoiceRunning());
- log.info("pollRunning = " + isPollRunning());
+ log.info("pollRunning = " + poll.isRunning(now));
log.info("accountFieldDisplayed = " + isAccountFieldDisplayed());
log.info("creatorUser = " + creatorUser);
}
@@ -365,6 +361,10 @@
return getVoteService().isUpdateAllowed(getPoll(), voteId, getAccountId(), getPollenUserAccount());
}
+ public boolean isVoteAllowed() {
+ return getVoteService().isVoteAllowed(getPoll(), getPollAccount());
+ }
+
public String escapeLineBreak(String text) {
return text;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:40:01 UTC (rev 3217)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:40:09 UTC (rev 3218)
@@ -264,7 +264,7 @@
</s:if>
</tr>
</thead>
-<s:if test="pollRunning">
+<s:if test="voteAllowed">
<tfoot>
<tr>
<s:if test="accountFieldDisplayed">
@@ -416,7 +416,7 @@
<%--<t:errors/>--%>
</div>
-<s:if test="pollRunning">
+<s:if test="voteAllowed">
<div id="buttons">
<s:if test="poll.anonymousVoteAllowed">
<s:checkbox key="vote.anonymous"/>
1
0
r3217 - in branches/pollen-1.2.6-struts2: pollen-persistence/src/main/java/org/chorem/pollen/business/persistence pollen-services/src/main/java/org/chorem/pollen/services/impl
by fdesbois@users.chorem.org 28 Mar '12
by fdesbois@users.chorem.org 28 Mar '12
28 Mar '12
Author: fdesbois
Date: 2012-03-28 18:40:01 +0200 (Wed, 28 Mar 2012)
New Revision: 3217
Url: http://chorem.org/repositories/revision/pollen/3217
Log:
- resolve issue on personToList creation (missing votingList reference)
- manage weight on restricted poll
Added:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java
Modified:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
Added: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java 2012-03-28 16:40:01 UTC (rev 3217)
@@ -0,0 +1,34 @@
+package org.chorem.pollen.business.persistence;
+
+import java.util.List;
+
+/**
+ * Created: 28/03/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ * $Id$
+ */
+public class PersonToListDAOImpl<E extends PersonToList> extends PersonToListDAOAbstract<E> {
+
+ public PersonToList findByPollAndAccount(Poll poll, PollAccount account) {
+
+// TopiaQuery query = createQuery("e")
+// .addFrom(Poll.class, "p")
+// .addFrom(VotingList.class, "v")
+// .addEquals("p", poll)
+// .addInElements("v", "p." + Poll.PROPERTY_VOTING_LIST)
+// .addWhere("e." + PersonToList.PROPERTY_VOTING_LIST + " = v." + VotingList.PROPERTY_POLL_ACCOUNT_PERSON_TO_LIST)
+// .addEquals("e." + PersonToList.PROPERTY_POLL_ACCOUNT, account);
+
+ PersonToList result;
+ List<VotingList> votingLists = poll.getVotingList();
+ for (VotingList votingList : votingLists) {
+ result = votingList.getPollAccountPersonToList(account);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+}
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-03-28 16:39:54 UTC (rev 3216)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-03-28 16:40:01 UTC (rev 3217)
@@ -107,6 +107,7 @@
TopiaQuery query = createQuery("e")
.addFrom(Poll.class, "p")
.addFrom(Vote.class, "v")
+ .addEquals("p", poll)
.addInElements("v", "p." + Poll.PROPERTY_VOTE)
.addWhere("e = v." + Vote.PROPERTY_POLL_ACCOUNT)
.addEquals("e." + PollAccount.PROPERTY_USER_ACCOUNT, user);
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 16:39:54 UTC (rev 3216)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 16:40:01 UTC (rev 3217)
@@ -188,7 +188,6 @@
PersonToList personToListCreated = create(personToListDAO);
personToListCreated.setHasVoted(personToList.isHasVoted());
personToListCreated.setWeight(personToList.getWeight());
- votingListCreated.addPollAccountPersonToList(personToListCreated);
PollAccount pollAccount = personToList.getPollAccount();
PollAccount pollAccountCreated = create(pollAccountDAO);
@@ -198,6 +197,10 @@
pollAccountCreated.setVotingId(pollAccount.getVotingId());
personToListCreated.setPollAccount(pollAccountCreated);
+
+ // The model doesn't have any composition for this relation, the link must be set in both objects
+ personToListCreated.setVotingList(votingListCreated);
+ votingListCreated.addPollAccountPersonToList(personToListCreated);
}
}
result.addVotingList(votingListCreated);
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 16:39:54 UTC (rev 3216)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 16:40:01 UTC (rev 3217)
@@ -31,6 +31,8 @@
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.PersonToList;
+import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountDAO;
@@ -43,6 +45,7 @@
import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.entities.PollenDAOHelper;
import org.chorem.pollen.services.PollenServiceSupport;
+import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.VoteNotFoundException;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -67,7 +70,6 @@
Vote result = newInstance(voteDAO);
result.setPollAccount(account);
- // TODO weight ?
result.setWeight(1.);
// Prepare the List of VoteToChoice with Poll's choices
@@ -126,6 +128,12 @@
} else {
result = getNewVote(poll, accountEditable);
}
+
+ if (poll.getPollType() != PollType.FREE && accountEditable.getTopiaId() != null) {
+ PersonToListDAO personToListDAO = getDAO(PersonToList.class);
+ PersonToList personToList = personToListDAO.findByPollAndAccount(poll, accountEditable);
+ result.setWeight(personToList.getWeight());
+ }
return result;
}
@@ -150,7 +158,7 @@
return result;
}
- public Vote createVote(Vote vote) {
+ public Vote createVote(Vote vote) throws PollAccountNotFound {
VoteDAO voteDAO = getDAO(Vote.class);
@@ -163,14 +171,16 @@
String pollAccountId = pollAccount.getTopiaId();
PollAccount pollAccountLoaded = null;
- // Load existing account only if not anonymous, otherwise a new pollAccount must be created
- if (pollAccountId != null && !vote.isAnonymous()) {
+ // Load existing account (restricted poll)
+ if (pollAccountId != null) {
pollAccountLoaded = getEntityById(PollAccount.class, pollAccountId);
- }
+
+ if (pollAccountLoaded == null) {
+ throw new PollAccountNotFound();
+ }
- // Create the new PollAccount
- if (pollAccountLoaded == null) {
-
+ // Create new account
+ } else {
PollAccountDAO pollAccountDAO = getDAO(PollAccount.class);
pollAccountLoaded = create(pollAccountDAO);
pollAccountLoaded.setAccountId(pollAccount.getAccountId());
@@ -188,6 +198,7 @@
pollAccountLoaded.setUserAccount(userAccountLoaded);
}
}
+ // TODO Manage anonymous for existing account ??? problem with restricted and email
result.setPollAccount(pollAccountLoaded);
// -- List of VoteToChoice -- //
1
0
r3216 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll resources/i18n webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 28 Mar '12
by fdesbois@users.chorem.org 28 Mar '12
28 Mar '12
Author: fdesbois
Date: 2012-03-28 18:39:54 +0200 (Wed, 28 Mar 2012)
New Revision: 3216
Url: http://chorem.org/repositories/revision/pollen/3216
Log:
- Add anonymous checkbox
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-28 16:39:46 UTC (rev 3215)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-28 16:39:54 UTC (rev 3216)
@@ -64,15 +64,18 @@
Poll poll = getPoll();
- String name = pollAccount.getVotingId();
- if (StringUtils.isBlank(name)) {
- addFieldError("pollAccount.votingId", _("pollen.error.pollAccount.votingId.required"));
- }
+ if (!vote.isAnonymous()) {
- // check if the new pollAccount (topiaId = null) has already voted
- if (pollAccount.getTopiaId() == null && getVoteService().hasAlreadyVoted(name, poll)) {
- addFieldError("pollAccount.votingId", _("pollen.error.user.alreadyVoted"));
- }
+ String name = pollAccount.getVotingId();
+ if (StringUtils.isBlank(name)) {
+ addFieldError("pollAccount.votingId", _("pollen.error.pollAccount.votingId.required"));
+ }
+
+ // check if the new pollAccount (topiaId = null) has already voted
+ if (pollAccount.getTopiaId() == null && getVoteService().hasAlreadyVoted(name, poll)) {
+ addFieldError("pollAccount.votingId", _("pollen.error.user.alreadyVoted"));
+ }
+ }
}
@Override
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-28 16:39:46 UTC (rev 3215)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-03-28 16:39:54 UTC (rev 3216)
@@ -236,3 +236,4 @@
pollen.title.selectPersonListToAddVotingList=Select a voter list to import in voting list
pollen.title.selectPersonListToCreateVotingList=Select a favorite list to import in a new voting list
pollen.title.usersList=Users administration
+vote.anonymous=Anonymous vote
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-28 16:39:46 UTC (rev 3215)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-03-28 16:39:54 UTC (rev 3216)
@@ -246,3 +246,4 @@
pollen.title.selectPersonListToCreateVotingList=Sélectionner une liste de votants pour créer un nouveau groupe
pollen.title.usersList=Gestion des utilisateurs
title=Création d'un sondage
+vote.anonymous=Vote anonyme
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:39:46 UTC (rev 3215)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:39:54 UTC (rev 3216)
@@ -86,7 +86,18 @@
}
jQuery(document).ready(function () {
+
$('#poll tr:even').addClass('even');
+
+ var $anonymousField = $('#voteForm [name="vote.anonymous"]');
+ var $votingIdField = $('#voteForm [name="pollAccount.votingId"]');
+
+ $votingIdField.attr('disabled', $anonymousField.prop('checked'));
+
+ $anonymousField.change(function() {
+ $votingIdField.attr('disabled', $(this).prop('checked'));
+ });
+
});
@@ -407,8 +418,8 @@
<s:if test="pollRunning">
<div id="buttons">
- <s:if test="anonymousVoteDisplayed">
- <s:checkbox id="anonymousVote" value="anonymousVote"/>
+ <s:if test="poll.anonymousVoteAllowed">
+ <s:checkbox key="vote.anonymous"/>
<%--<t:label for="anonymousVote"/>--%>
<br/>
</s:if>
1
0
r3215 - in branches/pollen-1.2.6-struts2: pollen-persistence/src/main/java/org/chorem/pollen/business/persistence pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/config pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 28 Mar '12
by fdesbois@users.chorem.org 28 Mar '12
28 Mar '12
Author: fdesbois
Date: 2012-03-28 18:39:46 +0200 (Wed, 28 Mar 2012)
New Revision: 3215
Url: http://chorem.org/repositories/revision/pollen/3215
Log:
- improve binding pollAccount and userAccount
- use copy of bean for edition
- add validation
Modified:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollAccountDAOImpl.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -97,5 +97,38 @@
return pollAccountExists;
}
+
+ public PollAccount findByPollVoteUser(Poll poll,
+ UserAccount user) throws TopiaException {
+
+ Preconditions.checkNotNull(poll);
+ Preconditions.checkNotNull(user);
+
+ TopiaQuery query = createQuery("e")
+ .addFrom(Poll.class, "p")
+ .addFrom(Vote.class, "v")
+ .addInElements("v", "p." + Poll.PROPERTY_VOTE)
+ .addWhere("e = v." + Vote.PROPERTY_POLL_ACCOUNT)
+ .addEquals("e." + PollAccount.PROPERTY_USER_ACCOUNT, user);
+ PollAccount result = findByQuery(query);
+ return result;
+ }
+ public boolean existsByPollVoteAccountId(String pollId,
+ String accountId) throws TopiaException {
+
+ Preconditions.checkNotNull(pollId);
+ Preconditions.checkNotNull(accountId);
+
+ TopiaQuery query = createQuery("e")
+ .addFrom(Poll.class, "p")
+ .addFrom(Vote.class, "v")
+ .addEquals("p." + Poll.PROPERTY_POLL_ID, pollId)
+ .addInElements("v", "p." + Poll.PROPERTY_VOTE)
+ .addWhere("e = v." + Vote.PROPERTY_POLL_ACCOUNT)
+ .addEquals("e." + PollAccount.PROPERTY_ACCOUNT_ID, accountId);
+ boolean result = existByQuery(query);
+ return result;
+ }
+
} //PollAccountDAOImpl<E extends PollAccount>
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/VoteDAOImpl.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -112,4 +112,16 @@
// result = count > 0;
}
+
+ public Vote findByAccountId(String accountId) throws TopiaException {
+
+ String accountIdProperty =
+ TopiaQuery.getProperty("e", Vote.PROPERTY_POLL_ACCOUNT, PollAccount.PROPERTY_ACCOUNT_ID);
+
+ TopiaQuery query = createQuery("e").addEquals(accountIdProperty, accountId);
+ Vote result = findByQuery(query);
+ return result;
+ }
+
+
} //VoteDAOImpl<E extends Vote>
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -49,6 +49,7 @@
import org.chorem.pollen.business.persistence.VotingListDAO;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollChoiceNotFoundException;
@@ -378,7 +379,7 @@
Poll result = dao.findByPollId(pollId);
return result;
} catch (TopiaException e) {
- throw new PollenTechnicalException("Could not find poll with pollId " + pollId);
+ throw new PollenTechnicalException("Could not find poll with pollId '" + pollId + "'", e);
}
}
@@ -386,23 +387,23 @@
* Retrieve a pollAccount with {@code accountId}. This pollAccount will be
* attached to the given {@code userAccount} (only if not already attached).
* If the {@code accountId} is undefined, a new instance of PollAccount will
- * be retrieved, otherwise the existing PollAccount is used. No create or
- * update is done here.
+ * be retrieved, otherwise a copy of the existing PollAccount is used. No
+ * create or update is done here. The {@code poll} is used to retrieve a potential
+ * existing vote with pollAccount linked to {@code userAccount}.
*
* @param accountId Id of the existing account (optional)
* @param userAccount UserAccount where account will be attached (optional)
+ * @param poll Poll where pollAccount will be added
* @return the existing PollAccount or a new instance
* @throws PollAccountNotFound if accountId is defined and doesn't match any
* existing PollAccount
*/
- public PollAccount getPollAccount(String accountId, UserAccount userAccount) throws PollAccountNotFound {
- PollAccount result;
+ public PollAccount getPollAccountEditable(String accountId, UserAccount userAccount, Poll poll) throws PollAccountNotFound {
+ PollAccount result = null;
if (StringUtils.isNotEmpty(accountId)) {
- result = getPollAccountByAccountId(accountId);
+ PollAccount pollAccountLoaded = getPollAccountByAccountId(accountId);
- // REMARQUES :
- // - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
- // - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
+ result = copyPollAccount(pollAccountLoaded);
// Don't remove or update userAccount link if already set
if (userAccount != null && result.getUserAccount() == null) {
@@ -418,10 +419,47 @@
}
} else {
- result = getNewPollAccount(userAccount);
+
+ // Retrieve existing pollAccount from user
+ if (userAccount != null) {
+ PollAccountDAO pollAccountDAO = getDAO(PollAccount.class);
+ PollAccount pollAccountLoaded;
+ try {
+ pollAccountLoaded = pollAccountDAO.findByPollVoteUser(poll, userAccount);
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(e);
+ }
+
+ if (pollAccountLoaded != null) {
+ result = copyPollAccount(pollAccountLoaded);
+ }
+
+ if (log.isDebugEnabled()) {
+ String account = result == null
+ ? "null"
+ : result.getVotingId() + " [" + result.getAccountId() + "]";
+
+ log.debug(String.format(
+ "PollAccount found from user '%s' = %s",
+ userAccount.getDisplayName(), account
+ ));
+ }
+ }
+
+ if (result == null) {
+ result = getNewPollAccount(userAccount);
+ }
}
return result;
}
+
+ protected PollAccount copyPollAccount(PollAccount source) {
+ PollAccountDAO dao = getDAO(PollAccount.class);
+ PollAccount result = newInstance(dao);
+ PollenBinderHelper.copy("", source, result, true);
+ result.setUserAccount(source.getUserAccount());
+ return result;
+ }
public PollAccount getNewPollAccount(UserAccount userAccount) {
PollAccountDAO dao = getDAO(PollAccount.class);
@@ -557,6 +595,8 @@
if (poll == null) {
throw new PollNotFoundException();
}
+
+ PollAccountDAO dao = getDAO(PollAccount.class);
if (poll.getPollType() != PollType.FREE) {
@@ -564,7 +604,6 @@
// Use PersonToList association entity to find coherence between
// the poll and votingId
- PollAccountDAO dao = getDAO(PollAccount.class);
try {
PollAccount result =
@@ -577,6 +616,19 @@
throw new PollenTechnicalException(
"Could not obtain restricted pollAccount", e);
}
+
+ } else if (accountId != null) {
+
+ try {
+
+ if (!dao.existsByPollVoteAccountId(pollId, accountId)) {
+ throw new UnauthorizedPollAccessException();
+ }
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not check pollAccount existence from poll '" +
+ pollId + "' and account '" + accountId + "'", e);
+ }
}
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -24,9 +24,7 @@
package org.chorem.pollen.services.impl;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,6 +40,7 @@
import org.chorem.pollen.business.persistence.VoteToChoice;
import org.chorem.pollen.business.persistence.VoteToChoiceDAO;
import org.chorem.pollen.common.PollType;
+import org.chorem.pollen.entities.PollenBinderHelper;
import org.chorem.pollen.entities.PollenDAOHelper;
import org.chorem.pollen.services.PollenServiceSupport;
import org.chorem.pollen.services.exceptions.VoteNotFoundException;
@@ -68,6 +67,8 @@
Vote result = newInstance(voteDAO);
result.setPollAccount(account);
+ // TODO weight ?
+ result.setWeight(1.);
// Prepare the List of VoteToChoice with Poll's choices
for (Choice choice : poll.getChoice()) {
@@ -75,53 +76,65 @@
element.setChoice(choice);
result.addChoiceVoteToChoice(element);
}
-
- // TODO weight ?
return result;
}
- public Vote getVote(Poll poll, List<Vote> votes, final PollAccount account) {
+ public Vote getVoteEditable(Poll poll, PollAccount accountEditable) {
Preconditions.checkNotNull(poll);
- Preconditions.checkNotNull(votes);
- Preconditions.checkNotNull(account);
+ Preconditions.checkNotNull(accountEditable);
- Vote result = Iterables.find(votes, new Predicate<Vote>() {
-
- @Override
- public boolean apply(Vote input) {
- return account.equals(input.getPollAccount());
- }
+ VoteDAO dao = getDAO(Vote.class);
+ Vote voteLoaded;
+ try {
+ voteLoaded = dao.findByAccountId(accountEditable.getAccountId());
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(e);
+ }
+
+ Vote result;
+ if (voteLoaded != null) {
+ result = copyVote(voteLoaded);
- }, getNewVote(poll, account));
+ // Attach the given accountEditable instead of the loaded one
+ result.setPollAccount(accountEditable);
-
- // For an existing Vote, ensure that there is as many voteToChoice as poll choices
- if (result.getTopiaId() != null) {
-
+ // For an existing Vote, ensure that there is as many voteToChoice as poll choices
VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class);
+ List<VoteToChoice> voteToChoices = Lists.newArrayList();
- List<VoteToChoice> voteToChoices = result.getChoiceVoteToChoice();
-
// Add all VoteToChoice even they have empty value to match the size of Poll Choice List
List<Choice> choices = poll.getChoice();
for (int i = 0; i < choices.size(); i++) {
Choice choice = choices.get(i);
- VoteToChoice voteToChoice = voteToChoices.get(i);
- // Add new VoteToChoice if choice doesn't match (not exists)
- if (!voteToChoice.getChoice().equals(choice)) {
- VoteToChoice element = newInstance(voteToChoiceDAO);
- element.setChoice(choice);
- voteToChoices.add(i, element);
+ VoteToChoice voteToChoice = newInstance(voteToChoiceDAO);
+ voteToChoice.setChoice(choice);
+
+ // Retrieve existing value from loaded vote
+ VoteToChoice voteToChoiceLoaded = voteLoaded.getChoiceVoteToChoice(choice);
+ if (voteToChoiceLoaded != null) {
+ voteToChoice.setVoteValue(voteToChoiceLoaded.getVoteValue());
}
+
+ voteToChoices.add(i, voteToChoice);
}
+ result.setChoiceVoteToChoice(voteToChoices);
+ } else {
+ result = getNewVote(poll, accountEditable);
}
return result;
}
+
+ protected Vote copyVote(Vote source) {
+ VoteDAO dao = getDAO(Vote.class);
+ Vote result = newInstance(dao);
+ PollenBinderHelper.copy("", source, result, true);
+ return result;
+ }
/**
* Retrieve the URL to update a vote based on {@link PollUri}.
@@ -140,7 +153,6 @@
public Vote createVote(Vote vote) {
VoteDAO voteDAO = getDAO(Vote.class);
- VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class);
Vote result = create(voteDAO);
result.setWeight(vote.getWeight());
@@ -183,17 +195,7 @@
Integer value = input.getVoteValue();
if (value != null) {
-
- VoteToChoice voteToChoiceCreated = create(voteToChoiceDAO);
- voteToChoiceCreated.setVoteValue(value);
-
- // Bind with existing Choice
- String choiceId = input.getChoice().getTopiaId();
- Choice choiceLoaded = getEntityById(Choice.class, choiceId);
- voteToChoiceCreated.setChoice(choiceLoaded);
- voteToChoiceCreated.setVote(result);
-
- result.addChoiceVoteToChoice(voteToChoiceCreated);
+ createVoteToChoice(result, input);
}
}
@@ -206,45 +208,82 @@
return result;
}
- public void updateVote(Vote vote) throws VoteNotFoundException {
+ public Vote updateVote(Vote vote) throws VoteNotFoundException {
- Vote entityToUpdate = getEntityById(Vote.class, vote.getTopiaId());
+ Vote result = getEntityById(Vote.class, vote.getTopiaId());
- if (entityToUpdate == null) {
+ if (result == null) {
throw new VoteNotFoundException();
}
- VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ // -- PollAccount -- //
+ PollAccount voteAccount = vote.getPollAccount();
+ PollAccount pollAccountEntity = result.getPollAccount();
+ if (vote.isAnonymous()) {
+ pollAccountEntity.setVotingId(null);
+ pollAccountEntity.setEmail(null);
+ pollAccountEntity.setUserAccount(null);
+ } else {
+ pollAccountEntity.setVotingId(voteAccount.getVotingId());
+ pollAccountEntity.setEmail(voteAccount.getEmail());
+ pollAccountEntity.setUserAccount(voteAccount.getUserAccount());
+ }
+ result.setAnonymous(vote.isAnonymous());
+
+ // -- List of VoteToChoice -- //
for (VoteToChoice input : vote.getChoiceVoteToChoice()) {
Integer value = input.getVoteValue();
- VoteToChoice voteToChoiceEntity = entityToUpdate.getChoiceVoteToChoice(input.getChoice());
+ VoteToChoice voteToChoiceEntity = result.getChoiceVoteToChoice(input.getChoice());
if (value != null) {
- if (voteToChoiceEntity == null) {
- voteToChoiceEntity = create(voteToChoiceDao);
- voteToChoiceEntity.setChoice(input.getChoice()); // very dangerous, bind with id
- entityToUpdate.addChoiceVoteToChoice(voteToChoiceEntity);
+ if (voteToChoiceEntity != null) {
+ voteToChoiceEntity.setVoteValue(value);
+
+ } else {
+ createVoteToChoice(result, input);
}
- voteToChoiceEntity.setVoteValue(value);
- // update needed ??
} else if (voteToChoiceEntity != null) {
-
- entityToUpdate.removeChoiceVoteToChoice(voteToChoiceEntity);
- delete(voteToChoiceDao, voteToChoiceEntity);
+ deleteVoteToChoice(result, voteToChoiceEntity);
}
}
if (log.isDebugEnabled()) {
- log.debug("Entity updated: " + vote.getTopiaId());
+ log.debug("Entity updated: " + result.getTopiaId());
}
commitTransaction("Could not update vote");
+
+ return result;
}
+
+ protected VoteToChoice createVoteToChoice(Vote vote, VoteToChoice source) {
+
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ VoteToChoice result = create(voteToChoiceDao);
+
+ String choiceId = source.getChoice().getTopiaId();
+ Choice choiceLoaded = getEntityById(Choice.class, choiceId);
+ result.setChoice(choiceLoaded);
+
+ result.setVote(vote);
+ result.setVoteValue(source.getVoteValue());
+
+ vote.addChoiceVoteToChoice(result);
+
+ return result;
+ }
+
+ protected void deleteVoteToChoice(Vote vote, VoteToChoice entity) {
+ VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class);
+ vote.removeChoiceVoteToChoice(entity);
+ delete(voteToChoiceDao, entity);
+ }
+
/**
* Delete vote referenced by {@code voteId}. This will also delete all
* associated {@link VoteToChoice}. The {@link PollAccount} could also be
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -66,4 +66,8 @@
pollUri = PollUriConverter.convertFromString(values);
}
}
+
+ protected void preparePollUri(String pollId, String accountId) {
+ pollUri = PollUri.newPollUri(pollId, accountId);
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -192,7 +192,7 @@
}
public String getCreatorName() {
- return poll.getCreator().getAccountId();
+ return poll.getCreator().getVotingId();
}
public String getVoteSizeMessage() {
@@ -277,14 +277,14 @@
DateFormat.SHORT, getLocale()));
// Current poll account
- pollAccount = getPollService().getPollAccount(getAccountId(), getPollenUserAccount());
+ pollAccount = getPollService().getPollAccountEditable(getAccountId(), getPollenUserAccount(), poll);
// All votes
// TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
votes = poll.getVote();
// Current vote
- vote = getVoteService().getVote(poll, votes, pollAccount);
+ vote = getVoteService().getVoteEditable(poll, pollAccount);
loadPollResults();
loadPollComments();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -23,8 +23,6 @@
*/
package org.chorem.pollen.ui.actions.poll;
-import org.chorem.pollen.bean.PollUri;
-
/**
* EditVote is a redirection to vote page. This action will simply update the
* uri with {@code accountId} and {@code pollId}.
@@ -51,7 +49,7 @@
@Override
public String execute() throws Exception {
- setUriId(PollUri.newPollUri(pollId, accountId));
+ preparePollUri(pollId, accountId);
return SUCCESS;
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-28 16:39:46 UTC (rev 3215)
@@ -23,11 +23,15 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import com.google.common.base.Preconditions;
import com.opensymphony.xwork2.Preparable;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.Vote;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Votes to a poll.
@@ -38,7 +42,7 @@
*/
public class VoteForPoll extends AbstractVoteAction implements Preparable {
- private static final Logger log = LoggerFactory.getLogger(VoteForPoll.class);
+ private static final Log log = LogFactory.getLog(VoteForPoll.class);
private static final long serialVersionUID = 1L;
@@ -50,12 +54,36 @@
}
@Override
+ public void validate() {
+
+ Vote vote = getVote();
+ Preconditions.checkNotNull(vote);
+
+ PollAccount pollAccount = getVote().getPollAccount();
+ Preconditions.checkNotNull(pollAccount);
+
+ Poll poll = getPoll();
+
+ String name = pollAccount.getVotingId();
+ if (StringUtils.isBlank(name)) {
+ addFieldError("pollAccount.votingId", _("pollen.error.pollAccount.votingId.required"));
+ }
+
+ // check if the new pollAccount (topiaId = null) has already voted
+ if (pollAccount.getTopiaId() == null && getVoteService().hasAlreadyVoted(name, poll)) {
+ addFieldError("pollAccount.votingId", _("pollen.error.user.alreadyVoted"));
+ }
+ }
+
+ @Override
public String execute() throws Exception {
+ // REMARQUES :
+ // - pas le droit de modif si le pollAccount est rattaché a un userAccount et qu'on est pas loggé ?!?
+ // - Ce serait plus simple que l'Admin ne puisse jamais voter, il ne peut que modérer les votes
+
// VALIDATION ::
- // - votingId/name not empty
- // - account not exists (matching userAccount) > check on all votes (EXISTS userAccount FROM poll.votes)
- // - votingId/name is unique > check on all votes (EXISTS votingId FROM poll.votes)
+ // - account not exists (matching userAccount) > check on all votes (EXISTS userAccount FROM poll.votes) >>> secu ?
if (getVote().getTopiaId() != null) {
getVoteService().updateVote(getVote());
@@ -74,7 +102,9 @@
String updateUrl = getVoteService().getUpdateVoteUrl(pollUri);
- log.debug("UpdateURL for poll '{}' and account '{}' = {}", new Object[]{pollId, accountId, updateUrl});
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("UpdateURL for poll '%s' and account '%s' = %s", pollId, accountId, updateUrl));
+ }
addActionMessage(_("pollen.information.vote.createdWithUpdateUrl", updateUrl));
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 16:39:46 UTC (rev 3215)
@@ -98,8 +98,9 @@
</action>
<!-- vote poll -->
- <action name="vote" method="execute"
+ <action name="vote/*" method="execute"
class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
<result type="redirectToVote"/>
</action>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 08:56:35 UTC (rev 3214)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-28 16:39:46 UTC (rev 3215)
@@ -160,7 +160,7 @@
title="%{getText('pollen.title.delete.pollChoice')}"
autoOpen="false" modal="true" width="800"/>
-<s:form id="voteForm">
+<s:form id="voteForm" validate="true">
<s:hidden key="uriId"/>
<table id="poll">
<thead>
@@ -401,6 +401,7 @@
</tbody>
</table>
<div id="voteError">
+ <s:fielderror fieldName="pollAccount.votingId"/>
<%--<t:errors/>--%>
</div>
@@ -411,7 +412,7 @@
<%--<t:label for="anonymousVote"/>--%>
<br/>
</s:if>
- <s:submit action="vote" key="pollen.action.pollVote"/>
+ <s:submit action="vote/%{uriId}" key="pollen.action.pollVote"/>
<%--<input id="submitVote" t:type="Submit" t:value="${message:submitVote}"/>--%>
</div>
</s:if>
1
0
r3214 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui java/org/chorem/pollen/ui/actions java/org/chorem/pollen/ui/results resources/config resources/org/chorem/pollen/business/persistence resources/org/chorem/pollen/ui/actions/poll webapp/js
by tchemit@users.chorem.org 28 Mar '12
by tchemit@users.chorem.org 28 Mar '12
28 Mar '12
Author: tchemit
Date: 2012-03-28 10:56:35 +0200 (Wed, 28 Mar 2012)
New Revision: 3214
Url: http://chorem.org/repositories/revision/pollen/3214
Log:
add result to avoid the : void mystery + add svn properties
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package org.chorem.pollen.ui.actions;
import org.apache.struts2.util.StrutsTypeConverter;
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package org.chorem.pollen.ui.actions;
import com.google.common.base.Preconditions;
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java 2012-03-28 08:56:35 UTC (rev 3214)
@@ -0,0 +1,231 @@
+/*
+ * #%L
+ * Pollen :: UI (strust2)
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.chorem.pollen.ui.results;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.ServletActionRedirectResult;
+import org.apache.struts2.dispatcher.ServletRedirectResult;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.views.util.UrlHelper;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+/**
+ * <!-- START SNIPPET: description -->
+ * <p/>
+ * This result uses the {@link ActionMapper} provided by the
+ * {@link ActionMapperFactory} to redirect the browser to a URL that invokes the
+ * specified action and (optional) namespace. This is better than the
+ * {@link ServletRedirectResult} because it does not require you to encode the
+ * URL patterns processed by the {@link ActionMapper} in to your struts.xml
+ * configuration files. This means you can change your URL patterns at any point
+ * and your application will still work. It is strongly recommended that if you
+ * are redirecting to another action, you use this result rather than the
+ * standard redirect result.
+ * <p/>
+ * See examples below for an example of how request parameters could be passed
+ * in.
+ * <p/>
+ * <!-- END SNIPPET: description -->
+ * <p/>
+ * <b>This result type takes the following parameters:</b>
+ * <p/>
+ * <!-- START SNIPPET: params -->
+ * <p/>
+ * <ul>
+ * <p/>
+ * <li><b>actionName (default)</b> - The name of the action that will be
+ * redirected to.</li>
+ * <p/>
+ * <li><b>namespace</b> - Used to determine which namespace the action is in
+ * that we're redirecting to. If namespace is null, the default will be the
+ * current namespace.</li>
+ * <p/>
+ * <li><b>suppressEmptyParameters</b> - Optional boolean (defaults to false) that
+ * can prevent parameters with no values from being included in the redirect
+ * URL.</li>
+ * <p/>
+ * <li><b>parse</b> - Boolean, true by default. If set to false, the actionName
+ * param will not be parsed for Ognl expressions.</li>
+ * <p/>
+ * <li><b>anchor</b> - Optional. Also known as "fragment" or colloquially as
+ * "hash". You can specify an anchor for a result.</li>
+ * </ul>
+ * <p/>
+ * <!-- END SNIPPET: params -->
+ * <p/>
+ * <b>Example:</b>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: example -->
+ * <package name="public" extends="struts-default">
+ * <action name="login" class="...">
+ * <!-- Redirect to another namespace -->
+ * <result type="redirectAction">
+ * <param name="actionName">dashboard</param>
+ * <param name="namespace">/secure</param>
+ * </result>
+ * </action>
+ * </package>
+ *
+ * <package name="secure" extends="struts-default" namespace="/secure">
+ * <-- Redirect to an action in the same namespace -->
+ * <action name="dashboard" class="...">
+ * <result>dashboard.jsp</result>
+ * <result name="error" type="redirectAction">error</result>
+ * </action>
+ *
+ * <action name="error" class="...">
+ * <result>error.jsp</result>
+ * </action>
+ * </package>
+ *
+ * <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
+ * <!-- Pass parameters (reportType, width and height) -->
+ * <!--
+ * The redirectAction url generated will be :
+ * /genReport/generateReport.action?reportType=pie&width=100&height=100#summary
+ * -->
+ * <action name="gatherReportInfo" class="...">
+ * <result name="showReportResult" type="redirectAction">
+ * <param name="actionName">generateReport</param>
+ * <param name="namespace">/genReport</param>
+ * <param name="reportType">pie</param>
+ * <param name="width">100</param>
+ * <param name="height">100</param>
+ * <param name="empty"></param>
+ * <param name="suppressEmptyParameters">true</param>
+ * <param name="anchor">summary</param>
+ * </result>
+ * </action>
+ * </package>
+ *
+ *
+ * <!-- END SNIPPET: example -->
+ * </pre>
+ *
+ * @see ActionMapper
+ */
+public class PollenServletActionRedirectResult extends ServletActionRedirectResult {
+
+ private static final long serialVersionUID = -9042425229314584066L;
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(ServletRedirectResult.class);
+
+ /**
+ * Redirects to the location specified by calling
+ * {@link HttpServletResponse#sendRedirect(String)}.
+ *
+ * @param finalLocation the location to redirect to.
+ * @param invocation an encapsulation of the action execution state.
+ * @throws Exception if an error occurs when redirecting.
+ */
+ protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
+ ActionContext ctx = invocation.getInvocationContext();
+ HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
+ HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
+
+// if (isPathUrl(finalLocation)) {
+ if (!finalLocation.startsWith("/")) {
+ ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager());
+ String namespace = null;
+ if (mapping != null) {
+ namespace = mapping.getNamespace();
+ }
+
+ if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) {
+ finalLocation = namespace + "/" + finalLocation;
+ } else {
+ finalLocation = "/" + finalLocation;
+ }
+ }
+
+ // if the URL's are relative to the servlet context, append the servlet context path
+ if (prependServletContext && (request.getContextPath() != null) && (request.getContextPath().length() > 0)) {
+ finalLocation = request.getContextPath() + finalLocation;
+ }
+
+ ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
+ if (resultConfig != null) {
+ Map<String, String> resultConfigParams = resultConfig.getParams();
+
+ for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
+ if (!getProhibitedResultParams().contains(e.getKey())) {
+ String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue(), invocation);
+ if (!suppressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) {
+ requestParameters.put(e.getKey(), potentialValue);
+ }
+ }
+ }
+ }
+
+ StringBuilder tmpLocation = new StringBuilder(finalLocation);
+ UrlHelper.buildParametersString(requestParameters, tmpLocation, "&");
+
+ // add the anchor
+ if (anchor != null) {
+ tmpLocation.append('#').append(anchor);
+ }
+
+ finalLocation = response.encodeRedirectURL(tmpLocation.toString());
+// }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Redirecting to finalLocation " + finalLocation);
+ }
+
+ sendRedirect(response, finalLocation);
+ }
+}
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 08:56:35 UTC (rev 3214)
@@ -34,7 +34,7 @@
<result-types>
<result-type name="redirectToVote"
- class="org.apache.struts2.dispatcher.ServletActionRedirectResult">
+ class="org.chorem.pollen.ui.results.PollenServletActionRedirectResult">
<param name="namespace">/poll</param>
<param name="actionName">votefor/${uriId}</param>
</result-type>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1 +1,24 @@
+###
+# #%L
+# Pollen :: UI (strust2)
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2012 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
voteValue=org.chorem.pollen.ui.actions.BooleanIntegerConverter
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-28 07:59:26 UTC (rev 3213)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-28 08:56:35 UTC (rev 3214)
@@ -1 +1,24 @@
+###
+# #%L
+# Pollen :: UI (strust2)
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2012 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
uriId=org.chorem.pollen.ui.actions.PollUriConverter
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r3213 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: resources resources/config webapp/WEB-INF/decorators webapp/WEB-INF/jsp/poll webapp/WEB-INF/jsp/user
by tchemit@users.chorem.org 28 Mar '12
by tchemit@users.chorem.org 28 Mar '12
28 Mar '12
Author: tchemit
Date: 2012-03-28 09:59:26 +0200 (Wed, 28 Mar 2012)
New Revision: 3213
Url: http://chorem.org/repositories/revision/pollen/3213
Log:
move some actions to user namespace + pass into devmode
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp
Removed:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -32,18 +32,25 @@
<package name="admin" extends="default" namespace="/admin">
- <default-interceptor-ref name="pollenBasicStack"/>
+ <default-interceptor-ref name="pollenParamsPrepareParamsStack"/>
<!-- manage users -->
<action name="usersList" method="input"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
+ <interceptor-ref name="pollenBasicStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
+ <!-- manage polls -->
+ <action name="pollsList" method="input"
+ class="org.chorem.pollen.ui.actions.admin.ManagePolls">
+ <interceptor-ref name="pollenBasicStack"/>
+ <result name="input">/WEB-INF/jsp/admin/pollsList.jsp</result>
+ </action>
+
<!-- create user -->
<action name="create" method="create"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
@@ -51,7 +58,6 @@
<!-- save user -->
<action name="edit" method="edit"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
@@ -59,17 +65,10 @@
<!-- delete user -->
<action name="delete" method="delete"
class="org.chorem.pollen.ui.actions.admin.ManageUsers">
- <interceptor-ref name="pollenParamsPrepareParamsStack"/>
<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>
<result>/WEB-INF/jsp/admin/usersList.jsp</result>
</action>
- <!-- manage polls -->
- <action name="pollsList" method="input"
- class="org.chorem.pollen.ui.actions.admin.ManagePolls">
- <result name="input">/WEB-INF/jsp/admin/pollsList.jsp</result>
- </action>
-
</package>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -31,79 +31,11 @@
<package name="json" extends="default" namespace="/json">
- <default-interceptor-ref name="pollenBasicStack"/>
-
- <action name="get*"
- class="org.chorem.pollen.ui.actions.json.Get{1}">
+ <action name="get*" class="org.chorem.pollen.ui.actions.json.Get{1}">
+ <interceptor-ref name="pollenBasicStack"/>
<result type="json"/>
</action>
- <!---->
- <!--<!– get pagined users –>-->
- <!--<action name="getUsers"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetUsers">-->
- <!--<result type="json"/>-->
- <!--</action>-->
- <!--<!– get user detail –>-->
- <!--<action name="getUser"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetUser">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined favorite lists of user –>-->
- <!--<action name="getFavoriteLists"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteLists">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get selected favorite list of user –>-->
- <!--<action name="getFavoriteList"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteList">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined poll accounts of a given favorite list –>-->
- <!--<action name="getFavoriteListPollAccounts"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccounts">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get selected poll account of a given favorite list –>-->
- <!--<action name="getFavoriteListPollAccount"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetFavoriteListPollAccount">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined polls –>-->
- <!--<action name="getPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined created polls –>-->
- <!--<action name="getCreatedPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetCreatedPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined invited polls –>-->
- <!--<action name="getInvitedPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetInvitedPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined created polls –>-->
- <!--<action name="getParticipatedPolls"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetParticipatedPolls">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
- <!--<!– get pagined poll comments –>-->
- <!--<action name="getPollComments"-->
- <!--class="org.chorem.pollen.ui.actions.json.GetPollComments">-->
- <!--<result type="json"/>-->
- <!--</action>-->
-
</package>
</struts>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -53,36 +53,42 @@
<result>/WEB-INF/jsp/poll/resume.jsp</result>
</action>
- <!-- display text choice -->
- <action name="displayTextChoice"
- class="org.chorem.pollen.ui.actions.poll.DisplayTextChoice">
- <result>/WEB-INF/jsp/poll/textChoice.jsp</result>
+ <!-- display * -->
+ <action name="display*"
+ class="org.chorem.pollen.ui.actions.poll.Display{1}">
+ <result>/WEB-INF/jsp/poll/{1}.jsp</result>
</action>
- <!-- display date choice -->
- <action name="displayDateChoice"
- class="org.chorem.pollen.ui.actions.poll.DisplayDateChoice">
- <result>/WEB-INF/jsp/poll/dateChoice.jsp</result>
- </action>
+ <!--<!– display text choice –>-->
+ <!--<action name="displayTextChoice"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayTextChoice">-->
+ <!--<result>/WEB-INF/jsp/poll/TextChoice.jsp</result>-->
+ <!--</action>-->
- <!-- display image choice -->
- <action name="displayImageChoice"
- class="org.chorem.pollen.ui.actions.poll.DisplayImageChoice">
- <result>/WEB-INF/jsp/poll/imageChoice.jsp</result>
- </action>
+ <!--<!– display date choice –>-->
+ <!--<action name="displayDateChoice"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayDateChoice">-->
+ <!--<result>/WEB-INF/jsp/poll/DateChoice.jsp</result>-->
+ <!--</action>-->
- <!-- display a votingList -->
- <action name="displayVotingList"
- class="org.chorem.pollen.ui.actions.poll.DisplayVotingList">
- <result>/WEB-INF/jsp/poll/votingList.jsp</result>
- </action>
+ <!--<!– display image choice –>-->
+ <!--<action name="displayImageChoice"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayImageChoice">-->
+ <!--<result>/WEB-INF/jsp/poll/ImageChoice.jsp</result>-->
+ <!--</action>-->
- <!-- display a personToList -->
- <action name="displayPersonToList"
- class="org.chorem.pollen.ui.actions.poll.DisplayPersonToList">
- <result>/WEB-INF/jsp/poll/personToList.jsp</result>
- </action>
+ <!--<!– display a votingList –>-->
+ <!--<action name="displayVotingList"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayVotingList">-->
+ <!--<result>/WEB-INF/jsp/poll/VotingList.jsp</result>-->
+ <!--</action>-->
+ <!--<!– display a personToList –>-->
+ <!--<action name="displayPersonToList"-->
+ <!--class="org.chorem.pollen.ui.actions.poll.DisplayPersonToList">-->
+ <!--<result>/WEB-INF/jsp/poll/PersonToList.jsp</result>-->
+ <!--</action>-->
+
<!-- edit poll -->
<action name="modification/*"
class="org.chorem.pollen.ui.actions.poll.EditPoll">
@@ -169,20 +175,6 @@
<result>/WEB-INF/jsp/poll/result.jsp</result>
</action>
- <!-- display createds polls -->
- <action name="createdList"
- class="org.chorem.pollen.ui.actions.poll.CreatedList">
- <interceptor-ref name="pollenBasicStack"/>
- <result>/WEB-INF/jsp/poll/createdList.jsp</result>
- </action>
-
- <!-- display participated polls -->
- <action name="participatedList"
- class="org.chorem.pollen.ui.actions.poll.ParticipatedList">
- <interceptor-ref name="pollenBasicStack"/>
- <result>/WEB-INF/jsp/poll/participatedList.jsp</result>
- </action>
-
<!-- confirm delete comment -->
<action name="confirmDeleteComment"
class="org.chorem.pollen.ui.actions.poll.ConfirmDeleteComment">
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -118,6 +118,20 @@
<result>/WEB-INF/jsp/user/favoriteList.jsp</result>
</action>
+ <!-- display createds polls -->
+ <action name="createdList"
+ class="org.chorem.pollen.ui.actions.poll.CreatedList">
+ <interceptor-ref name="pollenBasicStack"/>
+ <result>/WEB-INF/jsp/user/createdList.jsp</result>
+ </action>
+
+ <!-- display participated polls -->
+ <action name="participatedList"
+ class="org.chorem.pollen.ui.actions.poll.ParticipatedList">
+ <interceptor-ref name="pollenBasicStack"/>
+ <result>/WEB-INF/jsp/user/participatedList.jsp</result>
+ </action>
+
</package>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/shiro.ini 2012-03-28 07:59:26 UTC (rev 3213)
@@ -17,15 +17,12 @@
[urls]
+# anon urls
+/user/login = anon
+/user/register** = anon
+
# connected urls
-/poll/createdList=connected
-/poll/participatedList=connected
-/user/favoriteLists=connected
-/user/createFavoriteList=connected
-/user/deleteFavoriteList=connected
-/user/show=connected
-/user/edit=connected
-/user/editFavoriteList=connected
+/user/**=connected
/json/getFavoriteLists=connected
/json/getFavoriteList=connected
/json/getFavoriteListPollAccounts=connected
@@ -36,16 +33,13 @@
# connected and admin urls
/admin/**=connected,admin
-/user/addPollAccount=connected,admin
-/user/editPollAccount=connected,admin
-/user/removePollAccount=connected,admin
/json/getUsers=connected,admin
/json/getUser=connected,admin
/json/getPolls=connected,admin
# is pollAccount (can vote and see result of a poll)
/poll/votefor/**=poll,pollAccess
-/poll/result/**=poll,pollAccess
+/poll/results/**=poll,pollAccess
# is pollCreator (can admin a poll)
/poll/modification/**=poll,pollCreator
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-28 07:59:26 UTC (rev 3213)
@@ -43,6 +43,7 @@
<constant name="struts.ui.theme" value="css_xhtml"/>
<constant name="struts.multipart.maxSize" value="209715200"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
+ <constant name="struts.devMode" value="true"/>
<!--Performance tuning-->
<!--see http://struts.apache.org/2.2.3/docs/performance-tuning.html-->
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -153,7 +153,7 @@
<!-- Menu -->
<ul id="menu">
<li class="menu_elt">
- <s:a action="home">
+ <s:a action="home" namespace="/">
<s:text name="pollen.menu.home"/>
</s:a>
</li>
@@ -172,12 +172,12 @@
</li>
<s:if test="userExists">
<li>
- <s:a action="createdList" namespace="/poll">
+ <s:a action="createdList" namespace="/user">
<s:text name="pollen.menu.pollsCreatedList"/>
</s:a>
</li>
<li>
- <s:a action="participatedList" namespace="/poll">
+ <s:a action="participatedList" namespace="/user">
<s:text name="pollen.menu.pollsParticipatedList"/>
</s:a>
</li>
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,70 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<s:set name="prefix">dateChoice_<s:property value="choiceNumber"/></s:set>
+<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<div id='choicesDATE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" changeMonth="true"
+ changeYear="true" labelSeparator="" theme="simple" label=""
+ timepicker="true" value="%{choice.date}" displayFormat="dd/mm/yy"/>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ </div>
+ <div class="fleft">
+ <s:textarea cols="30" id="%{#prefix}.description"
+ key="%{#prefix}.description" label='' theme="simple"
+ value="%{choice.description}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ <%--s:a id='choicesDATE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ <div class="cleanBoth"></div>
+</div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/DateChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,83 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">imageChoice_<s:property value="choiceNumber"/></s:set>
+<s:set name="prefix2">imageChoice[<s:property value="choiceNumber"/>]</s:set>
+<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <s:if test="choice.name != ''">
+
+ <%--Uploaded image--%>
+ <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
+ value="%{choice.name}" label='' theme="simple"/>
+
+ <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
+ value="%{choice.location}" label='' theme="simple"/>
+
+ <s:label label='' theme="simple" cssClass="nameField"
+ value="%{choice.name}" readonly="true"/>
+ </s:if>
+ <s:else>
+ <%--New image--%>
+ <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>
+ </s:else>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ </div>
+ <div class="fleft">
+ <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
+ key="%{#prefix}.description" value="%{choice.description}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+
+ <div class="cleanBoth"></div>
+</div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/ImageChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,62 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">personToList_<s:property
+ value="votingListNumber"/>_<s:property value="personToListNumber"/>
+</s:set>
+<s:set id='deleteTitle'>
+ <s:text name="pollen.action.pollPersonToListDelete"/>
+</s:set>
+<s:div id='%{#prefix}'>
+ <s:fielderror/>
+ <s:hidden key='%{#prefix}.topiaId' value='%{personToList.topiaId}' label=''/>
+ <s:hidden key='%{#prefix}.accountId' value='%{personToList.pollAccount.accountId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.votingId" id="%{#prefix}_label" theme="simple"
+ value=''/>
+ <s:textfield cssClass="nameField" id='%{#prefix}.votingId'
+ key="%{#prefix}.votingId" label='' theme="simple"
+ value="%{personToList.pollAccount.votingId}"/>
+ -
+ <s:label for="%{#prefix}.email" key="pollen.common.email" theme="simple"/>
+ <s:textfield cols="30" id="%{#prefix}.email" key="%{#prefix}.email"
+ label='' theme="simple" size="30"
+ value="%{personToList.pollAccount.email}"/>
+ -
+ <s:label for="%{#prefix}.weight" key="pollen.common.weight" theme="simple"/>
+ <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight" size="1"
+ label='' theme="simple" value="%{personToList.weight}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deletePersonToList('%{#prefix}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ </div>
+
+ <div class="cleanBoth"></div>
+</s:div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,67 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">textChoice_<s:property value="choiceNumber"/></s:set>
+<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<div id='choicesTEXT_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <s:textfield cssClass="nameField" id='%{#prefix}.name' key="%{#prefix}.name"
+ label='' theme="simple" value="%{choice.name}"/>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ <%--/div>
+ <div class="fleft"--%>
+ <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
+ key="%{#prefix}.description" value="%{choice.description}"/>
+ </div>
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ <%--s:a id='choicesTEXT_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ <div class="cleanBoth"></div>
+</div>
\ No newline at end of file
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/TextChoice.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,90 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<s:set name="prefix">votingList_<s:property value="votingListNumber"/></s:set>
+<s:set id='deleteTitle'>
+ <s:text name="pollen.action.pollVotingListDelete"/>
+</s:set>
+
+<script type="text/javascript">
+ jQuery(document).ready(function () {
+ // personToList loading
+ <s:iterator begin="1" end="nbPersonToLists" status="status">
+ addPersonToList(<s:property value="votingListNumber"/>, <s:property value='%{#status.index}'/>, <s:property value="nbPersonToLists - 1"/>, '<s:property value="personToListTokenId" />');
+ </s:iterator>
+ });
+</script>
+<s:div id='votingLists_%{votingListNumber}'>
+ <fieldset class="ui-widget-content ui-corner-all">
+
+ <s:fielderror/>
+ <div class="groupPoll">
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" theme="simple"
+ id="votingLists_%{votingListNumber}_label"/>
+ <s:textfield id='%{#prefix}.name' key="%{#prefix}.name" label=''
+ theme="simple" value="%{votingList.name}"/>
+ -
+ <s:label for="%{#prefix}.weight" key="pollen.common.weight"
+ theme="simple"/>
+ <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight"
+ value="%{votingList.weight}"
+ size="1" label='' theme="simple"/>
+ </div>
+ <div id='<s:property value="%{#prefix}"/>_actions' class="fright">
+ <s:a href='#'
+ onclick="return deleteVotingList('votingLists_%{votingListNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ </div>
+ <hr/>
+ </div>
+ <div class="cleanBoth"></div>
+ <s:hidden key='%{#prefix}.topiaId' value='%{votingList.topiaId}' label=''/>
+
+ <s:div id='personToList_%{votingListNumber}'>
+ <%--Where to load personToList--%>
+ </s:div>
+ <hr/>
+ <div class="cleanBoth" align="center">
+ <s:submit id='%{#prefix}_addPersonToList'
+ name='%{#prefix}_addPersonToList'
+ key="pollen.action.addPersonToList" theme="simple"
+ onclick='return addNewPersonToList("%{votingListNumber}");'/>
+ <s:if test="userLoggued">
+ <s:submit id='%{#prefix}_addPersonToList' theme="simple"
+ name='%{#prefix}_addPersonToList'
+ key="pollen.action.addPersonListFromVotingList"
+ onclick='return selectPersonListToAddToVotingList("%{votingListNumber}");'/>
+ </s:if>
+
+ </div>
+
+ </fieldset>
+ <br/>
+</s:div>
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,59 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@page contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
-
-<script type="text/javascript">
-var redirectUrl = '<s:url namespace="/poll" action="createdList"/>';
-</script>
-<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
-
-<title><s:text name="pollen.title.pollsCreatedList"/></title>
-
-<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsCreatedList"/></h1>
-
-<h4><s:text name="pollen.title.pollsCreatedList.legend"/></h4>
-
-<s:url id="loadUrl" action="getCreatedPolls" namespace="/json" escapeAmp="false"/>
-
-<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
- sortable="true" pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" rownumbers="false" autowidth="true"
- onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
- onCompleteTopics='users-cleanSelect'
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true"
- rowList="10,15,20,50,100" rowNum="10">
- <sjg:gridColumn name="id" title="id" hidden="true"/>
-
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
- <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
- <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
- formatter="pollFunctions" width="180" sortable="false"/>
-</sjg:grid>
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/dateChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,70 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-
-<s:set name="prefix">dateChoice_<s:property value="choiceNumber"/></s:set>
-<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id='choicesDATE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" changeMonth="true"
- changeYear="true" labelSeparator="" theme="simple" label=""
- timepicker="true" value="%{choice.date}" displayFormat="dd/mm/yy"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- </div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description"
- key="%{#prefix}.description" label='' theme="simple"
- value="%{choice.description}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesDATE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
- <div class="cleanBoth"></div>
-</div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/imageChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,83 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">imageChoice_<s:property value="choiceNumber"/></s:set>
-<s:set name="prefix2">imageChoice[<s:property value="choiceNumber"/>]</s:set>
-<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <s:if test="choice.name != ''">
-
- <%--Uploaded image--%>
- <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
- value="%{choice.name}" label='' theme="simple"/>
-
- <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
- value="%{choice.location}" label='' theme="simple"/>
-
- <s:label label='' theme="simple" cssClass="nameField"
- value="%{choice.name}" readonly="true"/>
- </s:if>
- <s:else>
- <%--New image--%>
- <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>
- </s:else>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- </div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{choice.description}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
-
- <div class="cleanBoth"></div>
-</div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,85 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@page contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
-<script type="text/javascript">
- var redirectUrl = '<s:url namespace="/poll" action="participatedList"/>';
-</script>
-<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
-
-<title><s:text name="pollen.title.pollsParticipatedList"/></title>
-
-<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsParticipatedList"/></h1>
-
-<h4><s:text name="pollen.title.pollsInvitedList.legend"/></h4>
-
-<s:url id="loadInvitedUrl" action="getInvitedPolls"
- namespace="/json" escapeAmp="false"/>
-
-<sjg:grid dataType="json" href="%{loadInvitedUrl}" gridModel="polls"
- sortable="true" pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" rownumbers="false" autowidth="true"
- onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
- onCompleteTopics='users-cleanSelect'
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true"
- rowList="10,15,20,50,100" rowNum="10">
- <sjg:gridColumn name="id" title="id" hidden="true"/>
-
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
- <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
- <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
- formatter="pollFunctions" width="180" sortable="false"/>
-</sjg:grid>
-
-
-<h4><s:text name="pollen.title.pollsParticipatedList.legend"/></h4>
-
-<s:url id="loadParticipatedUrl" action="getParticipatedPolls"
- namespace="/json" escapeAmp="false"/>
-
-<sjg:grid dataType="json" href="%{loadParticipatedUrl}" gridModel="polls"
- sortable="true" pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" rownumbers="false" autowidth="true"
- onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
- onCompleteTopics='users-cleanSelect'
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" viewrecords="true"
- rowList="10,15,20,50,100" rowNum="10">
- <sjg:gridColumn name="id" title="id" hidden="true"/>
-
- <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
- <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
- <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
- <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
- <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
- <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
- formatter="pollFunctions" width="180" sortable="false"/>
-</sjg:grid>
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/personToList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,62 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">personToList_<s:property
- value="votingListNumber"/>_<s:property value="personToListNumber"/>
-</s:set>
-<s:set id='deleteTitle'>
- <s:text name="pollen.action.pollPersonToListDelete"/>
-</s:set>
-<s:div id='%{#prefix}'>
- <s:fielderror/>
- <s:hidden key='%{#prefix}.topiaId' value='%{personToList.topiaId}' label=''/>
- <s:hidden key='%{#prefix}.accountId' value='%{personToList.pollAccount.accountId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.votingId" id="%{#prefix}_label" theme="simple"
- value=''/>
- <s:textfield cssClass="nameField" id='%{#prefix}.votingId'
- key="%{#prefix}.votingId" label='' theme="simple"
- value="%{personToList.pollAccount.votingId}"/>
- -
- <s:label for="%{#prefix}.email" key="pollen.common.email" theme="simple"/>
- <s:textfield cols="30" id="%{#prefix}.email" key="%{#prefix}.email"
- label='' theme="simple" size="30"
- value="%{personToList.pollAccount.email}"/>
- -
- <s:label for="%{#prefix}.weight" key="pollen.common.weight" theme="simple"/>
- <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight" size="1"
- label='' theme="simple" value="%{personToList.weight}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deletePersonToList('%{#prefix}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
-
- <div class="cleanBoth"></div>
-</s:div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/textChoice.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,67 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">textChoice_<s:property value="choiceNumber"/></s:set>
-<s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id='choicesTEXT_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{choice.topiaId}' label=''/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{choiceNumber}"
- theme="simple" value=''/>
- <s:textfield cssClass="nameField" id='%{#prefix}.name' key="%{#prefix}.name"
- label='' theme="simple" value="%{choice.name}"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- <%--/div>
- <div class="fleft"--%>
- <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{choice.description}"/>
- </div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesTEXT_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
- <div class="cleanBoth"></div>
-</div>
\ No newline at end of file
Deleted: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp 2012-03-27 19:09:51 UTC (rev 3212)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/votingList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -1,90 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<s:set name="prefix">votingList_<s:property value="votingListNumber"/></s:set>
-<s:set id='deleteTitle'>
- <s:text name="pollen.action.pollVotingListDelete"/>
-</s:set>
-
-<script type="text/javascript">
- jQuery(document).ready(function () {
- // personToList loading
- <s:iterator begin="1" end="nbPersonToLists" status="status">
- addPersonToList(<s:property value="votingListNumber"/>, <s:property value='%{#status.index}'/>, <s:property value="nbPersonToLists - 1"/>, '<s:property value="personToListTokenId" />');
- </s:iterator>
- });
-</script>
-<s:div id='votingLists_%{votingListNumber}'>
- <fieldset class="ui-widget-content ui-corner-all">
-
- <s:fielderror/>
- <div class="groupPoll">
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" theme="simple"
- id="votingLists_%{votingListNumber}_label"/>
- <s:textfield id='%{#prefix}.name' key="%{#prefix}.name" label=''
- theme="simple" value="%{votingList.name}"/>
- -
- <s:label for="%{#prefix}.weight" key="pollen.common.weight"
- theme="simple"/>
- <s:textfield id="%{#prefix}.weight" key="%{#prefix}.weight"
- value="%{votingList.weight}"
- size="1" label='' theme="simple"/>
- </div>
- <div id='<s:property value="%{#prefix}"/>_actions' class="fright">
- <s:a href='#'
- onclick="return deleteVotingList('votingLists_%{votingListNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
- <hr/>
- </div>
- <div class="cleanBoth"></div>
- <s:hidden key='%{#prefix}.topiaId' value='%{votingList.topiaId}' label=''/>
-
- <s:div id='personToList_%{votingListNumber}'>
- <%--Where to load personToList--%>
- </s:div>
- <hr/>
- <div class="cleanBoth" align="center">
- <s:submit id='%{#prefix}_addPersonToList'
- name='%{#prefix}_addPersonToList'
- key="pollen.action.addPersonToList" theme="simple"
- onclick='return addNewPersonToList("%{votingListNumber}");'/>
- <s:if test="userLoggued">
- <s:submit id='%{#prefix}_addPersonToList' theme="simple"
- name='%{#prefix}_addPersonToList'
- key="pollen.action.addPersonListFromVotingList"
- onclick='return selectPersonListToAddToVotingList("%{votingListNumber}");'/>
- </s:if>
-
- </div>
-
- </fieldset>
- <br/>
-</s:div>
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createdList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,59 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+
+<script type="text/javascript">
+var redirectUrl = '<s:url namespace="/user" action="createdList"/>';
+</script>
+<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
+
+<title><s:text name="pollen.title.pollsCreatedList"/></title>
+
+<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsCreatedList"/></h1>
+
+<h4><s:text name="pollen.title.pollsCreatedList.legend"/></h4>
+
+<s:url id="loadUrl" action="getCreatedPolls" namespace="/json" escapeAmp="false"/>
+
+<sjg:grid id="polls" dataType="json" href="%{loadUrl}" gridModel="polls"
+ sortable="true" pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
+ onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
+ onCompleteTopics='users-cleanSelect'
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true"
+ rowList="10,15,20,50,100" rowNum="10">
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
+ <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
+ <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
+ formatter="pollFunctions" width="180" sortable="false"/>
+</sjg:grid>
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/createdList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp (from rev 3205, branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/participatedList.jsp)
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp 2012-03-28 07:59:26 UTC (rev 3213)
@@ -0,0 +1,85 @@
+<%--
+ #%L
+ Pollen :: UI (strust2)
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+<script type="text/javascript">
+ var redirectUrl = '<s:url namespace="/user" action="participatedList"/>';
+</script>
+<%@include file="/WEB-INF/jsp/pollListHelper.jsp"%>
+
+<title><s:text name="pollen.title.pollsParticipatedList"/></title>
+
+<h1 class="title${pageLogo}"><s:text name="pollen.title.pollsParticipatedList"/></h1>
+
+<h4><s:text name="pollen.title.pollsInvitedList.legend"/></h4>
+
+<s:url id="loadInvitedUrl" action="getInvitedPolls"
+ namespace="/json" escapeAmp="false"/>
+
+<sjg:grid dataType="json" href="%{loadInvitedUrl}" gridModel="polls"
+ sortable="true" pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
+ onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
+ onCompleteTopics='users-cleanSelect'
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true"
+ rowList="10,15,20,50,100" rowNum="10">
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
+ <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
+ <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
+ formatter="pollFunctions" width="180" sortable="false"/>
+</sjg:grid>
+
+
+<h4><s:text name="pollen.title.pollsParticipatedList.legend"/></h4>
+
+<s:url id="loadParticipatedUrl" action="getParticipatedPolls"
+ namespace="/json" escapeAmp="false"/>
+
+<sjg:grid dataType="json" href="%{loadParticipatedUrl}" gridModel="polls"
+ sortable="true" pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
+ onSelectRowTopics='users-rowSelect' editurl="%{loadUrl}"
+ onCompleteTopics='users-cleanSelect'
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" viewrecords="true"
+ rowList="10,15,20,50,100" rowNum="10">
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <sjg:gridColumn name="title" title='%{getText("pollen.common.title")}' />
+ <sjg:gridColumn name="description" title='%{getText("pollen.common.description")}'/>
+ <sjg:gridColumn name="addingChoices" title='%{getText("pollen.common.addingChoices")}'/>
+ <sjg:gridColumn name="beginDate" title='%{getText("pollen.common.beginDate")}'/>
+ <sjg:gridColumn name="endDate" title='%{getText("pollen.common.endDate")}'/>
+ <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}'
+ formatter="pollFunctions" width="180" sortable="false"/>
+</sjg:grid>
Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/participatedList.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r3212 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions java/org/chorem/pollen/ui/actions/poll resources/org/chorem/pollen resources/org/chorem/pollen/business resources/org/chorem/pollen/business/persistence resources/org/chorem/pollen/ui/actions/poll
by fdesbois@users.chorem.org 27 Mar '12
by fdesbois@users.chorem.org 27 Mar '12
27 Mar '12
Author: fdesbois
Date: 2012-03-27 21:09:51 +0200 (Tue, 27 Mar 2012)
New Revision: 3212
Url: http://chorem.org/repositories/revision/pollen/3212
Log:
- add PollUriConverter for parameter uriId that becomes a PollUri
- add BooleanIntegerConverter for voteValue in case of NORMAL VoteCounting
Added:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1,49 @@
+package org.chorem.pollen.ui.actions;
+
+import org.apache.struts2.util.StrutsTypeConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * Created: 26/03/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ * $Id$
+ */
+public class BooleanIntegerConverter extends StrutsTypeConverter {
+
+ private static final Logger log = LoggerFactory.getLogger(BooleanIntegerConverter.class);
+
+ @Override
+ public Integer convertFromString(Map context, String[] values, Class toClass) {
+ Integer result;
+ if (values.length == 1) {
+ result = parseValue(values[0]);
+
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ protected Integer parseValue(String value) {
+ Integer result;
+ if ("true".equals(value)) {
+ result = 1;
+
+ } else if ("false".equals(value)) {
+ result = 0;
+
+ } else {
+ result = Integer.parseInt(value);
+ }
+ return result;
+ }
+
+ @Override
+ public String convertToString(Map context, Object object) {
+ return object == null ? "" : String.valueOf(object);
+ }
+}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1,55 @@
+package org.chorem.pollen.ui.actions;
+
+import com.google.common.base.Preconditions;
+import org.apache.struts2.util.StrutsTypeConverter;
+import org.chorem.pollen.bean.PollUri;
+
+import java.util.Map;
+
+/**
+ * Created: 27/03/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class PollUriConverter extends StrutsTypeConverter {
+
+ private static PollUriConverter instance;
+
+ public static PollUriConverter getInstance() {
+ if (instance == null) {
+ instance = new PollUriConverter();
+ }
+ return instance;
+ }
+
+ @Override
+ public PollUri convertFromString(Map context, String[] values, Class toClass) {
+ PollUri result;
+ if (values.length == 1) {
+ String value = values[0];
+ result = PollUri.newPollUri(value);
+
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ @Override
+ public String convertToString(Map context, Object o) {
+ String result;
+ if (o != null) {
+ result = ((PollUri)o).getUri();
+
+ } else {
+ result = "";
+ }
+ return result;
+ }
+
+ public static PollUri convertFromString(String[] values) {
+ Preconditions.checkNotNull(values);
+ PollUri result = getInstance().convertFromString(null, values, PollUri.class);
+ return result;
+ }
+}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-27 11:28:43 UTC (rev 3211)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -24,8 +24,11 @@
package org.chorem.pollen.ui.actions.poll;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.ui.actions.PollUriConverter;
import org.chorem.pollen.ui.actions.PollenActionSupport;
+import java.util.Map;
+
/**
* Abstract action for all actions with a poll uri id.
*
@@ -34,23 +37,21 @@
* @since 1.2.6
*/
public abstract class AbstractPollUriIdAction extends PollenActionSupport {
+
+ public static final String PARAM_POLL_URI = "uriId";
private static final long serialVersionUID = 1L;
private PollUri pollUri;
- public final String getUriId() {
- return pollUri != null ? pollUri.getUri() : null;
+ public final PollUri getUriId() {
+ return pollUri;
}
- public final void setUriId(String uriId) {
- pollUri = PollUri.newPollUri(uriId);
+ public final void setUriId(PollUri pollUri) {
+ this.pollUri = pollUri;
}
- public void prepareUriId(String pollId, String accountId) {
- pollUri = PollUri.newPollUri(pollId, accountId);
- }
-
public final String getPollId() {
return pollUri != null ? pollUri.getPollId() : null;
}
@@ -58,4 +59,11 @@
public final String getAccountId() {
return pollUri != null ? pollUri.getAccountId() : null;
}
+
+ protected void preparePollUri(Map<String, String[]> parameters) {
+ if (pollUri == null) {
+ String[] values = parameters.get(PARAM_POLL_URI);
+ pollUri = PollUriConverter.convertFromString(values);
+ }
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-27 11:28:43 UTC (rev 3211)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -267,13 +267,8 @@
public void prepareVotePage() throws Exception {
- // Ensure pollId for loading
- if (getPollId() == null) {
- log.debug("parameters= " + parameters);
- String uriId = parameters.get("uriId")[0];
- log.debug("uriId= " + uriId);
- setUriId(uriId);
- }
+ // Ensure uri for poll and pollAccount loading
+ preparePollUri(parameters);
loadPoll();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-27 11:28:43 UTC (rev 3211)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditVote.java 2012-03-27 19:09:51 UTC (rev 3212)
@@ -23,13 +23,14 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import org.chorem.pollen.bean.PollUri;
+
/**
* EditVote is a redirection to vote page. This action will simply update the
* uri with {@code accountId} and {@code pollId}.
*
* @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.2.6
- * @see #prepareUriId(String, String)
*/
public class EditVote extends AbstractPollUriIdAction {
@@ -50,7 +51,7 @@
@Override
public String execute() throws Exception {
- prepareUriId(pollId, accountId);
+ setUriId(PollUri.newPollUri(pollId, accountId));
return SUCCESS;
}
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1 @@
+voteValue=org.chorem.pollen.ui.actions.BooleanIntegerConverter
\ No newline at end of file
Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-27 19:09:51 UTC (rev 3212)
@@ -0,0 +1 @@
+uriId=org.chorem.pollen.ui.actions.PollUriConverter
\ No newline at end of file
1
0