You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/11/11 02:05:35 UTC

svn commit: r473608 - in /tapestry/tapestry4/trunk: ./ tapestry-contrib/src/java/org/apache/tapestry/contrib/palette/ tapestry-contrib/src/test/org/apache/tapestry/contrib/palette/ tapestry-examples/TimeTracker/ tapestry-examples/TimeTracker/src/contex...

Author: jkuhnert
Date: Fri Nov 10 17:05:33 2006
New Revision: 473608

URL: http://svn.apache.org/viewvc?view=rev&rev=473608
Log:
Slightly more intelligent clientId / id / etc generation.

Added:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClientIdPropertyWorker.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java
Modified:
    tapestry/tapestry4/trunk/pom.xml
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java
    tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/palette/PaletteValidationTest.java
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml
    tapestry/tapestry4/trunk/tapestry-framework/pom.xml
    tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.enhance.xml
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/AbstractComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/BaseComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/IfBean.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/Dialog.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Form.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/BasePage.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/PageLoader.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/OpenToken.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ContainedComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IContainedComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/IdAllocator.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/TestAbstractComponent.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/BaseFormComponentTestCase.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormTest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockForm.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestButton.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestImageSubmit.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java

Modified: tapestry/tapestry4/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/pom.xml?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/pom.xml (original)
+++ tapestry/tapestry4/trunk/pom.xml Fri Nov 10 17:05:33 2006
@@ -213,6 +213,18 @@
                 <artifactId>backport-util-concurrent</artifactId>
                 <version>2.2</version>
             </dependency>
+            <dependency>
+                <groupId>org.openqa.selenium.client-drivers</groupId>
+                <artifactId>selenium-java-client-driver</artifactId>
+                <version>0.8.1</version>
+                <scope>test</scope>
+            </dependency>   
+            <dependency>
+                <groupId>org.openqa.selenium.server</groupId>
+                <artifactId>selenium-server</artifactId>
+                <version>0.8.1</version>
+                <scope>test</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -384,6 +396,11 @@
         <repository>
             <id>tapestry.javaforge</id>
             <url>http://howardlewisship.com/repository</url>
+        </repository>
+        <repository>
+            <id>openqa</id> 
+            <name>OpenQA Maven Repository</name> 
+            <url>http://maven.openqa.org/</url> 
         </repository>
     </repositories>
 

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java Fri Nov 10 17:05:33 2006
@@ -190,13 +190,6 @@
  *                               vertical-align: middle;
  *                               width: 60px;
  *                             }
- *             
- *            
- *           
- *          
- *         
- *        
- *       
  * </pre>
  * 
  * <p>
@@ -241,7 +234,7 @@
             return;
 
         IValidationDelegate delegate = form.getDelegate();
-
+        
         delegate.setFormComponent(this);
 
         form.getElementId(this);

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/palette/PaletteValidationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/palette/PaletteValidationTest.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/palette/PaletteValidationTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/palette/PaletteValidationTest.java Fri Nov 10 17:05:33 2006
@@ -53,7 +53,7 @@
         Palette component = newInstance(Palette.class, 
                 new Object[] { 
             "validatableFieldSupport", vfs, 
-            "id", "pal", "displayName", "Pally"});
+            "clientId", "pal", "displayName", "Pally"});
         
         expect(context.getProfile()).andReturn(profile);
         

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml Fri Nov 10 17:05:33 2006
@@ -139,7 +139,7 @@
             </plugin>
         </plugins>
     </reporting>
-
+<!--
     <pluginRepositories>
         <pluginRepository>
             <id>mortbay-repo</id>
@@ -147,5 +147,5 @@
             <url>http://www.mortbay.org/maven2/snapshot</url>
         </pluginRepository>
     </pluginRepositories>
-
+-->
 </project>

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html Fri Nov 10 17:05:33 2006
@@ -53,6 +53,17 @@
     </fieldset>
 </form>
 
+<a jwcid="@DirectLink" listener="listener:showDialog" 
+	async="true" updateComponents="testDialog">Show Dialog</a><br/>
+
+<div jwcid="testDialog@Dialog" style="display:none" hidden="ognl:dlHidden" >
+	<p style="display:block;background:#ffffff;width:20em;">
+	This is content hidden in a Dialog.
+	
+	<a href="#" onClick="dojo.widget.byId('testDialog').hide();return false">Close</a>
+	</p>
+</div>
+
 <div jwcid="projectDescription@Any" >
 	<h2 jwcid="@If" condition="ognl:selectedProject" style="clear:left" >
 		<span jwcid="projName@InlineEditBox" value="ognl:selectedProject.name" />

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/pom.xml Fri Nov 10 17:05:33 2006
@@ -92,7 +92,7 @@
             </plugin>
         </plugins>
     </reporting>
-    
+<!--    
     <pluginRepositories>
         <pluginRepository>
             <id>mortbay-repo</id>
@@ -100,5 +100,5 @@
             <url>http://www.mortbay.org/maven2/snapshot</url>
         </pluginRepository>
     </pluginRepositories>
-    
+   --> 
 </project>

Modified: tapestry/tapestry4/trunk/tapestry-framework/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/pom.xml?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/pom.xml Fri Nov 10 17:05:33 2006
@@ -203,29 +203,6 @@
                     </execution>
                 </executions>
             </plugin>
-            <!--
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-clover-plugin</artifactId>
-                <version>2.1</version>
-                <inherited>true</inherited>
-                <configuration>
-                    <licenseLocation>
-                        ${user.home}/.m2/repository/com/cenqua/clover/clover.license
-                    </licenseLocation>
-                    <jdk>1.5</jdk>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>pre-site</phase>
-                        <goals>
-                            <goal>instrument</goal>
-                            <goal>aggregate</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-             -->
         </plugins>
     </build>
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.enhance.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.enhance.xml?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.enhance.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/descriptor/META-INF/tapestry.enhance.xml Fri Nov 10 17:05:33 2006
@@ -95,6 +95,8 @@
       before="tapestry.enhance.abstract-property"
       after="tapestry.enhance.inject-messages,tapestry.enhance.inject-specification,tapestry.enhance.specified-property,tapestry.enhance.parameter,tapestry.enhance.dispatch-inject,tapestry.enhance.inject-component,tapestry.enhance.inject-bean,tapestry.enhance.inject-asset"/>
     
+    <command id="clientid-property" object="service:ClientIdPropertyWorker" />
+    
     <!-- After all the previous workers have had their chance, we "fill in" any unclaimed properties
          as transient page properties. -->
          
@@ -316,6 +318,16 @@
     
   </service-point>
 
