tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r732794 - in /tapestry/tapestry5/trunk: src/site/apt/dev/ src/site/apt/guide/ tapestry-core/src/main/java/org/apache/tapestry5/ tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ tapestry-core/src/main/java/org/apache/tapes...
Date Thu, 08 Jan 2009 19:03:17 GMT
Author: hlship
Date: Thu Jan  8 11:03:15 2009
New Revision: 732794

URL: http://svn.apache.org/viewvc?rev=732794&view=rev
Log:
TAP5-442: Add a context: binding prefix to make it super-easy to reference context assets from templates

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InvariantBinding.java
      - copied, changed from r728733, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/VariantBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/images/asf_logo_wide.gif   (with props)
Removed:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/VariantBinding.java
Modified:
    tapestry/tapestry5/trunk/src/site/apt/dev/bible.apt
    tapestry/tapestry5/trunk/src/site/apt/guide/parameters.apt
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/BindingConstants.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/MessageBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/NullFieldStrategyBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/TranslateBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ValidateBindingFactory.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AttributeExpansionBinding.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentDefaultProviderImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageElementFactoryImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageLoaderProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetSource.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml

Modified: tapestry/tapestry5/trunk/src/site/apt/dev/bible.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/dev/bible.apt?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/dev/bible.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/dev/bible.apt Thu Jan  8 11:03:15 2009
@@ -8,8 +8,9 @@
 
 IDE
 
- <<IntelliJ>>.  It's a free license for all committers and it's just better. You'll love it after the
- first couple of days fumbling because you're so used to Eclipse bending you over and doing unspeakable things.
+ <<IntelliJ>>.  It's a free license for all committers and it's just better. Yes, the first few days
+ can be an unpleasant fumble because everything is almost, but not quite, familiar.  Pretty soon you'll love IDEA and
+ recognize that Eclipse has been bending you over and doing unspeakable things.
 
  There are shared code formatting settings in <<<support/idea-settings.jar>>>.  This will prevent
  unexpected conflicts due to formatting.
@@ -28,7 +29,7 @@
   Always provide a commit message.  I generally try to work off the JIRA, so my commit message is often:
 
 ----
-TAPESTRY-1234: Make the Foo Widget more Ajax-tastic!
+TAP5-1234: Make the Foo Widget more Ajax-tastic!
 ----
 
   It is <<very important>> to include the JIRA issue id in the commit.  This is used in many places:
@@ -52,17 +53,17 @@
   When you start to work on an issue, make sure it is <<assigned to you>> and use the <<start progress>>
   option.
 
-  I often add comments about the state of the fix, or the challenges.  This often spurs the Issue's adder to
+  I often add comments about the state of the fix, or the challenges in creating a fix.  This often spurs the Issue's adder to
   provide more details.
 
   I often update the issue description to make it more legible and more precise, i.e., "NPE in CheckUpdates"
-  might become "NullPointerException when checking for updates to file that have been deleted".  Verbose is good.
+  might become "NullPointerException when checking for updates to files that have been deleted".  Verbose is good.
 
 * Closing bugs  
 
   Is it a bug fix without tests?  <<No.>>  In some cases, I write new tests to prove that an issue is not valid and
   then leave
-  the tests in place -- the close the bug as invalid.
+  the tests in place -- then close the bug as invalid.
 
   A good plan is to write a test that fails then work the code until the test passes.
   I'm also surprised by how often code works in a unit test but fails unexpectedly in an integration test.
@@ -119,12 +120,69 @@
   We do not have a specific plan for this yet. Future Tapestry 5 will add features to allow clean renames
   of parameters, and a way to deprecated and eventually remove components.
 
