Author: echatellier Date: 2010-03-16 11:22:18 +0100 (Tue, 16 Mar 2010) New Revision: 2949 Log: Fix poll description format. Fix line break in chenillekit tooltips. Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java =================================================================== --- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-16 08:59:17 UTC (rev 2948) +++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/VoteForPoll.java 2010-03-16 10:22:18 UTC (rev 2949) @@ -27,6 +27,8 @@ import java.util.Map; import java.util.UUID; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.EventContext; import org.apache.tapestry5.ValidationException; @@ -1244,4 +1246,24 @@ } return votes; } + + /** + * This method is used in tapestry template to escape line break string. + * + * Used for chenillekit tooltip for example. + * + * @param nonEscapedString non escaped string + * @return html escaped string + */ + public String escapeLineBreak(String nonEscapedString) { + + if (nonEscapedString == null) { + return null; + } + + String localStr = nonEscapedString.replaceAll("\n", "<br />"); + localStr = localStr.replaceAll("\r", ""); + + return localStr; + } } Modified: branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml =================================================================== --- branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-16 08:59:17 UTC (rev 2948) +++ branches/pollen-1.2.5-1.2.x/pollen-ui/src/main/webapp/poll/VoteForPoll.tml 2010-03-16 10:22:18 UTC (rev 2949) @@ -10,7 +10,7 @@ <!-- Informations sur le sondage --> <div id="pollTop"> - ${poll.description} + <div style="white-space:pre-wrap; text-align: start;">${poll.description}</div> <fieldset> <legend>${message:about}</legend> <div style="float: right"> @@ -69,7 +69,7 @@ <t:if test="!isChoiceHidden()"> <th> <t:unless test="isDescNull()"> - <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind"> + <span t:type="ck/Tooltip" title="${message:description}" value="${escapeLineBreak(choiceOfPoll.description)}" effect="blind"> <span class="desc">${choiceOfPoll.name}</span> </span> <p:else> @@ -92,7 +92,7 @@ <t:if test="!isChoiceHidden()"> <t:unless test="isDescNull()"> <th class="desc"> - <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind"> + <span t:type="ck/Tooltip" title="${message:description}" value="${escapeLineBreak(choiceOfPoll.description)}" effect="blind"> <t:output value="choiceNameAsDate" format="dateFormat"/> </span> </th> @@ -111,7 +111,7 @@ <t:if test="!isChoiceHidden()"> <t:unless test="isDescNull()"> <th class="desc"> - <span t:type="ck/Tooltip" title="${message:description}" value="${choiceOfPoll.description}" effect="blind"> + <span t:type="ck/Tooltip" title="${message:description}" value="${escapeLineBreak(choiceOfPoll.description)}" effect="blind"> <t:image t:src="choiceOfPoll.name" alt="choiceOfPoll.description" t:dir="poll.pollId"/> </span> </th>