+  <service-point id="ClientIdPropertyWorker" interface="EnhancementWorker">
+    
+    Enhances the IComponent.getClientId() abstract getter to properly provide 
+    client id's depending on the context called in. Does the same thing as 
+    AbstractPropertyWorker + the logic described.
+    
+    <invoke-factory>
+      <construct class="ClientIdPropertyWorker"/>
+    </invoke-factory>
+  </service-point>
   
   <service-point id="AbstractPropertyWorker" interface="EnhancementWorker">
     

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/AbstractComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/AbstractComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/AbstractComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/AbstractComponent.java Fri Nov 10 17:05:33 2006
@@ -43,7 +43,7 @@
  */
 
 public abstract class AbstractComponent extends BaseLocatable implements IDirectEvent
-{
+{   
     private static final int MAP_SIZE = 5;
     
     private static final int BODY_INIT_SIZE = 5;
@@ -53,9 +53,6 @@
      */
 
     private static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap(1));
-
-    /** @since 4.1 */
-    protected String _clientId;
     
     /**
      * The page that contains the component, possibly itself (if the component is in fact, a page).
@@ -302,17 +299,6 @@
      */
     protected void renderIdAttribute(IMarkupWriter writer, IRequestCycle cycle)
     {
-        // try to generate a client id if needed/possible
-        if (_clientId == null) {
-            String id = getBoundId();
-            
-            if (id == null) 
-                id = getId();
-            
-            if (id != null)
-                _clientId = cycle.getUniqueId(TapestryUtils.convertTapestryIdToNMToken(id));
-        }
-        
         String id = getClientId();
         
         if (id != null)
@@ -323,10 +309,10 @@
     private boolean isFormalParameter(String name)
     {
         Defense.notNull(name, "name");
-
+        
         return getSpecification().getParameter(name) != null;
     }
-
+    
     /**
      * Returns the named binding, or null if it doesn't exist.
      * <p>
@@ -407,6 +393,18 @@
         return _page.getPageName() + "/" + getIdPath();
     }
 
+    /** @since 4.1 */
+    
+    public String getSpecifiedId()
+    {
+        String id = getBoundId();
+        
+        if (id != null)
+            return id;
+        
+        return getId();
+    }
+    
     public String getId()
     {
         return _id;
@@ -443,22 +441,16 @@
      * {@inheritDoc}
      * @since 4.1
      */
-    public String getClientId()
-    {
-        if (_clientId != null)
-            return _clientId;
-        
-        String boundId = getBoundId();
-        
-        if (boundId == null)
-            return getId();
-        
-        return boundId;
-    }
+    public abstract String getClientId();
     
-    protected void setClientId(String id)
+    public abstract void setClientId(String id);
+    
+    protected void generateClientId()
     {
-        _clientId = id;
+        String id = getSpecifiedId();
+        
+        if (id != null && getPage() != null && getPage().getRequestCycle() != null)
+             setClientId(getPage().getRequestCycle().getUniqueId(TapestryUtils.convertTapestryIdToNMToken(id)));
     }
     
     protected String getBoundId()
@@ -695,12 +687,13 @@
             
             cycle.renderStackPush(this);
             
+            generateClientId();
+            
             prepareForRender(cycle);
             
             renderComponent(writer, cycle);
             
             getRenderWorker().renderComponent(cycle, this);
-            
         }
         finally
         {
@@ -708,9 +701,6 @@
             
             cleanupAfterRender(cycle);
             
-            // @since 4.1
-            _clientId = null;
-            
             cycle.renderStackPop();
         }
     }
@@ -899,7 +889,7 @@
     {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((_clientId == null) ? 0 : _clientId.hashCode());
+        result = prime * result + ((getClientId() == null) ? 0 : getClientId().hashCode());
         result = prime * result + ((_id == null) ? 0 : _id.hashCode());
         return result;
     }
@@ -914,9 +904,9 @@
         if (obj == null) return false;
         if (getClass() != obj.getClass()) return false;
         final AbstractComponent other = (AbstractComponent) obj;
-        if (_clientId == null) {
-            if (other._clientId != null) return false;
-        } else if (!_clientId.equals(other._clientId)) return false;
+        if (getClientId() == null) {
+            if (other.getClientId() != null) return false;
+        } else if (!getClientId().equals(other.getClientId())) return false;
         if (_id == null) {
             if (other._id != null) return false;
         } else if (!_id.equals(other._id)) return false;

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/BaseComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/BaseComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/BaseComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/BaseComponent.java Fri Nov 10 17:05:33 2006
@@ -25,7 +25,7 @@
  * @author Howard Lewis Ship
  */
 
-public class BaseComponent extends AbstractComponent implements ITemplateComponent
+public abstract class BaseComponent extends AbstractComponent implements ITemplateComponent
 {
     private static final Log LOG = LogFactory.getLog(BaseComponent.class);
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IComponent.java Fri Nov 10 17:05:33 2006
@@ -159,7 +159,16 @@
      */
 
     void setId(String value);
-
+    
+    /**
+     * Returns either the normal {@link #getId()} value OR the value of any binding 
+     * named <code>id</code> - if one exists. Higher precedence is given to bound id values.
+     * 
+     * @return The bound or normal component id, or null if neither exists.
+     */
+    
+    String getSpecifiedId();
+    
     /**
      * Returns the qualified id of the component. This represents a path from the {@link IPage page}
      * to this component, showing how components contain each other.
@@ -183,6 +192,15 @@
      * @since 4.1
      */
     String getClientId();
+    
+    /**
+     * Sets the client ID. It is <strong>strongly</strong> discouraged for you to try
+     * setting this unless you understand the ramifications of how the rest of the system
+     * relies on this functioning.
+     * 
+     * @param id The client id to set.
+     */
+    void setClientId(String id);
     
     /**
      * Though most component implementations ignore the specific html tag used 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java Fri Nov 10 17:05:33 2006
@@ -352,7 +352,19 @@
      */
 
     String getUniqueId(String baseId);
+    
+    /**
+     * Returns what <i>will</i> be the next unique id generated based on the given input, but doesn't
+     * store the result.
+     * 
+     * @param baseId
+     *            the base id from which to generate the unique string.
+     * @return baseId, or baseId with a suffix appended (if the method has been previously invoked
+     *         with the same baseId).
+     */
 
+    String peekUniqueId(String baseId);
+    
     /**
      * Sends a redirect to the client web browser. This is currently a convinience for constructing
      * and throwing a {@link RedirectException}, but may change in a later release.

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/Any.java Fri Nov 10 17:05:33 2006
@@ -46,9 +46,9 @@
             if (getId() != null && !isParameterBound("id"))
                 renderIdAttribute(writer, cycle);
         }
-
+        
         renderBody(writer, cycle);
-
+        
         if (!rewinding)
         {
             writer.end(element);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/ForBean.java Fri Nov 10 17:05:33 2006
@@ -97,13 +97,15 @@
     {
         // form may be null if component is not located in a form
         IForm form = (IForm) cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE);
-
+        
         // If the cycle is rewinding, but not this particular form,
         // then do nothing (don't even render the body).
         boolean cycleRewinding = cycle.isRewinding();
         if (cycleRewinding && form != null && !form.isRewinding())
             return;
-
+        
+        setForm(form);
+        
         // Get the data to be iterated upon. Store in form if needed.
         Iterator dataSource = getData(cycle, form);
 
@@ -142,7 +144,7 @@
 
                 if (element != null)
                     writer.end();
-
+                
                 _index++;
             }
         }
@@ -254,10 +256,12 @@
     {
         if (form == null || getVolatile())
             return evaluateSourceIterator();
-
+        
         String name = form.getElementId(this);
+        
         if (cycle.isRewinding())
             return getStoredData(cycle, name);
+        
         return storeSourceData(form, name);
     }
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/IfBean.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/IfBean.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/IfBean.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/components/IfBean.java Fri Nov 10 17:05:33 2006
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry.components;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.HiveMind;
 import org.apache.tapestry.IActionListener;
@@ -32,6 +34,8 @@
  */
 public abstract class IfBean extends AbstractFormComponent
 {
+    public static final Log _log = LogFactory.getLog(IfBean.class);
+    
     public static final String IF_VALUE_ATTRIBUTE = "org.mb.tapestry.base.IfValue";
     
     private boolean _rendering = false;
@@ -55,8 +59,8 @@
         boolean cycleRewinding = cycle.isRewinding();
         
         // form may be null if component is not located in a form
-        IForm form = (IForm) cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE);
-
+        IForm form = (IForm)cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE);
+        
         // If the cycle is rewinding, but not this particular form,
         // then do nothing (don't even render the body).
         if (cycleRewinding && form != null && !form.isRewinding())
@@ -88,7 +92,7 @@
                     writer.begin(element);
                     renderInformalParameters(writer, cycle);
                 }