+Evolving Interfaces
+
+  Tapestry users interfaces quite extensively.
+
+  Interfaces fall into two categories: service interfaces called by user code, and interfaces implemented by user code.
+
+  Internal interfaces may be changed at any time. That's why so much is kept internal.
+
+* Service Interfaces
+
+  New methods may be added if absolutely necessary, but this should be avoided if at all possible. Don't forget
+  the @since Javadoc annotation.
+
+  Consider having a stable public facade service whose implementation calls into one or more internal service.
+
+* User Interfaces
+
+  These should be frozen, no changes once released.  Failure to do so causes <non-backwards compatible upgrade problems>;
+  that is, classes that implement the (old) interface are suddenly invalid, missing methods from the (new) interface.
+
+  Consider introducing a new interface that extends the old one and adds new methods.  Make sure you support both.
+
+  You can see this with ServiceDef and ServiceDef2 (which extends ServiceDef).  Yes this can be a bit ugly.
+
+  I actually have utility methods that convert from ServiceDef to ServiceDef2, adding a wrapper implementation around
+  a ServiceDef instance if necessary:
+
+---
+  public static ServiceDef2 toServiceDef2(final ServiceDef sd)
+  {
+    if (sd instanceof ServiceDef2)
+        return (ServiceDef2) sd;
+
+    return new ServiceDef2()
+    {
+        public boolean isPreventDecoration()
+        {
+            return false;
+        }
+
+        public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
+        {
+            return sd.createServiceCreator(resources);
+        }
+
+        . . .
+    };
+  }
+---
+
+
+Use of @since
+
+  When adding new classes or interface, or adding new methods to existing types, add an @since Javadoc comment.
+
+  Use the complete version number of the release in which the type or method was added: i.e., <<<@since 5.1.0.3>>>.
+
 Code Style
 
-  Yes, I (Howard) use leading underscores for field names.  I just prefer that to prefixing with <<<this.>>>, you don't
-  have to do so, but try to make your code blend in when modifying existing source.
+  Yes, at one time I (Howard) used leading underscores for field names. I've since changed my mind, but
+  I unfortunately infected other people; please try to make your code blend in when modifying existing source.
 
-  Long ago, Tapestry code use the regrettable "leading-I-on-interfaces" style.  Don't do that.  Everythings an interface.
+  Long ago, Tapestry (3) code use the regrettable "leading-I-on-interfaces" style.  Don't do that.  Everything's an interface.
 
   I prefer braces on a new line (and thus, open braces lined up with close braces), so that's what the default
   code formatting is set up for. I sometimes omit braces for trivial if statements, such as <<<return;>>>.  I use a lot
@@ -138,20 +196,29 @@
   I don't bother alphabetizing things, because I have an IDE that lets me jump around easily.
 
   <<Final is the new private.>>  Final fields are great for multi-threaded code.  Especially when creating
-  service implementations with dependencies, store that dependencies into final fields. Once we're all running
+  service implementations with dependencies, store those dependencies into final fields. Once we're all running
   on 100 core workstations, you'll thank me.  Seriously, Java's memory model is seriously twisted stuff, and
   assigning to a non-final field from a constructor opens up a tiny window of non-thread safety.
 
 Comments
 
   Comments are overwhelmingly important.  Try to capture the <why> of a class or method.   Add lots
-  of links, to code that will be invoked by the method, to related methods or classes, and so forth.
+  of links, to code that will be invoked by the method, to related methods or classes, and so forth. For instance,
+  I'll often have an annotation, a worker class for the annotation, and a related service all cross-linked.
 
   Comment the <interfaces> and don't get worked up on the <implementations>.  Javadoc does a perfectly
   good job of copying interface comments to implementations, so this falls under the <Dont Repeat Yourself>
   guideline.
 
-  Be very careful about documenting what methods can accept null, and what methods may return null.
+  Be very careful about documenting what methods can accept null, and what methods may return null.  Generally
+  speaking, people will assume that null is not allowed for parameter and method will never return null, unless
+  it is explicitly documented that null is allowed (or potentially returned).
+
+Documentation
+
+  Try and keep the documentation up-to date as you make changes; it is <<much>> harder to do so later.
+
+  Documentation is the <<#1 criticism>> of Tapestry!
 
 Class and Method Naming Conventions
 
