r3205 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/services 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 pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
Author: fdesbois Date: 2012-03-23 18:15:58 +0100 (Fri, 23 Mar 2012) New Revision: 3205 Url: http://chorem.org/repositories/revision/pollen/3205 Log: Create/Update Vote with VoteToChoice management Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.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/AbstractVoteAction.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/struts.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-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-03-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-03-23 17:15:58 UTC (rev 3205) @@ -69,7 +69,7 @@ public <E extends TopiaEntity> E getEntityById(Class<E> entityType, String id) { Preconditions.checkNotNull(entityType); - Preconditions.checkArgument(StringUtils.isNotEmpty(id)); + Preconditions.checkArgument(StringUtils.isNotEmpty(id), "The " + entityType.getSimpleName() + " id is undefined"); try { TopiaDAO<E> dao = getDAO(entityType); E result = dao.findByTopiaId(id); 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-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-03-23 17:15:58 UTC (rev 3205) @@ -385,12 +385,14 @@ public PollAccount getNewPollAccount(UserAccount userAccount) { PollAccountDAO dao = getDAO(PollAccount.class); PollAccount result = newInstance(dao); + result.setAccountId(serviceContext.createPollenUrlId()); if (userAccount != null) { String displayName = userAccount.getDisplayName(); result.setVotingId(displayName); } else { result.setVotingId(""); } + result.setUserAccount(userAccount); return result; } @@ -600,6 +602,50 @@ return result; } + public void addVoteToPoll(Poll poll, Vote vote) { + + String pollId = poll.getTopiaId(); + String voteId = vote.getTopiaId(); + + Poll pollToUpdate = getEntityById(Poll.class, pollId); + Vote voteToAdd = getEntityById(Vote.class, voteId); + + pollToUpdate.addVote(voteToAdd); + + commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]"); + + +// TopiaContext transaction = null; +// try { +// transaction = rootContext.beginTransaction(); +// +// pollDAO = PollenModelDAOHelper.getPollDAO(transaction); +// Poll pollEntity = pollDAO.findByTopiaId(pollId); +// VoteDAO voteDAO = PollenModelDAOHelper.getVoteDAO(transaction); +// Vote voteEntity = voteDAO.findByTopiaId(voteId); +// +// if (log.isDebugEnabled()) { +// log.debug(pollEntity + " " + voteEntity); +// } +// +// pollEntity.addVote(voteEntity); +// pollDAO.update(pollEntity); +// +// transaction.commitTransaction(); +// +// if (log.isDebugEnabled()) { +// log.debug("Entity updated: " + pollId); +// } +// +// return true; +// } catch (Exception e) { +// ContextUtil.doCatch(e, transaction); +// return false; +// } finally { +// ContextUtil.doFinally(transaction); +// } + } + /** * Création d'une miniature. * 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-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-03-23 17:15:58 UTC (rev 3205) @@ -23,15 +23,22 @@ */ package org.chorem.pollen.services.impl; +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenTechnicalException; +import org.chorem.pollen.business.persistence.Choice; import org.chorem.pollen.business.persistence.Poll; import org.chorem.pollen.business.persistence.PollAccount; import org.chorem.pollen.business.persistence.PollAccountDAO; +import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.business.persistence.Vote; import org.chorem.pollen.business.persistence.VoteDAO; +import org.chorem.pollen.business.persistence.VoteToChoice; +import org.chorem.pollen.business.persistence.VoteToChoiceDAO; import org.chorem.pollen.entities.PollenDAOHelper; import org.chorem.pollen.services.PollenServiceSupport; import org.chorem.pollen.services.exceptions.VoteNotFoundException; @@ -46,68 +53,137 @@ /** Logger. */ private static final Log log = LogFactory.getLog(VoteService.class); + + public Vote getNewVote(Poll poll, PollAccount account) { + + Preconditions.checkNotNull(poll); + + VoteDAO voteDAO = getDAO(Vote.class); + VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class); + + Vote result = newInstance(voteDAO); + result.setPollAccount(account); + + // Prepare the List of VoteToChoice with Poll's choices + for (Choice choice : poll.getChoice()) { + VoteToChoice element = newInstance(voteToChoiceDAO); + element.setChoice(choice); + result.addChoiceVoteToChoice(element); + } - public void createVote(Vote vote, PollAccount pollAccount) { + // TODO weight ? + + return result; + } + + public Vote getVote(Poll poll, List<Vote> votes, final PollAccount account) { + + Preconditions.checkNotNull(poll); + Preconditions.checkNotNull(votes); + Preconditions.checkNotNull(account); - // création du compte associé au vote s'il n'existe pas - // sinon mise à jour du compte - //ServicePollAccount spa = new ServicePollAccountImpl(); - if (pollAccount == null) { - vote.setPollAccount(null); - } else { -// pollAccount.setHasVoted(true); - PollAccountDAO pollAccountDAO = - getDAO(PollAccount.class); + Vote result = Iterables.find(votes, new Predicate<Vote>() { + + @Override + public boolean apply(Vote input) { + return account.equals(input.getPollAccount()); + } - PollAccount pollAccountEntity = - getEntityById(PollAccount.class, pollAccount.getTopiaId()); + }, getNewVote(poll, account)); -// PollAccountDTO account = spa.findPollAccountById(pollAccountDTO -// .getId()); - if (pollAccountEntity == null) { - log.debug("Nouveau compte associé au vote"); - pollAccountEntity = create(pollAccountDAO); -// voteDTO.setPollAccountId(spa -// .createPollAccount(pollAccountDTO)); - } else { - log.debug("Compte associé au vote : " + pollAccountEntity.getTopiaId()); - //spa.updatePollAccount(pollAccountDTO); - //voteDTO.setPollAccountId(account.getId()); + // For an existing Vote, ensure that there is as many voteToChoice as poll choices + if (result.getTopiaId() != null) { + + VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class); + + 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); + } } - // Fill pollAccountEntity from DTO in argument -// DataPollAccountConverter pollAccountConverter = new DataPollAccountConverter(); -// pollAccountConverter.setTransaction(transaction); -// pollAccountConverter.populatePollAccountEntity(pollAccountDTO, -// pollAccountEntity); - // Update pollAccountEntity -// pollAccountDAO.update(pollAccountEntity); - - vote.setPollAccount(pollAccountEntity); -// vote.setVotingListId(pollAccount.getVotingListId()); -// vote.setWeight(pollAccount.getWeight()); - log.debug("Poids du vote : " + vote.getWeight()); + } + return result; + } + + public Vote createVote(Vote vote) { VoteDAO voteDAO = getDAO(Vote.class); + VoteToChoiceDAO voteToChoiceDAO = getDAO(VoteToChoice.class); - Vote voteEntity = create(voteDAO); -// converter.setTransaction(transaction); -// converter.populateVoteEntity(vote, voteEntity); + Vote result = create(voteDAO); + result.setWeight(vote.getWeight()); + result.setAnonymous(vote.isAnonymous()); -// converter.populateChoiceVote(vote, voteEntity); + // -- PollAccount -- // + PollAccount pollAccount = vote.getPollAccount(); + 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()) { + pollAccountLoaded = getEntityById(PollAccount.class, pollAccountId); + } + // Create the new PollAccount + if (pollAccountLoaded == null) { + + PollAccountDAO pollAccountDAO = getDAO(PollAccount.class); + pollAccountLoaded = create(pollAccountDAO); + pollAccountLoaded.setAccountId(pollAccount.getAccountId()); + } + + // Update user data if not anonymous + if (!vote.isAnonymous()) { + + pollAccountLoaded.setVotingId(pollAccount.getVotingId()); + pollAccountLoaded.setEmail(pollAccount.getEmail()); + + UserAccount userAccount = pollAccount.getUserAccount(); + if (userAccount != null) { + UserAccount userAccountLoaded = getEntityById(UserAccount.class, userAccount.getTopiaId()); + pollAccountLoaded.setUserAccount(userAccountLoaded); + } + } + result.setPollAccount(pollAccountLoaded); + + // -- List of VoteToChoice -- // + for (VoteToChoice input : vote.getChoiceVoteToChoice()) { + + 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); + + result.addChoiceVoteToChoice(voteToChoiceCreated); + } + } + if (log.isDebugEnabled()) { - log.debug("Entity created: " + voteEntity.getTopiaId()); + log.debug("Entity created: " + result.getTopiaId()); } commitTransaction("Could not create vote"); - // email notification - - // feed notification - + return result; } public void updateVote(Vote vote) throws VoteNotFoundException { @@ -117,9 +193,31 @@ if (entityToUpdate == null) { throw new VoteNotFoundException(); } -// converter.setTransaction(transaction); -// converter.populateVoteEntity(voteDTO, voteEntity); + VoteToChoiceDAO voteToChoiceDao = getDAO(VoteToChoice.class); + + for (VoteToChoice input : vote.getChoiceVoteToChoice()) { + + Integer value = input.getVoteValue(); + + VoteToChoice voteToChoiceEntity = entityToUpdate.getChoiceVoteToChoice(input.getChoice()); + if (value != null) { + + if (voteToChoiceEntity == null) { + voteToChoiceEntity = create(voteToChoiceDao); + voteToChoiceEntity.setChoice(input.getChoice()); // very dangerous, bind with id + entityToUpdate.addChoiceVoteToChoice(voteToChoiceEntity); + } + voteToChoiceEntity.setVoteValue(value); + // update needed ?? + + } else if (voteToChoiceEntity != null) { + + entityToUpdate.removeChoiceVoteToChoice(voteToChoiceEntity); + delete(voteToChoiceDao, voteToChoiceEntity); + } + } + if (log.isDebugEnabled()) { log.debug("Entity updated: " + vote.getTopiaId()); } 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-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-03-23 17:15:58 UTC (rev 3205) @@ -23,9 +23,11 @@ */ package org.chorem.pollen.ui.actions.poll; +import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.interceptor.ParameterAware; import org.chorem.pollen.bean.PollResult; import org.chorem.pollen.bean.PollResultList; import org.chorem.pollen.business.persistence.Choice; @@ -48,6 +50,7 @@ import java.text.DateFormat; import java.util.Date; import java.util.List; +import java.util.Map; /** * Abstract action for actions on the vote poll page. @@ -55,33 +58,35 @@ * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ -public abstract class AbstractVoteAction extends AbstractPollUriIdAction { +public abstract class AbstractVoteAction extends AbstractPollUriIdAction implements ParameterAware { private static final long serialVersionUID = 1L; /** Logger. */ private static final Log log = LogFactory.getLog(AbstractVoteAction.class); - /** - * Keep this service as property to avoid new instance for each loop in - * {@link #getResultValue(Choice)} - */ private transient PollResultsService pollResultsService; + + private transient PollService pollService; + private transient VoteService voteService; + private Poll poll; private boolean feedFileExisting; + private String voteCountingTypeHelp; + private boolean creatorUser; private PollAccount pollAccount; private boolean alreadyVoted; - - private String voteCountingTypeHelp; - - private String accountName; + private List<Vote> votes; + + private Vote vote; + private String commentName; private String voteSizeMessage; @@ -89,19 +94,40 @@ private List<PollResult> results; private List<Comment> comments; + + private Map<String, String[]> parameters; @Override public String getPageLogo() { return "Vote"; } - private PollResultsService getPollResultsService() { + protected PollResultsService getPollResultsService() { if (pollResultsService == null) { pollResultsService = newService(PollResultsService.class); } return pollResultsService; } + + protected PollService getPollService() { + if (pollService == null) { + pollService = newService(PollService.class); + } + return pollService; + } + protected VoteService getVoteService() { + if (voteService == null) { + voteService = newService(VoteService.class); + } + return voteService; + } + + @Override + public void setParameters(Map<String, String[]> parameters) { + this.parameters = parameters; + } + public Poll getPoll() { return poll; } @@ -110,10 +136,31 @@ return feedFileExisting; } + public String getVoteCountingTypeHelp() { + return voteCountingTypeHelp; + } + public PollAccount getPollAccount() { return pollAccount; } + public List<Vote> getVotes() { + return votes; + } + + public Vote getVote() { + return vote; + } + + public VoteToChoice getVoteToChoice(int index) { + return getVote().getChoiceVoteToChoice().get(index); + } + + public boolean getVoteValueAsBoolean(int index) { + Integer value = getVoteToChoice(index).getVoteValue(); + return value == 1; + } + public boolean isPollChoiceOrVoteStarted() { Date now = serviceContext.getCurrentTime(); return poll.isAddChoiceStarted(now) || poll.isStarted(now); @@ -127,14 +174,6 @@ return poll.isAnonymous(); } - public String getVoteCountingTypeHelp() { - return voteCountingTypeHelp; - } - - public String getAccountName() { - return accountName; - } - public List<PollResult> getResults() { return results; } @@ -232,11 +271,19 @@ } public void resetCommentName() { - setCommentName(getAccountName()); + setCommentName(getPollAccount().getVotingId()); } 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); + } + loadPoll(); setDateFormat(DateFormat.getDateTimeInstance( @@ -244,6 +291,7 @@ DateFormat.SHORT, getLocale())); loadPollAccount(); + loadVotes(); loadPollResults(); loadPollComments(); @@ -356,14 +404,14 @@ } protected void loadPoll() throws PollNotFoundException { - - PollService service = newService(PollService.class); - + if (StringUtils.isNotEmpty(pollId)) { - poll = service.getPollByPollId(pollId); + poll = getPollService().getPollByPollId(pollId); } + Preconditions.checkNotNull(poll, "Can't load poll with id = [" + pollId + "]"); + + log.debug("Poll TopiaId: " + poll.getTopiaId()); - if (poll.isClosed()) { addActionMessage(_("pollen.information.pollClosed")); } else if (!isPollStarted()) { @@ -378,74 +426,72 @@ protected void loadPollAccount() throws PollNotFoundException { - PollService service = newService(PollService.class); - //// Contrôle et définition du votingId - alreadyVoted = false; - boolean modifAllowed = false; - boolean restrictedListsForbidden = false; +// alreadyVoted = false; +// boolean modifAllowed = false; +// boolean restrictedListsForbidden = false; - // The calcul of alreadyVoted will be needed for no double votingId - // Carefull, not correct for an anonymous vote - VoteService voteService = newService(VoteService.class); - // Suppression des espaces pouvant provoquer un double vote - pollAccount = service.getNewPollAccount(getPollenUserAccount()); - String votingId = pollAccount.getVotingId().trim(); - pollAccount.setVotingId(votingId); + // TODO maybe it's better to keep current pollAccount instead of creating one each time + pollAccount = getPollService().getNewPollAccount(getPollenUserAccount()); +// String votingId = pollAccount.getVotingId().trim(); +// pollAccount.setVotingId(votingId); +// +// // The calcul of alreadyVoted will be needed for no double votingId +// // Carefull, not correct for an anonymous vote +// alreadyVoted = getVoteService().hasAlreadyVoted(votingId, poll); +// +// // Check for restricted poll +// if (!alreadyVoted && !isFreePoll()) { +// +// if (StringUtils.isNotEmpty(getAccountId())) { +// +// // The accountUId must be valid for the poll +// PollAccount restrictedAccount = +// getPollService().getRestrictedAccount(getPollId(), getAccountId()); +// +// if (restrictedAccount != null) { +// // PollAccount is replaced by the good account from db +// pollAccount = restrictedAccount; +// +// // Refresh alreadyVoted value depends on pollAccount +//// alreadyVoted = pollAccount.isHasVoted(); +// +// } else { +// // Existing account is null is forbidden for a restricted poll +// restrictedListsForbidden = true; +// } +// +// } else { +// // Not allowed to vote without an accountUId +// restrictedListsForbidden = true; +// } +// +// if (restrictedListsForbidden) { +// addActionError(_("pollen.error.user.restrictedListsForbidden")); +// } +// } +// +// // Génération d'un identifiant de vote (si le sondage est libre et anonyme) +// if (poll.isAnonymous() && isFreePoll()) { +// getPollAccount().setVotingId( +// "anonymous" + serviceContext.createPollenUrlId()); +// } +// +// modifAllowed = isModifAllowed(getPollAccount().getVotingId()); +// if (alreadyVoted && !modifAllowed) { +// addActionError(_("pollen.error.user.alreadyVoted", +// getPollAccount().getVotingId())); +// } + } + + protected void loadVotes() { + + // TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount + votes = getPoll().getVote(); - alreadyVoted = voteService.hasAlreadyVoted(votingId, poll); - - // Check for restricted poll - if (!alreadyVoted && !isFreePoll()) { - - if (StringUtils.isNotEmpty(getAccountId())) { - - // The accountUId must be valid for the poll - PollAccount restrictedAccount = - service.getRestrictedAccount(getPollId(), getAccountId()); - - if (restrictedAccount != null) { - // PollAccount is replaced by the good account from db - pollAccount = restrictedAccount; - - // Refresh alreadyVoted value depends on pollAccount -// alreadyVoted = pollAccount.isHasVoted(); - - } else { - // Existing account is null is forbidden for a restricted poll - restrictedListsForbidden = true; - } - - } else { - // Not allowed to vote without an accountUId - restrictedListsForbidden = true; - } - - if (restrictedListsForbidden) { - addActionError(_("pollen.error.user.restrictedListsForbidden")); - } - } - - // Génération d'un identifiant de vote (si le sondage est libre et anonyme) - if (poll.isAnonymous() && isFreePoll()) { - getPollAccount().setVotingId( - "anonymous" + serviceContext.createPollenUrlId()); - } - - modifAllowed = isModifAllowed(getPollAccount().getVotingId()); - if (alreadyVoted && !modifAllowed) { - addActionError(_("pollen.error.user.alreadyVoted", - getPollAccount().getVotingId())); - } - - // Initialize accountName - UserAccount userAccount = getPollenUserAccount(); - if (userAccount != null) { - accountName = userAccount.getDisplayName(); - } else { - accountName = getPollAccount().getAccountId(); - } + // Current vote + vote = getVoteService().getVote(getPoll(), getVotes(), getPollAccount()); } protected void loadPollComments() { 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-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-03-23 17:15:58 UTC (rev 3205) @@ -24,6 +24,7 @@ package org.chorem.pollen.ui.actions.poll; import com.opensymphony.xwork2.Preparable; +import org.chorem.pollen.business.persistence.Vote; /** * Votes to a poll. @@ -35,6 +36,10 @@ private static final long serialVersionUID = 1L; + public void setVoteValueAsBoolean(int index, boolean value) { + getVoteToChoice(index).setVoteValue(value ? 1 : 0); + } + @Override public String input() throws Exception { @@ -44,9 +49,15 @@ @Override public String execute() throws Exception { + + if (getVote().getTopiaId() != null) { + getVoteService().updateVote(getVote()); + + } else { + Vote voteCreated = getVoteService().createVote(getVote()); + getPollService().addVoteToPoll(getPoll(), voteCreated); + } - //TODO Do me! - return SUCCESS; } 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-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-03-23 17:15:58 UTC (rev 3205) @@ -108,9 +108,9 @@ <interceptor-ref name="checkbox"/> <interceptor-ref name="multiselect"/> <interceptor-ref name="pollenFileUpload"/> - <interceptor-ref name="params"> +<!-- <interceptor-ref name="params"> <param name="excludeParams">dojo\..*,^struts\..*</param> - </interceptor-ref> + </interceptor-ref>--> <interceptor-ref name="servletConfig"/> <interceptor-ref name="staticParams"/> @@ -119,9 +119,9 @@ <interceptor-ref name="modelDriven"/> <!--<interceptor-ref name="staticParams"/>--> <interceptor-ref name="actionMappingParams"/> - <!--<interceptor-ref name="params">--> - <!--<param name="excludeParams">dojo\..*,^struts\..*</param>--> - <!--</interceptor-ref>--> + <interceptor-ref name="params"> + <param name="excludeParams">dojo\..*,^struts\..*</param> + </interceptor-ref> <interceptor-ref name="conversionError"/> <interceptor-ref name="validation"> <param name="excludeMethods">input,back,cancel,browse</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-23 17:15:49 UTC (rev 3204) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-03-23 17:15:58 UTC (rev 3205) @@ -161,6 +161,7 @@ autoOpen="false" modal="true" width="800"/> <s:form id="voteForm"> +<s:hidden key="uriId"/> <table id="poll"> <thead> <tr> @@ -257,32 +258,37 @@ <tr> <s:if test="accountFieldDisplayed"> <th id="voterName"> - <s:textfield id='pollAccountName' required="true" + <s:textfield key='pollAccount.votingId' required="true" value="%{pollAccount.votingId}" theme="simple"/> </th> </s:if> <s:else> <th></th> </s:else> - <s:iterator value="poll.choice" var="choice"> + <s:iterator value="poll.choice" var="choice" status="status"> <s:if test="!isChoiceHidden(#choice)"> <th> <s:if test="normalVoteCounting"> - <s:checkbox name="addChoice" theme="simple"/> + <s:checkbox name="voteValueAsBoolean[%{#status.index}]" + value="%{voteValueAsBoolean[#status.index]}" theme="simple"/> </s:if> <s:if test="percentageVoteCounting"> - <s:textfield value="#choice.value" size="3" required="true" - theme="simple"/> + <s:textfield name="voteToChoice[%{#status.index}].voteValue" + value="%{voteToChoice[#status.index].voteValue}" + required="true" size="3" theme="simple"/> <%--t:validate="required, min=0, max=100"/>%--%> </s:if> <s:if test="condorcetVoteCounting"> - <s:textfield id="condorcetInput" value="choice.value" size="3" - theme="simple"/> + <s:textfield name="voteToChoice[%{#status.index}].voteValue" + value="%{voteToChoice[#status.index].voteValue}" + id="condorcetInput" size="3" theme="simple"/> <%--t:nulls="zero" t:validate="min=0, max=99"/>--%> </s:if> <s:if test="numberVoteCounting"> - <s:textfield value="addNumberVote" size="3" theme="simple"/> + <s:textfield name="voteToChoice[%{#status.index}].voteValue" + value="%{voteToChoice[#status.index].voteValue}" + size="3" theme="simple"/> </s:if> </th> </s:if> @@ -292,7 +298,7 @@ </s:if> <tbody> <s:if test="!poll.anonymous"> - <s:iterator value="poll.vote" var="vote"> + <s:iterator value="votes" var="vote"> <tr> <td> <s:if test="accountFieldDisplayed">
participants (1)
-
fdesbois@users.chorem.org