-                
+                _log.debug("Condition was true so rendering body" + this);
                 renderBody(writer, cycle);
 
                 if (render)
@@ -114,8 +118,9 @@
         else
         {
             // we are in a form and we care -- load/store the condition in a hidden field
+            
             String name = form.getElementId(this);
-
+            
             if (!cycleRewinding)
             {
                 condition = getCondition();
@@ -126,15 +131,17 @@
                 condition = readValue(cycle, name);
             }
         }
-
+        
         // write condition value if parameter is bound
+        
         IBinding conditionValueBinding = getConditionValueBinding();
+        
         if (conditionValueBinding != null)
             conditionValueBinding.setObject(new Boolean(condition));
 
         return condition;
     }
-
+    
     private void writeValue(IForm form, String name, boolean value)
     {
         String externalValue;
@@ -157,7 +164,9 @@
     private boolean readValue(IRequestCycle cycle, String name)
     {
         String submittedValue = cycle.getParameter(name);
-
+        
+        _log.debug("readValue() with : " + name + " [" + submittedValue + "]");
+        
         try
         {
             Object valueObject = getDataSqueezer().unsqueeze(submittedValue);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/AjaxShellDelegate.java Fri Nov 10 17:05:33 2006
@@ -74,8 +74,11 @@
         JSONObject dojoConfig = new JSONObject();
         
         dojoConfig.put("isDebug", _debug);
-        dojoConfig.put("debugAtAllCosts", _debugAtAllCosts);
-        dojoConfig.put("debugContainerId", _debugContainerId);
+        
+        if (_debugAtAllCosts)
+            dojoConfig.put("debugAtAllCosts", _debugAtAllCosts);
+        if (_debugContainerId != null)
+            dojoConfig.put("debugContainerId", _debugContainerId);
         
         dojoConfig.put("baseRelativePath", 
                 _assetService.getLink(true, _dojoPath.getResourceLocation().getPath()).getAbsoluteURL());
@@ -83,10 +86,12 @@
         dojoConfig.put("preventBackButtonFix", _preventBackButtonFix);
         dojoConfig.put("parseWidgets", _parseWidgets);
         
-        String locale = cycle.getPage().getLocale().toString().toLowerCase();
-        locale = locale.replace('_', '-');
+        Locale locale = cycle.getPage().getLocale();
         
-        dojoConfig.put("locale", locale);
+        dojoConfig.put("locale", locale.getLanguage().toLowerCase()
+                + ((locale.getCountry() != null && !locale.getCountry().isEmpty())
+                ? "-" + locale.getCountry().toLowerCase()
+                        : ""));
         
         StringBuffer str = new StringBuffer("<script type=\"text/javascript\">");
         str.append("djConfig = ").append(dojoConfig.toString())
@@ -108,12 +113,15 @@
                 : "dojo.require(\"dojo.logging.Logger\");\n";
         
         // logging configuration
-        str.append("\n<script type=\"text/javascript\">\n")
-        .append(logRequire)
-        .append("dojo.log.setLevel(dojo.log.getLevel(\"").append(_browserLogLevel)
-        .append("\"));\n")
-        .append("dojo.require(\"tapestry.namespace\")\n")
-        .append("</script>");
+        str.append("\n<script type=\"text/javascript\">\n");
+        
+        if (_debug) {
+            str.append(logRequire)
+            .append("dojo.log.setLevel(dojo.log.getLevel(\"").append(_browserLogLevel)
+            .append("\"));\n");
+        }
+        
+        str.append("dojo.require(\"tapestry.namespace\");\n").append("</script>");
         
         writer.printRaw(str.toString());
         writer.println();

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/Dialog.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/Dialog.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/Dialog.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/dojo/html/Dialog.java Fri Nov 10 17:05:33 2006
@@ -53,23 +53,29 @@
      */
     public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
     {
-        writer.begin(getTemplateTagName()); // use element specified
-        renderIdAttribute(writer, cycle); // render id="" client id
-        renderInformalParameters(writer, cycle);
+        if (!cycle.isRewinding()) {
+            writer.begin(getTemplateTagName()); // use element specified
+            renderIdAttribute(writer, cycle); // render id="" client id
+            renderInformalParameters(writer, cycle);
+        }
         
         renderBody(writer, cycle);
         
-        writer.end();
+        if (!cycle.isRewinding()) {
+            writer.end();
+        }
         
-        JSONObject json = new JSONObject();
-        json.put("bgColor", getBackgroundColor());
-        json.put("bgOpacity", getOpacity());
+        if (!cycle.isRewinding()) {
+            JSONObject json = new JSONObject();
+            json.put("bgColor", getBackgroundColor());
+            json.put("bgOpacity", getOpacity());
 
-        Map parms = new HashMap();
-        parms.put("component", this);
-        parms.put("props", json.toString());
-        
-        getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), parms);
+            Map parms = new HashMap();
+            parms.put("component", this);
+            parms.put("props", json.toString());
+
+            getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), parms);
+        }
     }
     
     /** injected. */

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java Fri Nov 10 17:05:33 2006
@@ -635,7 +635,14 @@
     {
         return _idAllocator.allocateId(baseId);
     }
