Author: bayard
Date: Sun Jul 12 05:14:15 2009
New Revision: 793274

URL: http://svn.apache.org/viewvc?rev=793274&view=rev
Log:
Adding new general support for a scope attribute. The two jsps use it, and the 
tld is changed such that capitalize and overlay have that scope attribute in 
their API

Modified:
    
jakarta/taglibs/proper/string/trunk/src/main/java/org/apache/taglibs/string/StringTagSupport.java
    
jakarta/taglibs/proper/string/trunk/src/main/resources/META-INF/tlds/taglibs-string.tld
    
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/CapitalizeTest.jsp
    
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/bug/Bug39964Test.jsp

Modified: 
jakarta/taglibs/proper/string/trunk/src/main/java/org/apache/taglibs/string/StringTagSupport.java
URL: 
http://svn.apache.org/viewvc/jakarta/taglibs/proper/string/trunk/src/main/java/org/apache/taglibs/string/StringTagSupport.java?rev=793274&r1=793273&r2=793274&view=diff
==============================================================================
--- 
jakarta/taglibs/proper/string/trunk/src/main/java/org/apache/taglibs/string/StringTagSupport.java
 (original)
+++ 
jakarta/taglibs/proper/string/trunk/src/main/java/org/apache/taglibs/string/StringTagSupport.java
 Sun Jul 12 05:14:15 2009
@@ -34,6 +34,9 @@
  *             return result in instead of pushing
  *             out to the html page.
  * </dd>
+ * <dt>scope</dt><dd>
+ *             The scope in which to place the PageContext var variable. 
+ * </dd>
  * </dl> 
  */
 abstract public class StringTagSupport extends BodyTagSupport {
@@ -46,6 +49,11 @@
     private String var;
 
     /**
+     * PageContext scope to store the var attribute in.
+     */
+    private String scope = "page";
+
+    /**
      * Empty constructor. Initialises the attributes.
      */
     public StringTagSupport() {
@@ -67,6 +75,20 @@
     }
        
     /**
+     * Get the PageContext scope to store the var attribute in.
+     */
+    public String getScope() {
+        return this.scope;
+    }
+
+    /**
+     * Set the PageContext scope to store the var attribute in.
+     */
+    public void setScope(String scope) {
+        this.scope = scope;
+    }
+       
+    /**
      * Handles the manipulation of the String tag,
      * evaluating the body of the tag. The evaluation 
      * is delegated to the changeString(String) method 
@@ -95,9 +117,20 @@
                 throw new JspException(e.toString());
             }
         } else {
-            pageContext.setAttribute(this.var, text);
-            // Use the below when running against the integration tests
-            // pageContext.setAttribute(this.var, text, 
PageContext.APPLICATION_SCOPE);
+            if("page".equals(this.scope)) {
+                pageContext.setAttribute(this.var, text, 
PageContext.PAGE_SCOPE);
+            } else
+            if("application".equals(this.scope)) {
+                pageContext.setAttribute(this.var, text, 
PageContext.APPLICATION_SCOPE);
+            } else
+            if("session".equals(this.scope)) {
+                pageContext.setAttribute(this.var, text, 
PageContext.SESSION_SCOPE);
+            } else
+            if("request".equals(this.scope)) {
+                pageContext.setAttribute(this.var, text, 
PageContext.REQUEST_SCOPE);
+            } else {
+                throw new JspException("Illegal scope - not application, page, 
session or request: '" + this.scope + "'");
+            }
         }
 
         return (EVAL_PAGE);
@@ -115,11 +148,12 @@
     /**
      * Initialise any properties to default values.
      * This method is called upon construction, and 
-     * after changeString(String) is called.
-     * This is a default empty implementation.
+     * after changeString(String) is called. It resets 
+     * var and scope.
      */
     public void initAttributes() {
         this.var = null;
+        this.scope = "page";
     }
 
 }

Modified: 
jakarta/taglibs/proper/string/trunk/src/main/resources/META-INF/tlds/taglibs-string.tld
URL: 
http://svn.apache.org/viewvc/jakarta/taglibs/proper/string/trunk/src/main/resources/META-INF/tlds/taglibs-string.tld?rev=793274&r1=793273&r2=793274&view=diff
==============================================================================
--- 
jakarta/taglibs/proper/string/trunk/src/main/resources/META-INF/tlds/taglibs-string.tld
 (original)
+++ 
jakarta/taglibs/proper/string/trunk/src/main/resources/META-INF/tlds/taglibs-string.tld
 Sun Jul 12 05:14:15 2009
@@ -71,6 +71,15 @@
               Variable to store result in.
           </description>
         </attribute>
+        <attribute>
+          <name>scope</name>
+          <required>false</required>
+          <rtexprvalue>true</rtexprvalue>
+          <type>java.lang.String</type>
+          <description>
+              Scope to store the result in.
+          </description>
+        </attribute>
       </tag>
       <tag>
         <name>uncapitalize</name>
@@ -960,6 +969,15 @@
           </description>
         </attribute>
         <attribute>
+          <name>scope</name>
+          <required>false</required>
+          <rtexprvalue>true</rtexprvalue>
+          <type>java.lang.String</type>
+          <description>
+              Scope to store the result in.
+          </description>
+        </attribute>
+        <attribute>
           <name>with</name>
           <required>true</required>
           <rtexprvalue>true</rtexprvalue>

Modified: 
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/CapitalizeTest.jsp
URL: 
http://svn.apache.org/viewvc/jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/CapitalizeTest.jsp?rev=793274&r1=793273&r2=793274&view=diff
==============================================================================
--- 
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/CapitalizeTest.jsp
 (original)
+++ 
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/CapitalizeTest.jsp
 Sun Jul 12 05:14:15 2009
@@ -1,3 +1,3 @@
 <%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1"; prefix="str" %>
 
-<str:capitalize var="test">test successful</str:capitalize>
+<str:capitalize var="test" scope="application">test successful</str:capitalize>

Modified: 
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/bug/Bug39964Test.jsp
URL: 
http://svn.apache.org/viewvc/jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/bug/Bug39964Test.jsp?rev=793274&r1=793273&r2=793274&view=diff
==============================================================================
--- 
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/bug/Bug39964Test.jsp
 (original)
+++ 
jakarta/taglibs/proper/string/trunk/string-test/src/main/webapp/org/apache/taglibs/string/bug/Bug39964Test.jsp
 Sun Jul 12 05:14:15 2009
@@ -2,4 +2,4 @@
 <%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1"; prefix="str" %>
 
 <c:set var="code">sample code</c:set>
-<str:overlay var="test" start="10" end="10" 
with="${code}">12345678901234567890</str:overlay>
+<str:overlay var="test" scope="application" start="10" end="10" 
with="${code}">12345678901234567890</str:overlay>



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscr...@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-h...@jakarta.apache.org

Reply via email to