tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertdzeig...@apache.org
Subject svn commit: r1171593 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/corelib/components/ main/java/org/apache/tapestry5/internal/services/ main/resources/org/apache/tapestry5/ main/resources/org/apache/tapestry5/corelib...
Date Fri, 16 Sep 2011 14:35:20 GMT
Author: robertdzeigler
Date: Fri Sep 16 14:35:20 2011
New Revision: 1171593

URL: http://svn.apache.org/viewvc?rev=1171593&view=rev
Log:
TAP5-1652: template expansion no longer trims whitespace off the right side of the expansion
TAP5-1633: Hardcoded value for "Dismiss All" in AlertManager

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/Alerts.properties
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/expansions_with_whitespace.tml
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SaxTemplateParser.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MapExpressionInExpansions.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Alerts.java
Fri Sep 16 14:35:20 2011
@@ -20,8 +20,10 @@ import org.apache.tapestry5.MarkupWriter
 import org.apache.tapestry5.alerts.Alert;
 import org.apache.tapestry5.alerts.AlertStorage;
 import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.Parameter;
 import org.apache.tapestry5.annotations.RequestParameter;
 import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.BindingConstants;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.json.JSONObject;
 import org.apache.tapestry5.services.javascript.InitializationPriority;
@@ -37,6 +39,10 @@ import org.apache.tapestry5.services.jav
  */
 public class Alerts implements ClientElement
 {
+
+    @Parameter(value="message:dismiss-label", defaultPrefix=BindingConstants.LITERAL)
+    private String dismissText;
+
     @Inject
     private ComponentResources resources;
 
@@ -61,7 +67,8 @@ public class Alerts implements ClientEle
         writer.end();
 
         JSONObject spec = new JSONObject("id", clientId,
-                "dismissURL", resources.createEventLink("dismiss").toURI());
+                "dismissURL", resources.createEventLink("dismiss").toURI(),
+                "dismissText", dismissText);
 
         javaScriptSupport.addInitializerCall(InitializationPriority.EARLY, "alertManager",
spec);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SaxTemplateParser.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SaxTemplateParser.java?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SaxTemplateParser.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SaxTemplateParser.java
Fri Sep 16 14:35:20 2011
@@ -133,7 +133,6 @@ public class SaxTemplateParser
     private static final char EXPANSION_STRING_DELIMITTER='\'';
     private static final char OPEN_BRACE='{';
     private static final char CLOSE_BRACE='}';
-    //private static final Pattern EXPANSION_PATTERN = Pattern.compile("\\$\\{\\");
 
     private static final Set<String> MUST_BE_ROOT = CollectionFactory.newSet("extend",
"container");
 
@@ -1157,7 +1156,7 @@ public class SaxTemplateParser
                 //can't just assign to 
                 startx=matcher.start(1) + expressionEnd + 1;
             } else {
-                tokenAccumulator.add(new ExpansionToken(expression, textStartLocation));
+                tokenAccumulator.add(new ExpansionToken(expression.trim(), textStartLocation));
 
                 startx = matcher.end();
             }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/Alerts.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/Alerts.properties?rev=1171593&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/Alerts.properties
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/Alerts.properties
Fri Sep 16 14:35:20 2011
@@ -0,0 +1 @@
+dismiss-label=Dismiss all

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-alerts.js
Fri Sep 16 14:35:20 2011
@@ -6,9 +6,9 @@ T5.extendInitializers(function() {
         var DISMISS_ALERTS = "tapestry:dismiss-all";
         var addAlertPublisher = T5.pubsub.createPublisher(T5.events.ADD_ALERT, document);
 
-        function construct(clientId) {
+        function construct(clientId, dismissText) {
             $(clientId).innerHTML = "<div class='t-alert-container'></div>" +
-                "<div class='t-alert-controls'><a href='#'>Dismiss all</a></div>";
+                "<div class='t-alert-controls'><a href='#'>" + dismissText +
"</a></div>";
 
             var list = find(clientId, "div");
             var link = find(clientId, "a");
@@ -48,7 +48,7 @@ T5.extendInitializers(function() {
 
             T5.sub(T5.events.ADD_ALERT, null, function(alertSpec) {
                 if (!constructed) {
-                    list = construct(spec.id);
+                    list = construct(spec.id, spec.dismissText);
                     constructed = true;
                 }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MapExpressionInExpansions.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MapExpressionInExpansions.tml?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MapExpressionInExpansions.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MapExpressionInExpansions.tml Fri
Sep 16 14:35:20 2011
@@ -5,5 +5,7 @@
         <li>Empty Map: <span id="emptymap">${echoMap({})}</span></li>
         <li>String Keys Map: <span id="stringmap">${echoMap({'A':1})}</span></li>
         <li>Number Keys Map: <span id="numberkeysmap">${echoMap({1: 'one'})}</span></li>
+        <!-- demonstrates TAP5-1652 -->
+        <li>Map with spaces: <span id="mapwithspaces">${ echoMap( { 2 : 'two'
} ) }</span></li>
     </ul>
 </html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/AlertsTests.groovy
Fri Sep 16 14:35:20 2011
@@ -94,4 +94,16 @@ class AlertsTests extends SeleniumTestCa
         click "link=Dismiss all"
     }
 
-}
\ No newline at end of file
+    /** #1633 - alerts shouldn't hard-code the  'Dismiss all' label...*/
+    @Test
+    void dismiss_label_is_parameter() {
+        openLinks "Alerts Demo", "reset"
+        select "id=severity", "Warn"
+        select "id=duration", "Until Dismissed"
+        type "id=message", "I'm sorry, Hal, I can't do that."
+        clickAndWait "//input[@value='Traditional Update']"
+        assertTextPresent "I'm sorry, Hal, I can't do that."
+        assertTrue isElementPresent("link=Zenbu Kesu")
+    }
+
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/TemplateParserImplTest.java
Fri Sep 16 14:35:20 2011
@@ -569,7 +569,6 @@ public class TemplateParserImplTest exte
     {
         List<TemplateToken> tokens= tokens("expansions_with_maps.tml");
 
-        System.out.println(tokens);
         assertEquals(tokens.size(), 11);
 
         //note that a single expansion on a line and two expansions on a line are tested
individually elsewhere,
@@ -588,6 +587,18 @@ public class TemplateParserImplTest exte
     }
 
     @Test
+    public void expansion_whitespace_trimmed()
+    {
+        List<TemplateToken> tokens = tokens("expansions_with_whitespace.tml");
+
+        assertEquals(tokens.size(), 9);
+        
+        ExpansionToken expansion = get(tokens, 2);
+        assertEquals( expansion.getExpression(), "message:messagekey1");
+
+    }
+
+    @Test
     public void parameter_element()
     {
         List<TemplateToken> tokens = tokens("parameter_element.tml");

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml?rev=1171593&r1=1171592&r2=1171593&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/AlertsDemo.tml
Fri Sep 16 14:35:20 2011
@@ -26,4 +26,5 @@
     ]
 </p>
 
+<t:alerts dismissText="Zenbu Kesu"/>
 </html>

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/expansions_with_whitespace.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/expansions_with_whitespace.tml?rev=1171593&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/expansions_with_whitespace.tml
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/expansions_with_whitespace.tml
Fri Sep 16 14:35:20 2011
@@ -0,0 +1,5 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="preserve">
+    Space after: ${message:messagekey1 }
+    Space before: ${ message:messagekey2}
+    Space both: ${ message:messagekey3 }
+</html>



Mime
View raw message