-
+    
+    /** @since 4.1 */
+    
+    public String peekUniqueId(String baseId)
+    {
+        return _idAllocator.peekNextId(baseId);
+    }
+    
     /** @since 4.0 */
     public void sendRedirect(String URL)
     {

Added: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClientIdPropertyWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClientIdPropertyWorker.java?view=auto&rev=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClientIdPropertyWorker.java (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/enhance/ClientIdPropertyWorker.java Fri Nov 10 17:05:33 2006
@@ -0,0 +1,131 @@
+// Copyright 2004, 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.enhance;
+
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+
+import org.apache.hivemind.ErrorLog;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.service.MethodSignature;
+import org.apache.tapestry.IComponent;
+import org.apache.tapestry.event.PageDetachListener;
+import org.apache.tapestry.spec.IComponentSpecification;
+
+
+/**
+ * Enhances the {@link org.apache.tapestry.IComponent#getClientId()} property.
+ */
+public class ClientIdPropertyWorker implements EnhancementWorker
+{
+    private static final String PROPERTY_NAME = "clientId";
+    
+    private ErrorLog _errorLog;
+    
+    public void performEnhancement(EnhancementOperation op, IComponentSpecification spec)
+    {
+        Location location = spec.getLocation();
+        
+        Iterator i = op.findUnclaimedAbstractProperties().iterator();
+
+        while (i.hasNext())
+        {
+            String name = (String) i.next();
+            
+            if (name.equals(PROPERTY_NAME)) {
+                
+                try
+                {
+                    createProperty(op, name, location);
+                }
+                catch (Exception ex)
+                {
+                    _errorLog.error(
+                            EnhanceMessages.errorAddingProperty(name, op.getBaseClass(), ex),
+                            location,
+                            ex);
+                }
+                
+                break;
+            }
+        }
+    }
+
+    private void createProperty(EnhancementOperation op, String name, Location location)
+    {
+        // This won't be null because its always for existing properties.
+
+        Class propertyType = op.getPropertyType(name);
+
+        String fieldName = "_$" + name;
+        String defaultFieldName = fieldName + "$defaultValue";
+
+        op.addField(fieldName, propertyType);
+        op.addField(defaultFieldName, propertyType);
+        
+        // EnhanceUtils.createSimpleAccessor(op, fieldName, name, propertyType, location);
+        
+        String methodName = op.getAccessorMethodName(name);
+        
+        // Build special getter logic 
+        // if the client id is null "peek" at the next possible unique id
+        
+        StringBuffer str = new StringBuffer();
+        
+        str.append(" if(").append(fieldName).append(" == null){")
+        .append(" if (getPage() == null) { return null; }")
+        .append(" String tempId = getSpecifiedId();")
+        .append(" if (tempId == null) { return null; }")
+        .append(" return getPage().getRequestCycle().peekUniqueId(org.apache.tapestry.TapestryUtils.convertTapestryIdToNMToken(tempId));")
+        .append("} else { ");
+        
+        // else return the existing clientId
+        
+        str.append("return ").append(fieldName).append(";");
+        
+        str.append("}");
+        
+        op.addMethod(
+                Modifier.PUBLIC,
+                new MethodSignature(propertyType, methodName, null, null),
+                str.toString(),
+                location);
+        
+        EnhanceUtils.createSimpleMutator(op, fieldName, name, propertyType, location);
+        
+        // Copy the real attribute into the default attribute inside finish load
+        // (allowing a default value to be set inside finishLoad()).
+
+        op.extendMethodImplementation(
+                IComponent.class,
+                EnhanceUtils.FINISH_LOAD_SIGNATURE,
+                defaultFieldName + " = " + fieldName + ";");
+
+        // On page detach, restore the attribute to its default value.
+
+        op.extendMethodImplementation(
+                PageDetachListener.class,
+                EnhanceUtils.PAGE_DETACHED_SIGNATURE,
+                fieldName + " = " + defaultFieldName + ";");
+
+        // This is not all that necessary, but is proper.
+
+        op.claimProperty(name);
+    }
+
+    public void setErrorLog(ErrorLog errorLog)
+    {
+        _errorLog = errorLog;
+    }
+}

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java Fri Nov 10 17:05:33 2006
@@ -147,12 +147,17 @@
     {
         getForm().getDelegate().writeSuffix(writer, cycle, this, null);
     }
-
+    
     protected void setName(IForm form)
     {
-        form.getElementId(this);
-        
-        setClientId(getName());
+        setName(form.getElementId(this));
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected void generateClientId()
+    {
     }
     
     /**

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Form.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Form.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Form.java Fri Nov 10 17:05:33 2006
@@ -127,7 +127,7 @@
 
     public String getElementId(IFormComponent component)
     {
-        return _formSupport.getElementId(component, component.getClientId());
+        return _formSupport.getElementId(component, component.getSpecifiedId());
     }
 
     /**
@@ -203,14 +203,12 @@
 
             throw new RenderRewoundException(this);
         }
-
+        
         // Note: not safe to invoke getNamespace() in Portlet world
         // except during a RenderRequest.
         
-        String baseName = constructFormNameForDirectService(cycle);
-        
-        _name = baseName + getResponse().getNamespace();
-        setClientId(_name);
+        // _name = getClientId() + getResponse().getNamespace();
+        _name = getClientId() + getResponse().getNamespace();
         
         if (_renderInformalParameters == null)
             _renderInformalParameters = new RenderInformalParameters();
@@ -219,7 +217,7 @@
         
         _formSupport.render(getMethod(), _renderInformalParameters, link, getScheme(), getPort());
     }
-
+    
     IActionListener findListener(String mode)
     {
         IActionListener result = null;
@@ -240,20 +238,7 @@
 
         return result;
     }
-
-    /**
-     * Constructs a form name for use with the direct service. This implementation bases the form
-     * name on the form component's id (but ensures it is unique). Remember that Tapestry assigns an
-     * "ugly" id if an explicit component id is not provided.
-     * 
-     * @since 4.0
-     */
-
-    private String constructFormNameForDirectService(IRequestCycle cycle)
-    {
-        return cycle.getUniqueId(TapestryUtils.convertTapestryIdToNMToken(getId()));
-    }
-
+    
     /**
      * Returns a new instance of {@link FormSupportImpl}.
      */

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java Fri Nov 10 17:05:33 2006
@@ -95,7 +95,7 @@
         set.add(RESERVED_FORM_IDS);
         set.add(SUBMIT_MODE);
         set.add(FormConstants.SUBMIT_NAME_PARAMETER);
-
+        
         _standardReservedIds = Collections.unmodifiableSet(set);
     }
 
@@ -375,9 +375,9 @@
 
     public String getElementId(IFormComponent component)
     {
-        return getElementId(component, component.getClientId());
+        return getElementId(component, component.getSpecifiedId());
     }
-
+    
     /**
      * Constructs a unique identifier (within the Form). The identifier consists of the component's
      * id, with an index number added to ensure uniqueness.
@@ -392,7 +392,7 @@
         // $ is not a valid character in an XML/XHTML id, so convert it to an underscore.
         
         String filteredId = TapestryUtils.convertTapestryIdToNMToken(baseId);
-
+        
         String result = _elementIdAllocator.allocateId(filteredId);
         
         if (_rewinding)
@@ -402,7 +402,7 @@
                 throw new StaleLinkException(FormMessages.formTooManyIds(_form, _allocatedIds
                         .size(), component), component);
             }
-
+            
             String expected = (String) _allocatedIds.get(_allocatedIdIndex);
             
             if (!result.equals(expected))
@@ -419,9 +419,11 @@
         }
 
         _allocatedIdIndex++;
-
+        
         component.setName(result);
         
+        component.setClientId(result);
+        
         return result;
     }
 
@@ -449,9 +451,9 @@
     private void reinitializeIdAllocatorForRewind()
     {
         String allocatedFormIds = _cycle.getParameter(FORM_IDS);
-
+        
         String[] ids = TapestryUtils.split(allocatedFormIds);
-
+        
         for (int i = 0; i < ids.length; i++)
             _allocatedIds.add(ids[i]);
 
@@ -468,6 +470,16 @@
             _elementIdAllocator.allocateId(ids[i]);
     }
     
+    int convertSeedToId(String input)
+    {
+        int index = input.lastIndexOf("_");
+        
+        if (index < 0)
+            throw new ApplicationRuntimeException("Unable to convert seedId of " + input + " to integer.");
+        
+        return Integer.parseInt(input.substring(index, input.length()));
+    }
+    
     public void render(String method, IRender informalParametersRenderer, ILink link, 
             String scheme, Integer port)
     {
@@ -484,12 +496,12 @@
         // client-side JavaScript forces an update.
 
         addHiddenValue(SUBMIT_MODE, null);
-
+        
         // And another for the name of the component that
         // triggered the submit.
 
         addHiddenValue(FormConstants.SUBMIT_NAME_PARAMETER, null);
-
+        
         IMarkupWriter nested = _writer.getNestedWriter();
 
         _form.renderBody(nested, _cycle);
@@ -517,13 +529,13 @@
         _writer.println();
 
         writeHiddenFields();
-
+        
         // Close the nested writer, inserting its contents.
         
         nested.close();
-
+        
         // Close the <form> tag.
-
+        
         _writer.end();
         
         String fieldId = _delegate.getFocusField();
@@ -573,7 +585,6 @@
         
         str.append(");");
         
-        
         _pageRenderSupport.addInitializationScript(_form, str.toString());
     }
     
@@ -584,17 +595,19 @@
         String mode = _cycle.getParameter(SUBMIT_MODE);
         
         // On a cancel, don't bother rendering the body or anything else at all.
-
+        
         if (FormConstants.SUBMIT_CANCEL.equals(mode))
             return mode;
-
+        
         reinitializeIdAllocatorForRewind();
-
+        
         _form.renderBody(_writer, _cycle);
         
         // New, handles cases where an eventlistener
         // causes a form submission.
+        
         BrowserEvent event = new BrowserEvent(_cycle);
+        
         _form.getEventInvoker().invokeFormListeners(this, _cycle, event);
         
         int expected = _allocatedIds.size();

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/TextField.java Fri Nov 10 17:05:33 2006
@@ -29,8 +29,7 @@
  * @author Howard Lewis Ship
  * @author Paul Ferraro
  */
-public abstract class TextField extends AbstractFormComponent implements
-        TranslatedField
+public abstract class TextField extends AbstractFormComponent implements TranslatedField
 {
 
     public abstract boolean isHidden();
@@ -46,7 +45,7 @@
     protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
         String value = getTranslatedFieldSupport().format(this, getValue());
-
+        
         renderDelegatePrefix(writer, cycle);
 
         writer.beginEmpty("input");
@@ -55,9 +54,11 @@
 
         writer.attribute("name", getName());
 
-        if (isDisabled()) writer.attribute("disabled", "disabled");
+        if (isDisabled()) 
+            writer.attribute("disabled", "disabled");
 
-        if (value != null) writer.attribute("value", value);
+        if (value != null) 
+            writer.attribute("value", value);
 
         renderIdAttribute(writer, cycle);
 
@@ -67,7 +68,7 @@
         getValidatableFieldSupport().renderContributions(this, writer, cycle);
 
         renderInformalParameters(writer, cycle);
-
+        
         writer.closeTag();
 
         renderDelegateSuffix(writer, cycle);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/BasePage.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/BasePage.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/BasePage.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/BasePage.java Fri Nov 10 17:05:33 2006
@@ -25,7 +25,7 @@
  * @author Howard Lewis Ship
  */
 
-public class BasePage extends AbstractPage
+public abstract class BasePage extends AbstractPage
 {
     /**
      * @return "text/html"

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/PageLoader.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/PageLoader.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/PageLoader.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pageload/PageLoader.java Fri Nov 10 17:05:33 2006
@@ -395,7 +395,7 @@
                         .getNamespace();
 
                 // Instantiate the contained component.
-
+                
                 IComponent component = instantiateComponent(page, container,
                         id, componentSpecification, _componentResolver
                                 .getType(), componentNamespace, contained);
@@ -520,7 +520,7 @@
                 .getComponentConstructor(spec, className);
 
         IComponent result = (IComponent) cc.newInstance();
-
+        
         result.setNamespace(namespace);
         result.setPage(page);
         result.setContainer(container);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/OpenToken.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/OpenToken.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/OpenToken.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/parse/OpenToken.java Fri Nov 10 17:05:33 2006
@@ -58,7 +58,7 @@
     public OpenToken(String tag, String id, String componentType, Location location)
     {
         super(TokenType.OPEN, location);
-
+        
         _tag = tag;
         _id = id;
         _componentType = componentType;

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java Fri Nov 10 17:05:33 2006
@@ -527,6 +527,7 @@
     /**
      * Gets the id of the specified component, choosing the "id" element
      * binding over any other id.
+     * 
      * @param comp
      * @return The id of the component.
      */

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ContainedComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ContainedComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ContainedComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ContainedComponent.java Fri Nov 10 17:05:33 2006
@@ -30,13 +30,13 @@
 {
     private static final int MAP_SIZE = 3;
     
-    protected Map bindings;
+    protected Map _bindings;
+    
+    private String _type;
 
-    private String type;
+    private String _copyOf;
 
-    private String copyOf;
-
-    private boolean inheritInformalParameters;
+    private boolean _inheritInformalParameters;
 
     /** @since 4.0 */
     private String _propertyName;
@@ -47,10 +47,10 @@
 
     public IBindingSpecification getBinding(String name)
     {
-        if (bindings == null)
+        if (_bindings == null)
             return null;
 
-        return (IBindingSpecification) bindings.get(name);
+        return (IBindingSpecification) _bindings.get(name);
     }
 
     /**
@@ -60,30 +60,30 @@
 
     public Collection getBindingNames()
     {
-        if (bindings == null)
+        if (_bindings == null)
             return Collections.EMPTY_LIST;
 
-        return Collections.unmodifiableCollection(bindings.keySet());
+        return Collections.unmodifiableCollection(_bindings.keySet());
     }
 
     public String getType()
     {
-        return type;
+        return _type;
     }
 
     public void setBinding(String name, IBindingSpecification spec)
     {
-        if (bindings == null)
-            bindings = new HashMap(MAP_SIZE);
+        if (_bindings == null)
+            _bindings = new HashMap(MAP_SIZE);
 
-        bindings.put(name, spec);
+        _bindings.put(name, spec);
     }
 
     public void setType(String value)
     {
-        type = value;
+        _type = value;
     }
-
+    
     /**
      * Sets the String Id of the component being copied from. For use by IDE tools like Spindle.
      * 
@@ -92,7 +92,7 @@
 
     public void setCopyOf(String id)
     {
-        copyOf = id;
+        _copyOf = id;
     }
 
     /**
@@ -103,7 +103,7 @@
 
     public String getCopyOf()
     {
-        return copyOf;
+        return _copyOf;
     }
 
     /**
@@ -113,7 +113,7 @@
      */
     public boolean getInheritInformalParameters()
     {
-        return inheritInformalParameters;
+        return _inheritInformalParameters;
     }
 
     /**
@@ -123,7 +123,7 @@
      */
     public void setInheritInformalParameters(boolean value)
     {
-        inheritInformalParameters = value;
+        _inheritInformalParameters = value;
     }
 
     /** @since 4.0 */

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IContainedComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IContainedComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IContainedComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IContainedComponent.java Fri Nov 10 17:05:33 2006
@@ -47,7 +47,7 @@
     void setBinding(String name, IBindingSpecification spec);
 
     void setType(String value);
-
+    
     /**
      * Sets the String Id of the component being copied from. For use by IDE
      * tools like Spindle.

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/IdAllocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/IdAllocator.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/IdAllocator.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/IdAllocator.java Fri Nov 10 17:05:33 2006
@@ -17,6 +17,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.util.Defense;
 
 /**
@@ -36,12 +37,9 @@
     private final Map _generatorMap = new HashMap();
 
     private final String _namespace;
-
-    /**
-     * 
-     * @author unkonwn
-     */
-    private static class NameGenerator
+    
+    /** Class used only by IdAllocator. */
+    private class NameGenerator implements Cloneable
     {
 
         private final String _baseId;
@@ -57,6 +55,20 @@
         {
             return _baseId + _index++;
         }
+        
+        public String peekId()
+        {
+            return _baseId + _index;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        protected Object clone()
+            throws CloneNotSupportedException
+        {
+            return super.clone();
+        }
     }
 
     public IdAllocator()
@@ -70,7 +82,7 @@
 
         _namespace = namespace;
     }
-
+    
     /**
      * Allocates the id. Repeated calls for the same name will return "name",
      * "name_0", "name_1", etc.
@@ -88,7 +100,8 @@
             g = new NameGenerator(key);
             result = key;
         }
-        else result = g.nextId();
+        else 
+            result = g.nextId();
 
         // Handle the degenerate case, where a base name of the form "foo$0" has
         // been
@@ -96,12 +109,57 @@
 
         while(_generatorMap.containsKey(result))
             result = g.nextId();
-
+        
         _generatorMap.put(result, g);
-
+        
         return result;
     }
+    
+    /**
+     * Should return the exact same thing as {@link #allocateId(String)}, with the difference
+     * that the calculated id is not allocated and stored so multiple calls will always return the 
+     * same thing. 
+     * 
+     * @param name The name to peek at.
+     * @return The next id that will be allocated for the given name.
+     */
+    public String peekNextId(String name)
+    {
+        String key = name + _namespace;
 
+        NameGenerator g = (NameGenerator) _generatorMap.get(key);
+        String result = null;
+        
+        if (g == null)
+        {
+            g = new NameGenerator(key);
+            result = key;
+        } else 
+            result = g.peekId();
+        
+        // Handle the degenerate case, where a base name of the form "foo_0" has
+        // been
+        // requested. Skip over any duplicates thus formed.
+        
+        // in a peek we don't want to actually increment any id state so we must
+        // clone
+        
+        if (_generatorMap.containsKey(result)) {
+            
+            try {
+                NameGenerator cg = (NameGenerator)g.clone();
+                
+                while (_generatorMap.containsKey(result))
+                    result = cg.nextId();
+                
+            } catch (CloneNotSupportedException e) {
+                throw new ApplicationRuntimeException(e);
+            }
+        }
+        
+        return result;
+    }
+    
     /**
      * Clears the allocator, resetting it to freshly allocated state.
      */

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/valid/FieldLabel.java Fri Nov 10 17:05:33 2006
@@ -48,17 +48,17 @@
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
         IForm form = TapestryUtils.getForm(cycle, this);
-
+        
         IFormComponent field = getField();
-
+        
         if (field != null && isPrerender())
             form.prerenderField(writer, field, getLocation());
-
+        
         if (cycle.isRewinding()) 
             return;
-
+        
         String displayName = getDisplayName();
-
+        
         if (displayName == null)
         {
             if (field == null)
@@ -70,16 +70,17 @@
                 throw new BindingException(ValidMessages.noDisplayName(this,
                         field), this, null, getBinding("field"), null);
         }
-
+        
         IValidationDelegate delegate = form.getDelegate();
-
+        
         String id = field == null ? null : field.getClientId();
         
         delegate.writeLabelPrefix(field, writer, cycle);
         
         writer.begin("label");
-
-        if (id != null) writer.attribute("for", id);
+        
+        if (id != null) 
+            writer.attribute("for", id);
         
         delegate.writeLabelAttributes(writer, cycle, field);
         renderInformalParameters(writer, cycle);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Fri Nov 10 17:05:33 2006
@@ -90,7 +90,9 @@
 	 * 
 	 */
 	load:function(type, data, http, kwArgs){
-		dojo.log.debug("Response recieved.");
+		if (djConfig["isDebug"]) {
+			dojo.log.debug("Response recieved.", data);
+		}
 		if (!data) {
 			dojo.log.warn("No data received in response.");
 			return;
@@ -139,8 +141,8 @@
 			
 			var node=dojo.byId(id);
 			if (!node) {
-				dojo.log.err("No node could be found to update content in with id " + id);
-				return;
+				dojo.log.warn("No node could be found to update content in with id " + id);
+				continue;
 			}
 			
 			tapestry.loadContent(id, node, elms[i]);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/TestAbstractComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/TestAbstractComponent.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/TestAbstractComponent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/TestAbstractComponent.java Fri Nov 10 17:05:33 2006
@@ -35,7 +35,15 @@
         protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
         {
         }
-
+        
+        public void setClientId(String id)
+        {
+        }
+        
+        public String getClientId()
+        {
+            return null;
+        }
     }
     
     public void testUnimplementedMethods()

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/dojo/AjaxShellDelegateTest.java Fri Nov 10 17:05:33 2006
@@ -41,10 +41,12 @@
     void trainStaticPath(IEngineService engine, IAsset asset, String path)
     {
         Resource res = newMock(Resource.class);
+        
         expect(asset.getResourceLocation()).andReturn(res);
         expect(res.getPath()).andReturn(path);
         
         ILink link = newLink();
+        
         expect(engine.getLink(Boolean.TRUE, path)).andReturn(link);
         expect(link.getAbsoluteURL()).andReturn("http://" + path);
     }
@@ -52,6 +54,7 @@
     void trainPageLocale(IRequestCycle cycle, Locale locale)
     {
         IPage page = newMock(IPage.class);        
+        
         expect(cycle.getPage()).andReturn(page);
         expect(page.getLocale()).andReturn(locale);
     }
@@ -87,15 +90,13 @@
         verify();
         
         assertBuffer("<script type=\"text/javascript\">djConfig = {\"isDebug\":false,"
-                + "\"debugAtAllCosts\":false,\"baseRelativePath\":\"http:///dojo/path\","
+                + "\"baseRelativePath\":\"http:///dojo/path\","
                 +"\"preventBackButtonFix\":false,\"parseWidgets\":false,\"locale\":\"en-us\"} </script>\n" + 
                 "\n" + 
                 " <script type=\"text/javascript\" src=\"http:///dojo/path/dojo.js\"></script>"
                 +"<script type=\"text/javascript\" src=\"http:///tapestry/tapestry.js\"></script>\n" + 
                 "<script type=\"text/javascript\">\n" + 
-                "dojo.require(\"dojo.logging.Logger\");\n" + 
-                "dojo.log.setLevel(dojo.log.getLevel(\"WARNING\"));\n" + 
-                "dojo.require(\"tapestry.namespace\")\n" + 
+                "dojo.require(\"tapestry.namespace\");\n" + 
         "</script>" + SYSTEM_NEWLINE);
     }
     
@@ -122,6 +123,7 @@
         d.setDojoPath(dojoPath);
         d.setDojoSource(dojoSource);
         d.setTapestrySource(tSource);
+        d.setDebug(true);
         d.setLogLevel(AjaxShellDelegate.BROWSER_LOG_DEBUG);
         d.setConsoleEnabled(true);
         
@@ -131,8 +133,8 @@
         
         verify();
         
-        assertBuffer("<script type=\"text/javascript\">djConfig = {\"isDebug\":false,"
-                + "\"debugAtAllCosts\":false,\"baseRelativePath\":\"http:///dojo/path\","
+        assertBuffer("<script type=\"text/javascript\">djConfig = {\"isDebug\":true,"
+                + "\"baseRelativePath\":\"http:///dojo/path\","
                 +"\"preventBackButtonFix\":false,\"parseWidgets\":false,\"locale\":\"en-gb\"} </script>\n" + 
                 "\n" + 
                 " <script type=\"text/javascript\" src=\"http:///dojo/path/dojo.js\"></script>"
@@ -140,7 +142,7 @@
                 "<script type=\"text/javascript\">\n" + 
                 "dojo.require(\"dojo.debug.console\");\n" + 
                 "dojo.log.setLevel(dojo.log.getLevel(\"DEBUG\"));\n" + 
-                "dojo.require(\"tapestry.namespace\")\n" + 
+                "dojo.require(\"tapestry.namespace\");\n" + 
         "</script>" + SYSTEM_NEWLINE);
     }
 }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/BaseFormComponentTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/BaseFormComponentTestCase.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/BaseFormComponentTestCase.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/BaseFormComponentTestCase.java Fri Nov 10 17:05:33 2006
@@ -87,6 +87,7 @@
     {
         form.getElementId(component);
         component.setName(name);
+        component.setClientId(name);
         expectLastCall().andReturn(name);
     }
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java Fri Nov 10 17:05:33 2006
@@ -91,10 +91,11 @@
         IFormComponent component = newMock(IFormComponent.class);
         checkOrder(component, false);
         
-        expect(component.getClientId()).andReturn(id);
+        expect(component.getSpecifiedId()).andReturn(id);
 
         component.setName(name);
-
+        component.setClientId(name);
+        
         return component;
     }
 
@@ -102,7 +103,7 @@
     {
         IFormComponent component = newMock(IFormComponent.class);
 
-        expect(component.getClientId()).andReturn(id);
+        expect(component.getSpecifiedId()).andReturn(id);
         
         trainGetExtendedId(component, extendedId);
         trainGetLocation(component, location);

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormTest.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormTest.java Fri Nov 10 17:05:33 2006
@@ -146,8 +146,6 @@
         trainStoreForm(cycle, form);
         
         trainIsRewinding(support, false);
-        
-        trainGetUniqueId(cycle, "myform", "myform_1");
 
         trainGetNamespace(response, "$ns");
         
@@ -196,8 +194,6 @@
         
         trainIsRewinding(support, false);
         
-        trainGetUniqueId(cycle, "myform", "myform_1");
-        
         trainGetNamespace(response, "$ns");
 
         trainGetLinkCheckIgnoreParameter(
@@ -357,8 +353,6 @@
         trainStoreForm(cycle, form);
         
         trainIsRewinding(support, false);
-        
-        trainGetUniqueId(cycle, "myform", "myform_1");
         
         trainGetNamespace(response, "$ns");
         

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/LinkSubmitTest.java Fri Nov 10 17:05:33 2006
@@ -83,13 +83,11 @@
 
         LinkSubmit linkSubmit = newInstance(LinkSubmit.class, new Object[]
         { "form", form, "name", "fred_1", "script", script, 
-            "id", "fred_id", "submitType", "submit" });
+            "id", "fred_id", "clientId", "fred_1", "submitType", "submit" });
         
         linkSubmit.addBody(newBody());
 
         trainGetSupport(cycle, support);
-
-        trainGetUniqueId(cycle, "fred_id", "fred_id_unique");
         
         trainResponseBuilder(cycle, writer);
         
@@ -99,7 +97,7 @@
 
         verify();
 
-        assertBuffer("<a href=\"HREF\" id=\"fred_id_unique\">BODY</a>");
+        assertBuffer("<a href=\"HREF\" id=\"fred_1\">BODY</a>");
     }
 
     public void testRenderDisabled()

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockForm.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockForm.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/MockForm.java Fri Nov 10 17:05:33 2006
@@ -81,6 +81,15 @@
         return false;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public void setClientId(String id)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
     public MockForm(IValidationDelegate delegate)
     {
         this(delegate, null);
@@ -90,6 +99,15 @@
     {
         _delegate = delegate;
         _location = location;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSpecifiedId()
+    {
+        // TODO Auto-generated method stub
+        return null;
     }
 
     public void rewind(IMarkupWriter writer, IRequestCycle cycle)

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestButton.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestButton.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestButton.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestButton.java Fri Nov 10 17:05:33 2006
@@ -82,10 +82,10 @@
     public void testRenderWithId()
     {
         Button b = newInstance(Button.class, new Object[]
-        { "id", "assignedId", "name", "assignedName"});
+        { "clientId", "assignedId", "name", "assignedId"});
         
         IMarkupWriter writer = newBufferWriter();
-        IRequestCycle cycle = newCycleGetUniqueId("assignedId", "assignedId$unique");
+        IRequestCycle cycle = newCycle();
         
         replay();
 
@@ -93,7 +93,7 @@
 
         verify();
 
-        assertBuffer("<button type=\"button\" name=\"assignedName\" id=\"assignedId$unique\"></button>");
+        assertBuffer("<button type=\"button\" name=\"assignedId\" id=\"assignedId\"></button>");
     }
 
     public void testSubmit()

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestCheckbox.java Fri Nov 10 17:05:33 2006
@@ -164,7 +164,7 @@
         ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
         
         Checkbox cb = newInstance(Checkbox.class, new Object[]
-        { "id", "foo", "name", "assignedName", "value", Boolean.TRUE,
+        { "id", "foo", "clientId", "assignedName", "name", "assignedName", "value", Boolean.TRUE,
             "form",  form, "validatableFieldSupport", vfs});
         
         IMarkupWriter writer = newBufferWriter();
@@ -173,11 +173,9 @@
         IValidationDelegate delegate = newDelegate();
         trainGetDelegate(form, delegate);
         
-        // IRequestCycle cycle = newCycleGetUniqueId("foo", "foo$unique");
-        
         delegate.writePrefix(writer, cycle, cb, null);
         
-        expect(cycle.getUniqueId("foo")).andReturn("foo$unique");
+        // expect(cycle.getUniqueId("foo")).andReturn("foo$unique");
         
         vfs.renderContributions(cb, writer, cycle);
         
@@ -191,7 +189,7 @@
 
         verify();
         
-        assertBuffer("<input type=\"checkbox\" name=\"assignedName\" checked=\"checked\" id=\"foo$unique\"/>");
+        assertBuffer("<input type=\"checkbox\" name=\"assignedName\" checked=\"checked\" id=\"assignedName\"/>");
     }
 
     public void testSubmitNull()

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestImageSubmit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestImageSubmit.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestImageSubmit.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestImageSubmit.java Fri Nov 10 17:05:33 2006
@@ -102,6 +102,9 @@
         writer.attribute("name", "fred");
         writer.attribute("border", 0);
         writer.attribute("src", "image-url");
+        
+        writer.attribute("id", "fred");
+        
         writer.closeTag();
         
         trainIsInError(delegate, false);
@@ -150,6 +153,9 @@
         writer.attribute("disabled", "disabled");
         writer.attribute("border", 0);
         writer.attribute("src", "disabled-image-url");
+        
+        writer.attribute("id", "fred");
+        
         writer.closeTag();
 
         replay();
@@ -194,6 +200,9 @@
         writer.attribute("disabled", "disabled");
         writer.attribute("border", 0);
         writer.attribute("src", "image-url");
+        
+        writer.attribute("id", "fred");
+        
         writer.closeTag();
 
         replay();

Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java?view=auto&rev=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java Fri Nov 10 17:05:33 2006
@@ -0,0 +1,72 @@
+// Copyright 2004, 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.util;
+
+import static org.testng.AssertJUnit.*;
+
+import org.testng.annotations.Test;
+
+
+/**
+ * Tests functionality of {@link IdAllocator}.
+ */
+@Test
+public class TestIdAllocator
+{
+    public void test_Simple_Allocation()
+    {
+        IdAllocator ida = new IdAllocator();
+        
+        assertEquals("name", ida.allocateId("name"));
+        assertEquals("name_0", ida.allocateId("name"));
+        assertEquals("name_1", ida.allocateId("name"));
+    }
+    
+    public void test_Namespace_Allocation()
+    {
+        IdAllocator ida = new IdAllocator("_test");
+        
+        assertEquals("name_test",ida.allocateId("name"));
+        assertEquals("name_test_0", ida.allocateId("name"));
+        assertEquals("name_test_1", ida.allocateId("name"));
+    }
+    
+    public void test_Peek_Allocation()
+    {
+        IdAllocator ida = new IdAllocator();
+        
+        assertEquals("name", ida.allocateId("name"));
+        
+        assertEquals("name_0", ida.peekNextId("name"));
+        assertEquals("name_0", ida.allocateId("name"));
+        
+        assertEquals("name_1", ida.peekNextId("name"));
+        assertEquals("name_1", ida.peekNextId("name"));
+    }
+    
+    public void test_Peek_Allocation_With_PriorId()
+    {
+        IdAllocator ida = new IdAllocator();
+        
+        assertEquals("name", ida.allocateId("name"));
+        
+        assertEquals("name_0", ida.peekNextId("name_0"));
+        assertEquals("name_0", ida.allocateId("name"));
+        
+        assertEquals("name_1", ida.peekNextId("name"));
+        assertEquals("name_1", ida.peekNextId("name"));
+        
+        assertEquals("name_1", ida.peekNextId("name_0"));
+    }
+}

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java?view=diff&rev=473608&r1=473607&r2=473608
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/valid/FieldLabelTest.java Fri Nov 10 17:05:33 2006
@@ -161,8 +161,7 @@
         IRequestCycle cycle = newCycle();
         
         FieldLabel fl = newInstance(FieldLabel.class, 
-                new Object[] { "id", "label"
-        });
+                new Object[] { "id", "label"});
         
         expect(cycle.renderStackPush(fl)).andReturn(fl);