@@ -186,7 +253,7 @@
  to the contributed values (possibly after some transformation).
 
  [To]
- A method prefix that indicates a conversion or coersion from one type to another.
+ A method prefix that indicates a conversion or coersion from one type to another.  I.e., toUserPresentable().
 
  [Worker]
  An object that peforms a specific job.  Workers will be stateless, but will be passed
@@ -225,6 +292,14 @@
  Objects that are exposed to user code should generally implement a meaningful toString() method.
  And that method should be tested.
 
+Subclassing
+
+  You'll notice there isn't a lot of inheritance in Tapestry.  Given the function of the IoC container,
+  it is much more common to use some variation of <aggregation> rather than <inheritance>.
+
+  Where subclassing exists, the guideline for constructor parameters is:  the subclass should include all
+  the constructor parameters of the superclass, in the same positions.  Thus subclass constructor parameters
+  are appended to the list of super-class constructor parameters.
  
 
 

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/parameters.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/parameters.apt?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/parameters.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/parameters.apt Thu Jan  8 11:03:15 2009
@@ -115,12 +115,14 @@
 *------------+----------------------------------------------------------------------------------+
 | <<Prefix>> | <<Description>>                                                                  |
 *------------+----------------------------------------------------------------------------------+
-| asset      | The relative path to an asset file (which must exist). |
+| asset      | The relative path to an asset file (which must exist).                           |
 *------------+----------------------------------------------------------------------------------+
-| block      | The id of a block within the template. |
+| block      | The id of a block within the template.                                           |
 *------------+----------------------------------------------------------------------------------+
 | component  | The id of another component within the same template.                            |
 *------------+----------------------------------------------------------------------------------+
+| context    | Context asset: path from context root.                                           |
+*------------+----------------------------------------------------------------------------------+
 | literal    | A literal string.                                                                |
 *------------+----------------------------------------------------------------------------------+
 | nullfieldstrategy | Used to locate a pre-defined {{{../apidocs/org/apache/tapestry5/NullFieldStrategy.html}NullFieldStrategy}}|
@@ -235,6 +237,24 @@
   prefix is "literal:".  This reflects the fact that a parameter specified in the Java class, using the annotation, is most likely
   a computed value, whereas a value in the template should simply be copied, as is, into the result HTML stream.
 
+Asset Bindings
+
+  Assets bindings are normally relative to the component class.  This can be overriden by prefixing the path with "context:",
+  in which case, the path is a context path from the root of the web application context.
+
+Context Bindings
+
+  Context bindings are like asset bindings, but the path is <always> relative to the root of the web application context.
+  This is intended for use inside templates, i.e.:
+
+---
+  <img src="${context:images/icon.png}"/>
+---
+
+  Tapestry will adjust the URL of the image so that it is processed by Tapestry, not the servlet container.
+  It will gain a URL that includes the applications version number, it will have a far-future expires header,
+  and (if the client supports it) it will be compressed before being sent to the client.
+
 Supporting Informal Parameters
 
     <<Only>> components which area annotated with

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/BindingConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/BindingConstants.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/BindingConstants.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/BindingConstants.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-//  Copyright 2007, 2008 The Apache Software Foundation
+//  Copyright 2007, 2008, 2009 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.
@@ -69,7 +69,8 @@
 
     /**
      * References a localized asset.  The asset will be relative to the component's class file, unless a prefix
-     * (typically, "context:") is used.
+     * (typically, "context:") is used on the expression.    Typically, this is used for classpath assets relative to
+     * the component class, and {@link #CONTEXT} is used for context assets.
      *
      * @see org.apache.tapestry5.Asset
      * @see org.apache.tapestry5.services.AssetSource
@@ -82,4 +83,12 @@
      * org.apache.tapestry5.corelib.components.Loop} component.
      */
     public static final String VAR = "var";
