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
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>
participants (1)
-
fdesbois@users.chorem.org