r3542 - in trunk/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/io java/org/chorem/pollen/ui/actions/poll webapp/WEB-INF/jsp/poll
Author: tchemit Date: 2012-06-20 12:46:32 +0200 (Wed, 20 Jun 2012) New Revision: 3542 Url: http://chorem.org/repositories/revision/pollen/3542 Log: refs #613: No thumbnail and image if accents in image name (vote + result page) + clean some jsp Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/io/GetPollImageChoice.java 2012-06-20 10:46:32 UTC (rev 3542) @@ -22,6 +22,7 @@ */ package org.chorem.pollen.ui.actions.io; +import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; import org.chorem.pollen.ui.actions.PollenActionSupport; @@ -30,6 +31,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import java.net.URLDecoder; /** * Obtain the image choice of a given choice of an image-like poll. @@ -93,8 +95,12 @@ Preconditions.checkNotNull(pollId); Preconditions.checkNotNull(choiceId); - file = getPollService().getPollChoiceImageFile(pollId, choiceId); + // decode choice Id + String choiceName = URLDecoder.decode(choiceId, + Charsets.UTF_8.name()); + file = getPollService().getPollChoiceImageFile(pollId, choiceName); + if (thumb) { file = getPollService().getImageThumbFile(file); Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-20 10:46:32 UTC (rev 3542) @@ -215,17 +215,6 @@ public abstract boolean isEdit(); - public String getImagechoicesThumbPrefix(Choice choice) { - String name = choice.getName(); - try { - String result = URLEncoder.encode(IMAGECHOICES_THUMB_PREFIX + name, Charsets.UTF_8.name()); - return result; - } catch (UnsupportedEncodingException e) { - throw new PollenTechnicalException( - "Could not encode name " + name, e); - } - } - @Override public void setServletRequest(HttpServletRequest request) { this.request = request; @@ -504,12 +493,6 @@ poll.setMaxChoiceNb(0); } -// if (!poll.isPublicResults()) { -// -// // force to not have continous results -// poll.setContinuousResults(false); -// } - if (poll.isAnonymous()) { // force to not have choice to vote anonymously @@ -731,6 +714,17 @@ return creator.getUserAccount() != null; } + public String getImageChoiceName(Choice choice) { + String name = choice.getName(); + try { + String result = URLEncoder.encode(IMAGECHOICES_THUMB_PREFIX + name, Charsets.UTF_8.name()); + return result; + } catch (UnsupportedEncodingException e) { + throw new PollenTechnicalException( + "Could not encode name " + name, e); + } + } + public void prepareFormPage() throws Exception { getPollenSession().removeDynamicDataWithPrefix(IMAGECHOICES_THUMB_PREFIX); @@ -1320,7 +1314,7 @@ // keep in session the location of this thumb (do not // want to expose the full path location in url) - String key = getImagechoicesThumbPrefix(choice); + String key = getImageChoiceName(choice); getPollenSession().putDynamicData(key, thumbFile); } } Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-20 10:46:32 UTC (rev 3542) @@ -22,12 +22,14 @@ */ package org.chorem.pollen.ui.actions.poll; +import com.google.common.base.Charsets; 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.apache.struts2.interceptor.ServletRequestAware; +import org.chorem.pollen.PollenTechnicalException; import org.chorem.pollen.bean.PollResult; import org.chorem.pollen.bean.PollResultList; import org.chorem.pollen.bean.PollUrl; @@ -48,6 +50,8 @@ import org.chorem.pollen.ui.actions.PageSkin; import javax.servlet.http.HttpServletRequest; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import java.util.List; import java.util.Map; @@ -489,6 +493,17 @@ return text; } + public String getImageChoiceName(Choice choice) { + String name = choice.getName(); + try { + String result = URLEncoder.encode(name, Charsets.UTF_8.name()); + return result; + } catch (UnsupportedEncodingException e) { + throw new PollenTechnicalException( + "Could not encode name " + name, e); + } + } + protected void loadPollAccount() throws PollAccountNotFound { // Current poll account Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-06-20 10:46:32 UTC (rev 3542) @@ -142,7 +142,7 @@ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage" escapeAmp="true"> <s:param name="choiceTokenId" - value="%{getImagechoicesThumbPrefix(#choice)}"/> + value="%{getImageChoiceName(#choice)}"/> </s:url> <img name="<s:property value="#prefix"/>.thumb" alt="<s:property value='name'/>" @@ -151,8 +151,7 @@ class="fleft choiceImage"> <s:file key='imageChoice[%{#choiceNumber}]' label='' theme="simple" - class="fright" - cssStyle="opacity: 0;"/> + class="fright" cssStyle="opacity: 0;"/> </s:if> <s:else> <%--New image--%> @@ -164,8 +163,7 @@ src="<s:property value='imageUrl'/>" width="100px" height="75px" class="fleft choiceImage"> <s:file key='imageChoice[%{#choiceNumber}]' label='' theme="simple" - class="fright" - cssStyle="opacity: 0;"/> + class="fright" cssStyle="opacity: 0;"/> </s:else> </div> Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp 2012-06-20 10:46:32 UTC (rev 3542) @@ -42,24 +42,10 @@ displayFormat="%{getText('pollen.common.datePickerPattern')}"/> </div> <div class="fright"> - <%--s:a id='choicesDATE_down_%{choiceNumber}' - cssClass="hidden" href='#' - onclick="return downChoice('choicesDATE_%{choiceNumber}')"> - <image alt='<s:property value="downTitle"/>' - title='<s:property value="downTitle"/>' - src="<s:url value='/img/1downarrow.png'/>"></image> - </s:a> - <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden" - onclick="return upChoice('choicesDATE_%{choiceNumber}')"> - <image alt='<s:property value="upTitle"/>' - title='<s:property value="upTitle"/>' - src="<s:url value='/img/1uparrow.png'/>"></image> - </s:a--%> <s:label for="%{#prefix}.description" key="pollen.common.description" theme="simple"/> - <s:textarea cols="30" id="%{#prefix}.description" - key="%{#prefix}.description" label='' theme="simple" - value="%{choice.description}"/> + <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple" + key="%{#prefix}.description" value="%{choice.description}"/> <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')"> <image alt='<s:property value="deleteTitle"/>' title='<s:property value="deleteTitle"/>' Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp 2012-06-20 10:46:32 UTC (rev 3542) @@ -46,26 +46,11 @@ title="<s:text name='pollen.image.not.loaded'/>" src="<s:property value='imageUrl'/>" width="100px" height="75" class="fleft choiceImage"> - <s:file key='%{#prefix2}' label='' - theme="simple" - class="fright" + <s:file key='%{#prefix2}' label='' theme="simple" class="fright" cssStyle="opacity: 0;"/> </div> </div> <div class="fright"> - <%--s:a id='choicesIMAGE_down_%{choiceNumber}' - cssClass="hidden" href='#' - onclick="return downChoice('choicesIMAGE_%{choiceNumber}')"> - <image alt='<s:property value="downTitle"/>' - title='<s:property value="downTitle"/>' - src="<s:url value='/img/1downarrow.png'/>"></image> - </s:a> - <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden" - onclick="return upChoice('choicesIMAGE_%{choiceNumber}')"> - <image alt='<s:property value="upTitle"/>' - title='<s:property value="upTitle"/>' - src="<s:url value='/img/1uparrow.png'/>"></image> - </s:a--%> <s:label for="%{#prefix}.description" key="pollen.common.description" theme="simple"/> <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple" Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp 2012-06-20 10:46:32 UTC (rev 3542) @@ -39,19 +39,6 @@ label='' theme="simple" value="%{choice.name}"/> </div> <div class="fright"> - <%--s:a id='choicesTEXT_down_%{choiceNumber}' - cssClass="hidden" href='#' - onclick="return downChoice('choicesTEXT_%{choiceNumber}')"> - <image alt='<s:property value="downTitle"/>' - title='<s:property value="downTitle"/>' - src="<s:url value='/img/1downarrow.png'/>"></image> - </s:a> - <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden" - onclick="return upChoice('choicesTEXT_%{choiceNumber}')"> - <image alt='<s:property value="upTitle"/>' - title='<s:property value="upTitle"/>' - src="<s:url value='/img/1uparrow.png'/>"></image> - </s:a--%> <s:label for="%{#prefix}.description" key="pollen.common.description" theme="simple"/> <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple" Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-20 10:00:52 UTC (rev 3541) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-20 10:46:32 UTC (rev 3542) @@ -244,13 +244,13 @@ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage" escapeAmp="false"> - <s:param name="choiceId" value="name"/> + <s:param name="choiceId" value="%{getImageChoiceName(#choice)}"/> <s:param name="pollId" value="poll.pollId"/> <s:param name="thumb" value="false"/> </s:url> <s:url id="imageUrlThumb" namespace="/io" action="getPollChoiceImage" escapeAmp="false"> - <s:param name="choiceId" value="name"/> + <s:param name="choiceId" value="%{getImageChoiceName(#choice)}"/> <s:param name="pollId" value="poll.pollId"/> <s:param name="thumb" value="true"/> </s:url>
participants (1)
-
tchemit@users.chorem.org