hlship      2005/08/04 16:03:14

  Modified:    framework/src/java/org/apache/tapestry/record
                        PageClientPropertyPersistenceScope.java
                        AppClientPropertyPersistenceScope.java
  Added:       framework/src/java/org/apache/tapestry/record
                        AbstractPrefixedClientPropertyPersistenceScope.java
  Log:
  TAPESTRY-524: Client Side Persistence Scopes can conflict with each other
  
  Revision  Changes    Path
  1.4       +9 -19     
jakarta-tapestry/framework/src/java/org/apache/tapestry/record/PageClientPropertyPersistenceScope.java
  
  Index: PageClientPropertyPersistenceScope.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/record/PageClientPropertyPersistenceScope.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PageClientPropertyPersistenceScope.java   4 Aug 2005 22:15:33 -0000       
1.3
  +++ PageClientPropertyPersistenceScope.java   4 Aug 2005 23:03:14 -0000       
1.4
  @@ -25,34 +25,24 @@
    * @since 4.0
    * @see org.apache.tapestry.record.ClientPropertyPersistenceScope
    */
  -public class PageClientPropertyPersistenceScope implements 
ClientPropertyPersistenceScope
  +public class PageClientPropertyPersistenceScope extends
  +        AbstractPrefixedClientPropertyPersistenceScope
   {
  -    private static final String PREFIX = "state:";
  +
  +    public PageClientPropertyPersistenceScope()
  +    {
  +        super("state:");
  +    }
   
       /**
        * Returns true if the active page name matches the page for this 
property. This means that
        * <em>after a new page has been activated</em>, the state is discarded.
        */
   
  -    public boolean shouldEncodeState(ServiceEncoding encoding,
  -            IRequestCycle cycle, String pageName, PersistentPropertyData 
data)
  +    public boolean shouldEncodeState(ServiceEncoding encoding, IRequestCycle 
cycle,
  +            String pageName, PersistentPropertyData data)
       {
           return pageName.equals(cycle.getPage().getPageName());
       }
   
  -    public String constructParameterName(String pageName)
  -    {
  -        return PREFIX + pageName;
  -    }
  -
  -    public boolean isParameterForScope(String parameterName)
  -    {
  -        return parameterName.startsWith(PREFIX);
  -    }
  -
  -    public String extractPageName(String parameterName)
  -    {
  -        return parameterName.substring(PREFIX.length());
  -    }
  -
   }
  
  
  
  1.4       +8 -20     
jakarta-tapestry/framework/src/java/org/apache/tapestry/record/AppClientPropertyPersistenceScope.java
  
  Index: AppClientPropertyPersistenceScope.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/record/AppClientPropertyPersistenceScope.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AppClientPropertyPersistenceScope.java    4 Aug 2005 22:15:34 -0000       
1.3
  +++ AppClientPropertyPersistenceScope.java    4 Aug 2005 23:03:14 -0000       
1.4
  @@ -24,34 +24,22 @@
    * @since 4.0
    * @see org.apache.tapestry.record.ClientPropertyPersistenceScope
    */
  -public class AppClientPropertyPersistenceScope implements 
ClientPropertyPersistenceScope
  +public class AppClientPropertyPersistenceScope extends
  +        AbstractPrefixedClientPropertyPersistenceScope
   {
   
  -    private final static String PREFIX = "appstate:";
  +    public AppClientPropertyPersistenceScope()
  +    {
  +        super("appstate:");
  +    }
   
       /**
        * Always returns true.
        */
   
  -    public boolean shouldEncodeState(ServiceEncoding encoding,
  -            IRequestCycle cycle, String pageName, PersistentPropertyData 
data)
  +    public boolean shouldEncodeState(ServiceEncoding encoding, IRequestCycle 
cycle,
  +            String pageName, PersistentPropertyData data)
       {
           return true;
       }
  -
  -    public String constructParameterName(String pageName)
  -    {
  -        return PREFIX + pageName;
  -    }
  -
  -    public boolean isParameterForScope(String parameterName)
  -    {
  -        return parameterName.startsWith(PREFIX);
  -    }
  -
  -    public String extractPageName(String parameterName)
  -    {
  -        return parameterName.substring(PREFIX.length());
  -    }
  -
   }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/java/org/apache/tapestry/record/AbstractPrefixedClientPropertyPersistenceScope.java
  
  Index: AbstractPrefixedClientPropertyPersistenceScope.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.record;
  
  import org.apache.hivemind.util.Defense;
  
  /**
   * Base implementation of [EMAIL PROTECTED] 
org.apache.tapestry.record.ClientPropertyPersistenceScope} wherein
   * the scopes are recognized via a prefix on the page name to form the query 
parameter name.
   * Capiche?
   * 
   * @author Howard Lewis Ship
   * @since 4.0
   */
  public abstract class AbstractPrefixedClientPropertyPersistenceScope 
implements
          ClientPropertyPersistenceScope
  {
      private final String _prefix;
  
      public AbstractPrefixedClientPropertyPersistenceScope(String prefix)
      {
          Defense.notNull(prefix, "prefix");
  
          _prefix = prefix;
      }
  
      public String constructParameterName(String pageName)
      {
          return _prefix + pageName;
      }
  
      public boolean isParameterForScope(String parameterName)
      {
          return parameterName.startsWith(_prefix);
      }
  
      public String extractPageName(String parameterName)
      {
          return parameterName.substring(_prefix.length());
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to