+
+    /**
+     * Binding factory for context assets specifically. The expression is the path from the root of the web
+     * application.
+     *
+     * @since 5.1.0.0
+     */
+    public static final String CONTEXT = "context";
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java?rev=732794&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBinding.java Thu Jan  8 11:03:15 2009
@@ -0,0 +1,62 @@
+// Copyright 2009 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.tapestry5.internal.bindings;
+
+import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.ioc.Location;
+
+public class AssetBinding extends AbstractBinding
+{
+    private final String description;
+
+    private final Asset asset;
+
+    private final boolean invariant;
+
+    AssetBinding(Location location, String description, Asset asset, boolean invariant)
+    {
+        super(location);
+
+        this.description = description;
+        this.asset = asset;
+        this.invariant = invariant;
+    }
+
+    public Object get()
+    {
+        return asset;
+    }
+
+    /**
+     * Asset bindings are invariant only if full URIs are being used.  This is complicated ... basically, if the Asset
+     * is invariant, then any value coerced from the Asset is also invariant (such as a String version of an Asset's
+     * path).  Thus, the invariant String gets cached inside component parameter fields.  However, when the path is
+     * dynamic (i.e., because of {@link org.apache.tapestry5.internal.services.RequestPathOptimizer}), we need to ensure
+     * that the Assets aren't cached.
+     *
+     * @return true if full URIs are enabled, false otherwise
+     */
+    @Override
+    public boolean isInvariant()
+    {
+        return invariant;
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.format("AssetBinding[%s: %s]", description, asset);
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AssetBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -27,7 +27,8 @@
 /**
  * Binding factory where the expression is a reference to an asset.
  *
- * @see AssetSource
+ * @see org.apache.tapestry5.services.AssetSource
+ * @see org.apache.tapestry5.internal.bindings.ContextBindingFactory
  */
 public class AssetBindingFactory implements BindingFactory
 {
@@ -35,47 +36,6 @@
 
     private final boolean forceAbsoluteURIs;
 
-    public class AssetBinding extends AbstractBinding
-    {
-        private final String description;
-
-        private final Asset asset;
-
-        protected AssetBinding(String description, Asset asset, Location location)
-        {
-            super(location);
-
-            this.description = description;
-            this.asset = asset;
-        }
-
-        public Object get()
-        {
-            return asset;
-        }
-
-        /**
-         * Asset bindings are invariant only if full URIs are being used.  This is complicated ... basically, if the
-         * Asset is invariant, then any value coerced from the Asset is also invariant (such as a String version of an
-         * Asset's path).  Thus, the invariant String gets cached inside component parameter fields.  However, when the
-         * path is dynamic (i.e., because of {@link org.apache.tapestry5.internal.services.RequestPathOptimizer}), we
-         * need to ensure that the Assets aren't cached.
-         *
-         * @return true if full URIs are enabled, false otherwise
-         */
-        @Override
-        public boolean isInvariant()
-        {
-            return forceAbsoluteURIs;
-        }
-
-        @Override
-        public String toString()
-        {
-            return String.format("AssetBinding[%s: %s]", description, asset);
-        }
-    }
-
     public AssetBindingFactory(AssetSource source,
 
                                @Symbol(SymbolConstants.FORCE_ABSOLUTE_URIS)
@@ -92,6 +52,6 @@
 
         Asset asset = source.getAsset(baseResource, expression, container.getLocale());
 
-        return new AssetBinding(description, asset, location);
+        return new AssetBinding(location, description, asset, forceAbsoluteURIs);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBinding.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2009 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.
@@ -25,7 +25,8 @@
 
     private final String blockId;
 
-    public BlockBinding(String description, ComponentResources component, String blockId, Location location)
+    public BlockBinding(Location location, String description, ComponentResources component, String blockId
+    )
     {
         super(location);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/BlockBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2009 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.
@@ -27,7 +27,6 @@
     public Binding newBinding(String description, ComponentResources container,
                               ComponentResources component, String expression, Location location)
     {
-        return new BlockBinding(description, container, expression, location);
+        return new BlockBinding(location, description, container, expression);
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBinding.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2009 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.
@@ -25,8 +25,8 @@
 
     private final String componentId;
 
-    public ComponentBinding(String description, ComponentResources resources, String componentId,
-                            Location location)
+    public ComponentBinding(Location location, String description, ComponentResources resources, String componentId
+    )
     {
         super(location);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ComponentBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2009 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.
@@ -27,7 +27,6 @@
     public Binding newBinding(String description, ComponentResources container, ComponentResources component,
                               String expression, Location location)
     {
-        return new ComponentBinding(description, container, expression, location);
+        return new ComponentBinding(location, description, container, expression);
     }
-
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java?rev=732794&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ContextBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -0,0 +1,54 @@
+// Copyright 2009 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.tapestry5.internal.bindings;
+
+import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.Binding;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.services.AssetSource;
+import org.apache.tapestry5.services.BindingFactory;
+
+/**
+ * Specialization of {@link org.apache.tapestry5.internal.bindings.AssetBindingFactory} that is explicitly limited to
+ * context assets.
+ *
+ * @since 5.1.0.0
+ */
+public class ContextBindingFactory implements BindingFactory
+{
+    private final AssetSource source;
+
+    private final boolean forceAbsoluteURIs;
+
+    public ContextBindingFactory(AssetSource source,
+
+                                 @Symbol(SymbolConstants.FORCE_ABSOLUTE_URIS)
+                                 boolean forceAbsoluteURIs)
+    {
+        this.source = source;
+        this.forceAbsoluteURIs = forceAbsoluteURIs;
+    }
+
+    public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+                              String expression, Location location)
+    {
+        Asset asset = source.getContextAsset(expression, container.getLocale());
+
+        return new AssetBinding(location, description, asset, forceAbsoluteURIs);
+    }
+}

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InvariantBinding.java (from r728733, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/VariantBinding.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InvariantBinding.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InvariantBinding.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/VariantBinding.java&r1=728733&r2=732794&rev=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/VariantBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InvariantBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-//  Copyright 2008 The Apache Software Foundation
+//  Copyright 2008, 2009 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.
@@ -20,13 +20,13 @@
  * Extends {@link org.apache.tapestry5.internal.bindings.AbstractBinding} with a description and a binding type, with
  * invariant forced to true.
  */
-public abstract class VariantBinding extends AbstractBinding
+public abstract class InvariantBinding extends AbstractBinding
 {
     private final Class bindingType;
 
     private final String description;
 
-    public VariantBinding(Class bindingType, String description, Location location)
+    public InvariantBinding(Location location, Class bindingType, String description)
     {
         super(location);
 
@@ -49,6 +49,6 @@
     @Override
     public String toString()
     {
-        return String.format("VariantBinding[%s]", description);
+        return String.format("InvariantBinding[%s]", description);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBinding.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2009 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.
@@ -30,7 +30,7 @@
 
     private final Object value;
 
-    public LiteralBinding(String description, Object value, Location location)
+    public LiteralBinding(Location location, String description, Object value)
     {
         super(location);
         this.description = description;

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/LiteralBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,17 +1,17 @@
-// Copyright 2006 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.
-
+// Copyright 2006, 2009 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.tapestry5.internal.bindings;
 
 import org.apache.tapestry5.Binding;
@@ -29,6 +29,6 @@
     public Binding newBinding(String description, ComponentResources container, ComponentResources component,
                               String expression, Location location)
     {
-        return new LiteralBinding(description, expression, location);
+        return new LiteralBinding(location, description, expression);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/MessageBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/MessageBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/MessageBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/MessageBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2009 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.
@@ -31,7 +31,6 @@
     {
         String messageValue = container.getMessages().get(expression);
 
-        return new LiteralBinding(description, messageValue, location);
+        return new LiteralBinding(location, description, messageValue);
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/NullFieldStrategyBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/NullFieldStrategyBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/NullFieldStrategyBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/NullFieldStrategyBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright  2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -39,6 +39,6 @@
     {
         NullFieldStrategy strategy = strategySource.get(expression);
 
-        return new LiteralBinding(description, strategy, location);
+        return new LiteralBinding(location, description, strategy);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2009 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.
@@ -35,8 +35,8 @@
 
     private boolean invariant;
 
-    public PropBinding(final Object root, final PropertyConduit conduit, final String toString,
-                       final Location location)
+    public PropBinding(final Location location, final Object root, final PropertyConduit conduit, final String toString
+    )
     {
         super(location);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -47,6 +47,6 @@
         String toString = String.format("PropBinding[%s %s(%s)]", description, container
                 .getCompleteId(), expression);
 
-        return new PropBinding(target, conduit, toString, location);
+        return new PropBinding(location, target, conduit, toString);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBinding.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -23,7 +23,8 @@
     private final ComponentResources resources;
     private final String name;
 
-    public RenderVariableBinding(String description, ComponentResources resources, String name, Location location)
+    public RenderVariableBinding(Location location, String description, ComponentResources resources, String name
+    )
     {
         super(location);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/RenderVariableBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -24,6 +24,6 @@
     public Binding newBinding(String description, ComponentResources container, ComponentResources component,
                               String expression, Location location)
     {
-        return new RenderVariableBinding(description, container, expression, location);
+        return new RenderVariableBinding(location, description, container, expression);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/TranslateBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/TranslateBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/TranslateBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/TranslateBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -37,7 +37,7 @@
     public Binding newBinding(String description, ComponentResources container,
                               final ComponentResources component, final String expression, Location location)
     {
-        return new VariantBinding(FieldTranslator.class, description + ": " + expression, location)
+        return new InvariantBinding(location, FieldTranslator.class, description + ": " + expression)
         {
             public Object get()
             {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ValidateBindingFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ValidateBindingFactory.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ValidateBindingFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/ValidateBindingFactory.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2009 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.
@@ -48,7 +48,7 @@
 
         final Field field = (Field) fieldAsObject;
 
-        return new VariantBinding(FieldValidator.class, description + ": " + expression, location)
+        return new InvariantBinding(location, FieldValidator.class, description + ": " + expression)
         {
             public Object get()
             {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetSourceImpl.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -30,6 +30,8 @@
 {
     private static final String CLASSPATH = "classpath";
 
+    private static final String CONTEXT = "context";
+
     private final StrategyRegistry<AssetFactory> registry;
 
     private final ThreadLocale threadLocale;
@@ -71,14 +73,21 @@
         return getAsset(null, path, locale);
     }
 
+    public Asset getContextAsset(String path, Locale locale)
+    {
+        Defense.notBlank(path, "path");
+
+        Resource rootResource = prefixToRootResource.get(CONTEXT);
+
+        return findRelativeAsset(rootResource, path, locale);
+    }
+
     public Asset getAsset(Resource baseResource, String path, Locale locale)
     {
         Defense.notBlank(path, "path");
 
         if (baseResource == null) baseResource = prefixToRootResource.get(CLASSPATH);
 
-        if (locale == null) locale = threadLocale.getLocale();
-
         int colonx = path.indexOf(':');
 
         if (colonx < 0) return findRelativeAsset(baseResource, path, locale);
@@ -96,7 +105,12 @@
     private Asset findRelativeAsset(Resource baseResource, String path, Locale locale)
     {
         Resource unlocalized = baseResource.forFile(path);
-        Resource localized = unlocalized.forLocale(locale);
+
+        Locale effectiveLocale = locale != null
+                                 ? locale
+                                 : threadLocale.getLocale();
+
+        Resource localized = unlocalized.forLocale(effectiveLocale);
 
         if (localized == null)
             throw new RuntimeException(ServicesMessages.assetDoesNotExist(unlocalized));
@@ -129,5 +143,4 @@
 
         return factory.createAsset(resource);
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AttributeExpansionBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AttributeExpansionBinding.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AttributeExpansionBinding.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AttributeExpansionBinding.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2009 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.
@@ -25,7 +25,7 @@
 {
     private final StringProvider provider;
 
-    public AttributeExpansionBinding(StringProvider provider, Location location)
+    public AttributeExpansionBinding(Location location, StringProvider provider)
     {
         super(location);
 
@@ -45,5 +45,4 @@
     {
         return false;
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentDefaultProviderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentDefaultProviderImpl.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentDefaultProviderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentDefaultProviderImpl.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -16,7 +16,7 @@
 
 import org.apache.tapestry5.*;
 import org.apache.tapestry5.internal.TapestryInternalUtils;
-import org.apache.tapestry5.internal.bindings.VariantBinding;
+import org.apache.tapestry5.internal.bindings.InvariantBinding;
 import org.apache.tapestry5.ioc.Messages;
 import static org.apache.tapestry5.ioc.internal.util.Defense.notBlank;
 import static org.apache.tapestry5.ioc.internal.util.Defense.notNull;
@@ -128,8 +128,7 @@
         String description = String.format("default translator, parameter %s of %s",
                                            parameterName, resources.getCompleteId());
 
-        return new VariantBinding(FieldTranslator.class, description,
-                                  resources.getLocation())
+        return new InvariantBinding(resources.getLocation(), FieldTranslator.class, description)
         {
             public Object get()
             {
@@ -150,7 +149,7 @@
         String description = String.format("default validator, parameter %s of %s", parameterName,
                                            resources.getCompleteId());
 
-        return new VariantBinding(FieldValidator.class, description, resources.getLocation())
+        return new InvariantBinding(resources.getLocation(), FieldValidator.class, description)
         {
             public Object get()
             {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageElementFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageElementFactoryImpl.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageElementFactoryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageElementFactoryImpl.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -303,7 +303,7 @@
             StringProvider provider = parseAttributeExpansionExpression(expression, loadingComponentResources,
                                                                         location);
 
-            return new AttributeExpansionBinding(provider, location);
+            return new AttributeExpansionBinding(location, provider);
         }
 
         return bindingSource.newBinding(parameterName, loadingComponentResources,

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageLoaderProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageLoaderProcessor.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageLoaderProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageLoaderProcessor.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2009 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.
@@ -610,7 +610,7 @@
         BlockImpl block = new BlockImpl(token.getLocation(),
                                         String.format("Parmeter %s of %s", name, element.getCompleteId()));
 
-        Binding binding = new LiteralBinding("block parameter " + name, block, token.getLocation());
+        Binding binding = new LiteralBinding(token.getLocation(), "block parameter " + name, block);
 
         // TODO: Check that the parameter block doesn't appear outside of an embedded component.
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -347,6 +347,6 @@
             return;
         }
 
-        resources.bindParameter(parameterName, new LiteralBinding("default " + parameterName, value, null));
+        resources.bindParameter(parameterName, new LiteralBinding(null, "default " + parameterName, value));
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetSource.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetSource.java Thu Jan  8 11:03:15 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -57,6 +57,16 @@
     Asset getClasspathAsset(String path, Locale locale);
 
     /**
+     * Convienience for finding assets in the context.
+     *
+     * @param path   path relative to the base resource (the context root)
+     * @param locale to localize the resource to, or null for the locale for the current request
+     * @return the asset
+     * @since 5.1.0.0
+     */
+    Asset getContextAsset(String path, Locale locale);
+
+    /**
      * Obtains a classpath alias in the current locale (as defined by the {@link ThreadLocale} service).
      *
      * @param path

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Thu Jan  8 11:03:15 2009
@@ -185,6 +185,7 @@
         binder.bind(BindingFactory.class, ValidateBindingFactory.class).withId("ValidateBindingFactory");
         binder.bind(BindingFactory.class, TranslateBindingFactory.class).withId("TranslateBindingFactory");
         binder.bind(BindingFactory.class, AssetBindingFactory.class).withId("AssetBindingFactory");
+        binder.bind(BindingFactory.class, ContextBindingFactory.class).withId("ContextBindingFactory");
         binder.bind(BindingFactory.class, NullFieldStrategyBindingFactory.class).withId(
                 "NullFieldStrategyBindingFactory");
         binder.bind(URLEncoder.class, URLEncoderImpl.class);
@@ -244,7 +245,10 @@
                                                BindingFactory assetBindingFactory,
 
                                                @InjectService("NullFieldStrategyBindingFactory")
-                                               BindingFactory nullFieldStrategyBindingFactory)
+                                               BindingFactory nullFieldStrategyBindingFactory,
+
+                                               @InjectService("ContextBindingFactory")
+                                               BindingFactory contextBindingFactory)
     {
         configuration.add(BindingConstants.LITERAL, new LiteralBindingFactory());
         configuration.add(BindingConstants.COMPONENT, new ComponentBindingFactory());
@@ -257,6 +261,7 @@
         configuration.add(BindingConstants.TRANSLATE, translateBindingFactory);
         configuration.add(BindingConstants.ASSET, assetBindingFactory);
         configuration.add(BindingConstants.NULLFIELDSTRATEGY, nullFieldStrategyBindingFactory);
+        configuration.add(BindingConstants.CONTEXT, contextBindingFactory);
     }
 
     public static void contributeClasspathAssetAliasManager(MappedConfiguration<String, String> configuration,

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/images/asf_logo_wide.gif
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/images/asf_logo_wide.gif?rev=732794&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/images/asf_logo_wide.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Thu Jan  8 11:03:15 2009
@@ -50,24 +50,14 @@
 
         // assertSourcePresent("<link href=\"/css/app.css\" rel=\"stylesheet\" type=\"text/css\">");
 
-        // The URL
-
-        // assertAttribute("//img[@id='icon']/@src", "/images/tapestry_banner.gif");
-
-
-        // doesn't prove that the image shows up in the client browser (it does, but
-        // it could just as easily be a broken image). Haven't figured out how Selenium
-        // allows to be verified. Note that the path below represents some aliasing
-        // of the raw classpath resource path.
-
-        // assertAttribute("//img[@id='button']/@src", "/assets/app1/pages/nested/tapestry-button.png");
-
         // Read the byte stream for the asset and compare to the real copy.
 
         compareDownloadedAsset(getAttribute("//img[@id='icon']/@src"),
                                "src/test/app1/images/tapestry_banner.gif");
         compareDownloadedAsset(getAttribute("//img[@id='button']/@src"),
                                "src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/tapestry-button.png");
+        compareDownloadedAsset(getAttribute("//img[@id='viaContext']/@src"),
+                               "src/test/app1/images/asf_logo_wide.gif");
     }
 
     private void compareDownloadedAsset(String assetURL, String localPath) throws Exception
@@ -76,8 +66,7 @@
 
         byte[] downloaded = readContent(url);
 
-        File local = new File(
-                localPath);
+        File local = new File(localPath);
 
         byte[] actual = readContent(local.toURL());
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml?rev=732794&r1=732793&r2=732794&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/AssetDemo.tml Thu Jan  8 11:03:15 2009
@@ -23,4 +23,10 @@
 
     <img src="${asset:../smiley.png}"/>
 
+
+    <p>
+        Context asset via context: binding
+    </p>
+
+    <img id="viaContext" src="${context:images/asf_logo_wide.gif}"/>
 </html>
\ No newline at end of file



Mime
View raw message