Author: tchemit Date: 2012-02-22 23:25:51 +0100 (Wed, 22 Feb 2012) New Revision: 3141 Url: http://chorem.org/repositories/revision/pollen/3141 Log: - add application url in service context - vote comment is ok - Anomalie #119: [Comment] Pas de message de confirmation lors de la suppression d'un commentaire - Anomalie #175: [Comment] Impossible de supprimer des commentaires (ou alors c'est tr?\195?\168s long) - Anomalie #172: [Comment] Pagination des commentaires - Anomalie #171: [Comment] Ordre des commentaires bizarre Added: 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/ConfirmDeleteComment.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.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/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/Vote.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 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/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/resources/org/chorem/pollen/ui/actions/poll/AddComment-addComment-validation.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 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/jsp/poll/vote.jsp Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -25,6 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.ServletActionContext; import org.chorem.pollen.PollenConfiguration; import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.PollenTopiaRootContextFactory; @@ -42,6 +43,7 @@ import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import java.net.URL; import java.util.Date; import java.util.Locale; @@ -78,6 +80,13 @@ I18n.init(i18nInitializer, Locale.getDefault()); PollenApplicationContext applicationContext = new PollenApplicationContext(); + + URL url = PollenUIUtils.getApplicationBase(ServletActionContext.getRequest()); + if (log.isInfoEnabled()) { + log.info("Pollen application url : " + url); + } + applicationContext.setApplicationUrl(url); + sce.getServletContext().setAttribute(PollenActionSupport.APPLICATION_CONTEXT_PARAMETER, applicationContext); // initialize configuration Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -160,7 +160,8 @@ getLocale(), getTransaction(), getConfiguration(), - getServiceFactory() + getServiceFactory(), + getApplicationUrl() ); } return serviceContext; Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -80,7 +80,7 @@ String result = INPUT; try { - service.createUser(user, true, getApplicationUrl()); + service.createUser(user, true); getTransaction().commitTransaction(); addActionMessage( _("pollen.information.user.created", Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -24,7 +24,9 @@ package org.chorem.pollen.ui.actions.json; import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; import org.chorem.pollen.business.persistence.Comment; +import org.chorem.pollen.business.persistence.PollAccount; import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.entities.PollenBinderHelper; import org.chorem.pollen.services.impl.PollCommentService; @@ -32,6 +34,7 @@ import java.util.List; import java.util.Map; +import java.util.Set; /** * Get paginated list of poll comments. @@ -97,15 +100,29 @@ Comment.PROPERTY_TEXT, Comment.PROPERTY_POST_DATE ); - map.put("name", comment.getPollAccount().getVotingId()); + map.put(Comment.PROPERTY_POLL_ACCOUNT + "." + PollAccount.PROPERTY_VOTING_ID, + comment.getPollAccount().getVotingId()); map.put("id", comment.getTopiaId()); - boolean canDelete = pollService.isCanDeleteComment(comment, - userAccount); - map.put("canDelete", canDelete); + Set<String> functions = getCommentFunctions(pollService, + comment, + userAccount); + map.put("functions", functions); comments[index++] = map; } return SUCCESS; } + private Set<String> getCommentFunctions(PollCommentService pollService, + Comment comment, + UserAccount userAccount) { + Set<String> result = Sets.newHashSet(); + boolean canDelete = pollService.isCanDeleteComment(comment, + userAccount); + if (canDelete) { + result.add("delete"); + } + return result; + } + } \ No newline at end of file Added: 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 (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -0,0 +1,142 @@ +/* + * #%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.poll; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.Poll; +import org.chorem.pollen.business.persistence.UserAccount; +import org.chorem.pollen.common.VoteCountingType; +import org.chorem.pollen.services.exceptions.PollNotFoundException; +import org.chorem.pollen.services.impl.PollFeedService; +import org.chorem.pollen.services.impl.PollService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Abstract action for actions on the vote poll page. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public abstract class AbstractVoteAction extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String pollId; + + protected Poll poll; + + protected boolean feedFileExisting; + + protected String voteCountingTypeHelp; + + protected String defaultCommentName; + + protected String creatorName; + + protected String commentName; + + @Override + public final String getPageLogo() { + return "Vote"; + } + + public final String getPollId() { + return pollId; + } + + public final void setPollId(String pollId) { + this.pollId = pollId; + } + + public final Poll getPoll() { + return poll; + } + + public final boolean isFeedFileExisting() { + return feedFileExisting; + } + + public final String getVoteCountingTypeHelp() { + return voteCountingTypeHelp; + } + + public final String getDefaultCommentName() { + return defaultCommentName; + } + + public final String getCommentName() { + return commentName; + } + + public void prepareVotePage() throws Exception { + + loadPoll(); + + PollFeedService pollFeedService = newService(PollFeedService.class); + + feedFileExisting = pollFeedService.isFeedExists(poll); + + VoteCountingType voteCountingType = poll.getVoteCountingType(); + switch (voteCountingType) { + + case NORMAL: + voteCountingTypeHelp = + _("pollen.common.voteCountingTypeHelp.normal"); + break; + case PERCENTAGE: + voteCountingTypeHelp = + _("pollen.common.voteCountingTypeHelp.percentage"); + break; + case CONDORCET: + voteCountingTypeHelp = + _("pollen.common.voteCountingTypeHelp.condorcet"); + break; + case NUMBER: + voteCountingTypeHelp = + _("pollen.common.voteCountingTypeHelp.number"); + break; + } + + // set default comment name + UserAccount userAccount = getPollenSession().getUserAccount(); + if (userAccount == null) { + defaultCommentName = ""; + } else { + defaultCommentName = userAccount.getDisplayName(); + } + } + + protected void loadPoll() throws PollNotFoundException { + + Preconditions.checkNotNull(pollId); + + PollService service = newService(PollService.class); + + poll = service.getPollByPollId(pollId); + + if (poll == null) { + throw new PollNotFoundException(); + } + } +} \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.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/poll/AddComment.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddComment.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -24,11 +24,10 @@ package org.chorem.pollen.ui.actions.poll; import com.google.common.base.Preconditions; +import com.opensymphony.xwork2.interceptor.annotations.InputConfig; import org.chorem.pollen.business.persistence.Comment; -import org.chorem.pollen.business.persistence.Poll; import org.chorem.pollen.business.persistence.PollAccount; import org.chorem.pollen.services.impl.PollCommentService; -import org.chorem.pollen.ui.actions.PollenActionSupport; /** * To add a poll comment. @@ -36,63 +35,51 @@ * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ -public class AddComment extends PollenActionSupport { +public class AddComment extends AbstractVoteAction { private static final long serialVersionUID = 1L; - protected String pollId; + /** Text of the comment. */ + protected String commentText; - protected String name; - - protected String text; - - public String getPollId() { - return pollId; + public void setCommentName(String commentName) { + this.commentName = commentName; } - public void setPollId(String pollId) { - this.pollId = pollId; + public String getCommentText() { + return commentText; } - public String getName() { - return name; + public void setCommentText(String commentText) { + this.commentText = commentText; } - public void setName(String name) { - this.name = name; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - + @InputConfig(methodName = "prepareVotePage") @Override public String execute() throws Exception { - Preconditions.checkNotNull(pollId); - Preconditions.checkNotNull(text); - Preconditions.checkNotNull(name); + loadPoll(); + Preconditions.checkNotNull(commentName); + Preconditions.checkNotNull(commentText); + PollCommentService service = newService(PollCommentService.class); - Poll poll = service.getEntityById(Poll.class, pollId); - // prepare a new poll account for the comment PollAccount pollAccount = service.getNewPollAccount( - getPollenSession().getUserAccount(), name); + getPollenSession().getUserAccount(), commentName); // prepare a new comment - Comment comment = service.getNewComment(pollAccount, text); + Comment comment = service.getNewComment(pollAccount, commentText); // create the comment service.createComment(poll, comment); getTransaction().commitTransaction(); + // let's use back default comment name + commentName = getDefaultCommentName(); return SUCCESS; } + } Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -0,0 +1,71 @@ +/* + * #%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.poll; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.Comment; +import org.chorem.pollen.services.exceptions.PollCommentNotFound; +import org.chorem.pollen.services.impl.PollCommentService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * To confirm a comment delete. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class ConfirmDeleteComment extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + /** Id of the comment. */ + protected String commentId; + + /** Comment to delete. */ + protected Comment comment; + + public void setCommentId(String commentId) { + this.commentId = commentId; + } + + public Comment getComment() { + return comment; + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(commentId); + + PollCommentService service = newService(PollCommentService.class); + + comment = service.getEntityById(Comment.class, commentId); + + if (comment == null) { + throw new PollCommentNotFound(); + } + + return SUCCESS; + } +} \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ConfirmDeleteComment.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/poll/DeleteComment.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteComment.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -24,8 +24,10 @@ package org.chorem.pollen.ui.actions.poll; import com.google.common.base.Preconditions; +import com.opensymphony.xwork2.interceptor.annotations.InputConfig; +import org.chorem.pollen.business.persistence.Comment; +import org.chorem.pollen.services.exceptions.PollCommentNotFound; import org.chorem.pollen.services.impl.PollCommentService; -import org.chorem.pollen.ui.actions.PollenActionSupport; /** * To delete a poll comment. @@ -33,27 +35,39 @@ * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ -public class DeleteComment extends PollenActionSupport { +public class DeleteComment extends AbstractVoteAction { private static final long serialVersionUID = 1L; - protected String pollId; - + /** Id of the comment to delete. */ protected String commentId; + public void setCommentId(String commentId) { + this.commentId = commentId; + } + @InputConfig(methodName = "prepareVotePage") @Override public String execute() throws Exception { - Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(commentId); PollCommentService service = newService(PollCommentService.class); + Comment comment = service.getEntityById(Comment.class, commentId); + + if (comment == null) { + throw new PollCommentNotFound(); + } + + setPollId(comment.getPoll().getPollId()); + service.deleteComment(commentId); getTransaction().commitTransaction(); + commentName = getDefaultCommentName(); + return SUCCESS; } } Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -0,0 +1,88 @@ +/* + * #%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.poll; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.Poll; +import org.chorem.pollen.services.exceptions.PollNotFoundException; +import org.chorem.pollen.services.impl.PollFeedService; +import org.chorem.pollen.services.impl.PollService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +/** + * Obtain the feed of a given poll. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class GetFeed extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String pollId; + + protected long contentLength; + + protected transient InputStream stream; + + public String getPollId() { + return pollId; + } + + public long getContentLength() { + return contentLength; + } + + public InputStream getStream() { + return stream; + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(pollId); + + PollService service = newService(PollService.class); + + Poll poll = service.getPollByPollId(pollId); + + if (poll == null) { + throw new PollNotFoundException(); + } + + PollFeedService pollFeedService = newService(PollFeedService.class); + + File feedLocation = pollFeedService.getFeedLocation(poll); + + contentLength = feedLocation.length(); + + stream = new FileInputStream(feedLocation); + + return SUCCESS; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/GetFeed.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/poll/Vote.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/Vote.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -23,7 +23,7 @@ */ package org.chorem.pollen.ui.actions.poll; -import org.chorem.pollen.ui.actions.PollenActionSupport; +import com.opensymphony.xwork2.Preparable; /** * Votes to a poll. @@ -31,7 +31,29 @@ * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ -public class Vote extends PollenActionSupport { +public class Vote extends AbstractVoteAction implements Preparable { private static final long serialVersionUID = 1L; + + @Override + public String input() throws Exception { + + //TODO DO me! + return INPUT; + } + + @Override + public String execute() throws Exception { + + //TODO Do me! + + return SUCCESS; + } + + @Override + public void prepare() throws Exception { + + prepareVotePage(); + commentName = getDefaultCommentName(); + } } Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Register.java 2012-02-22 22:25:51 UTC (rev 3141) @@ -70,7 +70,7 @@ String result = INPUT; try { - UserAccount createdUser = service.createUser(user, false, getApplicationUrl()); + UserAccount createdUser = service.createUser(user, false); getTransaction().commitTransaction(); getPollenSession().setUserAccount(createdUser); 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-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-02-22 22:25:51 UTC (rev 3141) @@ -101,6 +101,13 @@ <result type="json"/> </action> + <!-- get pagined poll comments --> + <action name="getPollComments" + class="org.chorem.pollen.ui.actions.json.GetPollComments"> + <interceptor-ref name="pollenBasicStack"/> + <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-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-02-22 22:25:51 UTC (rev 3141) @@ -32,6 +32,16 @@ <package name="poll" extends="default" namespace="/poll"> + <result-types> + <result-type name="redirectToVote" + class="org.apache.struts2.dispatcher.ServletActionRedirectResult"> + <param name="namespace">/poll</param> + <param name="actionName">vote</param> + <param name="method">input</param> + <param name="pollId">${pollId}</param> + </result-type> + </result-types> + <!-- create poll --> <action name="create" class="org.chorem.pollen.ui.actions.poll.Create"> @@ -104,20 +114,35 @@ <result>/WEB-INF/jsp/home.jsp</result> </action> + <!-- confirm delete comment --> + <action name="confirmDeleteComment" + class="org.chorem.pollen.ui.actions.poll.ConfirmDeleteComment"> + <result>/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp</result> + </action> + <!-- add a poll comment --> <action name="addComment" class="org.chorem.pollen.ui.actions.poll.AddComment"> <result name="input">/WEB-INF/jsp/poll/vote.jsp</result> - <result>/WEB-INF/jsp/poll/vote.jsp</result> + <result type="redirectToVote"/> </action> <!-- delete a poll comment --> <action name="deleteComment" class="org.chorem.pollen.ui.actions.poll.DeleteComment"> - <result name="input">/WEB-INF/jsp/poll/vote.jsp</result> - <result>/WEB-INF/jsp/poll/vote.jsp</result> + <result type="redirectToVote"/> </action> + <!-- get the feed of a given poll --> + <action name="getFeed" class="org.chorem.pollen.ui.actions.poll.GetFeed"> + <result type="stream"> + <param name="contentCharSet">UTF-8</param> + <param name="contentType">application/atom+xml</param> + <param name="encode">true</param> + <param name="bufferSize">4096</param> + </result> + </action> + </package> 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-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-02-22 22:25:51 UTC (rev 3141) @@ -1,5 +1,11 @@ +poll.common.aboutPoll=About the poll +poll.common.comments=Comments about this poll poll.common.select.choiceType=Select the type of choice poll.common.select.userFavoriteList=List +poll.common.vote.results=Results +poll.common.vote.results-help=Display results +poll.legend.addNewComment=Add a comment +pollen.action.addComment=Add pollen.action.backToFavoriteLists=Back to favorite lists pollen.action.create=Create pollen.action.createFavoriteList=Create a new list @@ -17,6 +23,7 @@ pollen.action.modify=Modify pollen.action.pollClone=Copy the poll to create a new one pollen.action.pollClose=Close the poll +pollen.action.pollCommentDelete=Supprimer le commentaire pollen.action.pollDelete=Delete the poll pollen.action.pollEdit=Edit poll pollen.action.pollExport=Export poll @@ -29,6 +36,8 @@ pollen.common.beginChoiceDate=Begin choice date pollen.common.beginDate=Begin date pollen.common.bugReport=Bug report +pollen.common.commentName=Name +pollen.common.commentText=Comment pollen.common.csvImport=CSV import pollen.common.description=Description pollen.common.email=Em@il @@ -47,6 +56,7 @@ pollen.common.or=or pollen.common.password=Password pollen.common.password2=Renter your password +pollen.common.pollCreator=Creator pollen.common.pollOption.anonymous=Anonymous pollen.common.pollOption.anonymousVoteAllowed=Anonymous vote allowed pollen.common.pollOption.choiceAddAllowed=Allow adding choices @@ -59,9 +69,14 @@ pollen.common.pollOption.reminder=Send reminder emails pollen.common.pollOption.reminderHourCountdown=Hours before end pollen.common.pollType=Poll type +pollen.common.postDate=Comment date pollen.common.title=Title pollen.common.userSupport=User support pollen.common.voteCountingType=Counting type +pollen.common.voteCountingTypeHelp.condorcet=Condorcet vote\: rank choices by preference order from 1 to N (1\=favorite). Only the rank is taken into account, not the values. Two choices can have the same value. +pollen.common.voteCountingTypeHelp.normal=Normal vote\: vote for your favorite choice. +pollen.common.voteCountingTypeHelp.number=Voting by number\: The answer is free, leave blank or enter a integer. +pollen.common.voteCountingTypeHelp.percentage=Percentage vote\: allocate choices to get a 100%% total. 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 @@ -72,6 +87,7 @@ pollen.error.favoriteList.participant.not.found.in.list=Member not found in favorite list pollen.error.favoriteListName.required=List name mandatory pollen.error.login.required=You must provide a login +pollen.error.no.poll.found=Poll not found with id %s pollen.error.password.required=Your must provide a password pollen.error.password2.required=You must repeat your password for confirmation pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques @@ -124,6 +140,7 @@ pollen.menu.register=Register pollen.menu.userFavoriteLists=Voting lists pollen.title.createPoll=New poll +pollen.title.delete.comment=Confirm to delete a poll comment pollen.title.editFavoriteList=Edition de la liste des favoris pollen.title.favoriteLists=Vos listes de votants pollen.title.myAccount=My account 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-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-02-22 22:25:51 UTC (rev 3141) @@ -1,5 +1,11 @@ +poll.common.aboutPoll=A propos du sondage +poll.common.comments=Commentaire à propos du sondage poll.common.select.choiceType=Sélectionner le type de choix poll.common.select.userFavoriteList=Liste +poll.common.vote.results=Résultats +poll.common.vote.results-help=Voir les résultats +poll.legend.addNewComment=Ajouter un commentaire +pollen.action.addComment=Ajouter pollen.action.backToFavoriteLists=Retour à la liste des favoris pollen.action.create=Créer pollen.action.createFavoriteList=Créer une ouvelle liste @@ -17,6 +23,7 @@ pollen.action.modify=Modifier pollen.action.pollClone=Créer un nouveau sondage à partir de celui-ci pollen.action.pollClose=Fermer le sondage +pollen.action.pollCommentDelete=Supprimer le commentaire pollen.action.pollDelete=Supprimer le sondage pollen.action.pollEdit=Editer le sondage pollen.action.pollExport=Exporter le sondage @@ -29,6 +36,8 @@ pollen.common.beginChoiceDate=Date de début des choix pollen.common.beginDate=Date de début pollen.common.bugReport=Rapport de bug +pollen.common.commentName=Nom +pollen.common.commentText=Commentaire pollen.common.csvImport=Import CSV pollen.common.description=Description pollen.common.email=Em@il @@ -47,6 +56,7 @@ pollen.common.or=ou pollen.common.password=Mot de passe pollen.common.password2=Répétez votre mot de passe +pollen.common.pollCreator=Créateur pollen.common.pollOption.anonymous=Sondage anonyme pollen.common.pollOption.anonymousVoteAllowed=Autoriser le vote anonyme pollen.common.pollOption.choiceAddAllowed=Autoriser l'ajout de choix @@ -59,9 +69,14 @@ pollen.common.pollOption.reminder=Envoyer des emails de rappel pollen.common.pollOption.reminderHourCountdown=heures avant la fin du sondage pollen.common.pollType=Type de sondage +pollen.common.postDate=Date du commentaire pollen.common.title=Titre pollen.common.userSupport=Support utilisateur pollen.common.voteCountingType=Type de dépouillement +pollen.common.voteCountingTypeHelp.condorcet=Vote Condorcet \: classer les choix par ordre de préférence de 1 à N (1\=préféré). Seul l'ordre des choix compte, peu importe les valeurs. Deux choix peuvent avoir la même valeur. +pollen.common.voteCountingTypeHelp.normal=Vote normal \: voter pour le ou les choix préférés. +pollen.common.voteCountingTypeHelp.number=Vote par nombre \: La réponse est libre, laissez vide ou entrez un nombre entier +pollen.common.voteCountingTypeHelp.percentage=Vote par pourcentage \: répartir les choix de manière à obtenir 100%% au total. pollen.common.x=Dépouillement pollen.error.comment.name.empty=Nom du commentaire obligatoire pollen.error.comment.text.empty=Texte du commentaire obligatoire @@ -73,6 +88,7 @@ pollen.error.favoriteList.participant.not.found.in.list=Membre non trouvé dans la liste pollen.error.favoriteListName.required=Nom de liste obligatoire pollen.error.login.required=Login obligatoire +pollen.error.no.poll.found=Sondage non trouvé avec l'id %s pollen.error.password.required=Mot de passe obligatoire pollen.error.password2.required=Mot de passe répété obligatoire pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques @@ -125,6 +141,7 @@ pollen.menu.register=Inscrivez-vous pollen.menu.userFavoriteLists=Listes de votants pollen.title.createPoll=Nouveau sondage +pollen.title.delete.comment=Confirmer la suppresion d'un commentaire pollen.title.editFavoriteList=Edition de la liste des favoris pollen.title.favoriteLists=Vos listes de votants pollen.title.myAccount=Mon compte Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AddComment-addComment-validation.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AddComment-addComment-validation.xml 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AddComment-addComment-validation.xml 2012-02-22 22:25:51 UTC (rev 3141) @@ -30,14 +30,14 @@ <validators> - <field name="name"> + <field name="commentName"> <field-validator type="requiredstring"> <message key="pollen.error.comment.name.empty"/> </field-validator> </field> - <field name="text"> + <field name="commentText"> <field-validator type="requiredstring"> <message key="pollen.error.comment.text.empty"/> 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-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-02-22 22:25:51 UTC (rev 3141) @@ -259,7 +259,7 @@ <a href="http://www.gnu.org/licenses/gpl.html"> <s:text name="pollen.common.license"/> </a> - - <span title="Copyright">©2009-${currentYear}</span> + <span title="Copyright">©2009-2012</span> <a href="http://www.codelutin.com">Code Lutin</a> - <a href="http://www.chorem.org/projects/pollen/issues"> <s:text name="pollen.common.bugReport"/> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 2012-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 2012-02-22 22:25:51 UTC (rev 3141) @@ -29,6 +29,7 @@ <pattern>/images/*</pattern> <pattern>/config-browser/*</pattern> <pattern>/json/*</pattern> + <pattern>/poll/confirmDelete*</pattern> </excludes> <decorator name="layout-default" page="layout-default.jsp"> Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollcomment.jsp 2012-02-22 22:25:51 UTC (rev 3141) @@ -0,0 +1,45 @@ +<%-- + #%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 contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + +<s:form method="POST" namespace="/poll" action="deleteComment"> + + <s:hidden name="pollId" value='%{comment.poll.pollId}'/> + + <s:hidden name="commentId" value='%{comment.topiaId}'/> + + <s:textfield key='comment.postDate' readonly="true" size="50" + label="%{getText('pollen.common.postDate')}"/> + + <s:textfield key='comment.pollAccount.votingId' readonly="true" size="50" + label="%{getText('pollen.common.commentName')}"/> + + <s:textarea key='comment.text' readonly="true" rows="3" + label="%{getText('pollen.common.commentText')}"/> + + <div class="cleanBoth"> + <s:submit key="pollen.action.delete" align="center"/> + </div> +</s:form> \ 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/confirmDeletePollcomment.jsp ___________________________________________________________________ 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/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-02-22 22:23:54 UTC (rev 3140) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-02-22 22:25:51 UTC (rev 3141) @@ -21,5 +21,142 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<h2>vote poll TODO</h2> \ No newline at end of file +<%@page contentType="text/html" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> + +<script type="text/javascript" + src="<s:url value='/js/gridHelper.js' />"></script> + +<s:url id="deleteUrl" action="confirmDeleteComment" namespace="/poll"/> + +<s:url id='deleteImg' value='/img/delete.png'/> +<s:set id='deleteTitle'><s:text name="pollen.action.pollCommentDelete"/></s:set> + +<script type="text/javascript"> + + function commentFunctions(cellvalue, options, rowObject) { + + var id = rowObject.id; + + var result = ""; + + if (cellvalue.indexOf('delete') > -1) { + var url = "openDialog(\""+ id + "\"); return false;"; + result += formatLink(id, url, "${deleteImg}", "Delete", "${deleteTitle}") + } + return result; + } + function formatLink(id, baseUrl, image, imageAlt, imageTitle) { + //var url = $.prepareUrl(baseUrl, {commentId:id}); + return "<a href='#' onclick='" + baseUrl + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>"; +// return "<a href='" + url + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>"; + } + + function openDialog(commentId) { + var dialog = $("#deleteCommentDialog"); + var url = $.prepareUrl("${deleteUrl}", {commentId:commentId}); + dialog.load(url); + dialog.dialog('open'); + } +</script> + +<h1 class="titleVote"><s:property value="poll.title"/></h1> + +<!-- Informations sur le sondage --> + +<div id="pollTop"> + <div style="white-space:pre-wrap; text-align: start;"> + <s:property value="poll.description"/> + </div> + <fieldset> + <legend><s:text name="poll.common.aboutPoll"/></legend> + <div style="float: right"> + <s:if test="poll.publicResults"> + + <s:a namespace="/poll" action="result" method="input"> + <s:param name="pollId" value="poll.pollId"/> + <img src="<s:url value='/img/count.png'/>" + title="<s:text name="poll.common.vote.results-help"/>" + alt="<s:text name="poll.common.vote.results"/>"/> + </s:a> + </s:if> + <t:FeedContextLink t:id="feedContext"/> + <s:if test="feedFileExisting"> + <s:a namespace="/poll" action="getFeed" method="input"> + <s:param name="pollId" value="poll.pollId"/> + <img src="<s:url value='/img/feed.png'/>" title="Atom" alt="Atom"/> + </s:a> + </s:if> + </div> + <s:label value="%{poll.creator.votingId}" key='pollen.common.pollCreator'/> + <s:label value="%{poll.beginDate}" key='pollen.common.beginDate'/> + <s:label value="%{poll.endDate}" + label='%{getText("pollen.common.endDate")}'/> + <s:label value="%{poll.voteCountingType}" + label='%{getText("pollen.common.voteCountingType")}' + tooltip="%{voteCountingTypeHelp}" tooltipIconPath="/img/help.png"/> + </fieldset> +</div> + + +<!-- Ajout de commentaires --> + +<h3><s:text name="poll.common.comments"/></h3> + +<div id="commentsDiv"> + + <s:url id="loadPollComments" action="getPollComments" namespace="/json" + escapeAmp="false"> + <s:param name="pollId" value="%{poll.pollId}"/> + </s:url> + + <sjg:grid id="comments" dataType="json" href="%{loadPollComments}" + gridModel="comments" sortable="true" pager="true" + pagerButtons="true" pagerInput="true" navigator="true" + rownumbers="false" autowidth="true" editinline="false" + navigatorEdit="false" navigatorDelete="false" + navigatorSearch="false" navigatorRefresh="false" + navigatorAdd="false" viewrecords="true" sortorder="desc" + sortname="postDate" rowList="10,15,20,50,100" rowNum="10"> + + <sjg:gridColumn name="id" title="id" hidden="true"/> + <sjg:gridColumn name="postDate" title='%{getText("pollen.common.postDate")}' + sortable="true" formatter="date" width="50" + formatoptions="{newformat : 'd.m.Y H:i', srcformat : 'Y-m-d H:i:s'}"/> + <sjg:gridColumn name="pollAccount.votingId" + title='%{getText("pollen.common.commentName")}' + sortable="true"/> + <sjg:gridColumn name="text" title='%{getText("pollen.common.commentText")}' + sortable="true"/> + <sjg:gridColumn name="functions" sortable="false" title='' width="10" + formatter="commentFunctions"/> + </sjg:grid> +</div> + +<br/> + +<%--<div id="commentFormDiv">--%> + +<fieldset> + <legend><s:text name="poll.legend.addNewComment"/></legend> + <s:form id='addCommentForm' method="POST" namespace="/poll"> + <s:hidden key="pollId" label=''/> + <s:textfield key="commentName" required="true" + 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"/> + </div> + </s:form> +</fieldset> +<%--</div>--%> + +<sj:dialog id="deleteCommentDialog" + title="%{getText('pollen.title.delete.comment')}" + autoOpen="false" modal="true" width="800"/> +