tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r411005 - in /tapestry/tapestry4/trunk: ./ annotations/src/java/org/apache/tapestry/annotations/ examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/ framework/src/java/org/apache/tapestry/ framework/src/java/org/apache/tapes...
Date Fri, 02 Jun 2006 00:24:01 GMT
Author: jkuhnert
Date: Thu Jun  1 17:24:00 2006
New Revision: 411005

URL: http://svn.apache.org/viewvc?rev=411005&view=rev
Log:
Fixed issues with resolving client id's on all components. 

Removed:
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/DatePicker.js.merge-left.r384672
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/DatePicker.js.merge-right.r384672
Modified:
    tapestry/tapestry4/trunk/annotations/src/java/org/apache/tapestry/annotations/EventListener.java
    tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/AbstractComponent.java
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/ComponentEvent.script
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/IComponent.java
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/dojo/html/WidgetEvent.script
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/IFormComponent.java
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/html/ElementEvent.script
    tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
    tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/MockForm.java
    tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
    tapestry/tapestry4/trunk/status.xml

Modified: tapestry/tapestry4/trunk/annotations/src/java/org/apache/tapestry/annotations/EventListener.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/annotations/src/java/org/apache/tapestry/annotations/EventListener.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/annotations/src/java/org/apache/tapestry/annotations/EventListener.java
(original)
+++ tapestry/tapestry4/trunk/annotations/src/java/org/apache/tapestry/annotations/EventListener.java
Thu Jun  1 17:24:00 2006
@@ -48,4 +48,18 @@
      * Ie <code>events = {"onClick", "onOptionSelect"}</code> etc..
      */
     String[] events();
+    
+    /**
+     * The form id of the form that should have its data submitted when one 
+     * of the specified events is triggered.
+     * @return
+     */
+    String submitForm() default "";
+    
+    /**
+     * Whether or not to perform form validation if the {@link #form()} parameter has 
+     * been set. Default is false.
+     * @return
+     */
+    boolean validateForm() default false;
 }

Modified: tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
(original)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
Thu Jun  1 17:24:00 2006
@@ -40,7 +40,7 @@
     
     @Component(type = "Autocompleter", id = "projectChoose",
             bindings = { "model=projectModel", "value=selectedProject",
-            "displayName=message:choose.project", "filterOnChange=ognl:true"})
+            "displayName=message:choose.project", "filterOnChange=true"})
     public abstract Autocompleter getProjectSelection();
     
     @InjectObject("service:timetracker.dao.ProjectDao")

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/AbstractComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/AbstractComponent.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/AbstractComponent.java
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/AbstractComponent.java
Thu Jun  1 17:24:00 2006
@@ -412,6 +412,20 @@
         return _idPath;
     }
 
+    /**
+     * 
+     * {@inheritDoc}
+     * @since 4.1
+     */
+    public String getClientId()
+    {
+        IBinding id = (IBinding)_bindings.get("id");
+        if (id == null)
+            return getId();
+        
+        return id.getObject().toString();
+    }
+    
     public IPage getPage()
     {
         return _page;

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/ComponentEvent.script
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/ComponentEvent.script?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/ComponentEvent.script
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/ComponentEvent.script
Thu Jun  1 17:24:00 2006
@@ -14,10 +14,10 @@
     </body>
     <initialization>
         <foreach expression="events" key="event">
-        dojo.event.connect(dojo.byId("${component.id}"), "${event}", function(e) {
+        dojo.event.connect(dojo.byId("${component.clientId}"), "${event}", function(e) {
             var content={beventname:"${event}"};
             tapestry.event.buildEventProperties(e, content);
-            if (!content["beventtarget.id"]) content["beventtarget.id"]="${component.id}";
+            if (!content["beventtarget.id"]) content["beventtarget.id"]="${component.clientId}";
             
             tapestry.bind("${url}", content);
         });

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/IComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/IComponent.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/IComponent.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/IComponent.java Thu Jun
 1 17:24:00 2006
@@ -174,6 +174,17 @@
     String getIdPath();
 
     /**
+     * Returns the component's client-side element id. This has traditionally been an 
+     * {@link IFormComponent} only binding but now applies to all components. The method
+     * should check to see if any id parameter/property has been set already and use that
+     * above all others, falling back to {@link #getId()} if nothing else is found.
+     * 
+     * @return the id, or null if the component doesn't support a client id.
+     * @since 4.1
+     */
+    String getClientId();
+    
+    /**
      * Returns the page which ultimately contains the receiver. A page will return itself.
      */
 

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/dojo/html/WidgetEvent.script
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/dojo/html/WidgetEvent.script?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/dojo/html/WidgetEvent.script
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/dojo/html/WidgetEvent.script
Thu Jun  1 17:24:00 2006
@@ -14,10 +14,10 @@
     </body>
     <initialization>
         <foreach expression="events" key="event">
-        dojo.event.connect(dojo.widget.byId("${component.id}"), "${event}", function(e) {
+        dojo.event.connect(dojo.widget.byId("${component.clientId}"), "${event}", function(e)
{
             var content={beventname:"${event}"};
             tapestry.event.buildEventProperties(e, content);
-            if (!content["beventtarget.id"]) content["beventtarget.id"]="${component.id}";
+            if (!content["beventtarget.id"]) content["beventtarget.id"]="${component.clientId}";
             
             tapestry.bind("${url}", content);
         });

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/AbstractFormComponent.java
Thu Jun  1 17:24:00 2006
@@ -184,5 +184,10 @@
 
     protected abstract void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle);
 
+    /**
+     * 
+     * @param writer
+     * @param cycle
+     */
     protected abstract void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle);
 }

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/IFormComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/IFormComponent.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/IFormComponent.java
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/form/IFormComponent.java
Thu Jun  1 17:24:00 2006
@@ -86,6 +86,12 @@
      * {@link #getName()}, if a component renders more than once (such as inside a loop)
then on
      * each render it will have a different clientId.
      * 
+     * <p>
+     * <b>Note:</b>Though semantically this method should result in the roughly
the same results,
+     * the method used to create unique client ID's on form components is <i>not</i>
the same as that
+     * defined in {@link IComponent}. 
+     * </p>
+     * 
      * @return the id, or null if the component doesn't support an id.
      * @since 4.0
      */

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/html/ElementEvent.script
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/html/ElementEvent.script?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/html/ElementEvent.script
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/html/ElementEvent.script
Thu Jun  1 17:24:00 2006
@@ -17,7 +17,7 @@
         dojo.event.connect(dojo.byId("${target}"), "${event}", function(e) {
             var content={beventname:"${event}"};
             tapestry.event.buildEventProperties(e, content);
-            if (!content["beventtarget.id"]) content["beventtarget.id"]="${component.id}";
+            if (!content["beventtarget.id"]) content["beventtarget.id"]="${target}";
             
             tapestry.bind("${url}", content);
         });

Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
(original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentEventConnectionWorker.java
Thu Jun  1 17:24:00 2006
@@ -56,6 +56,10 @@
     
     private ClassResolver _resolver;
     
+    private ClasspathResource _componentResource;
+    private ClasspathResource _widgetResource;
+    private ClasspathResource _elementResource;
+    
     /** 
      * {@inheritDoc}
      */
@@ -95,7 +99,7 @@
         String url = _eventEngine.getLink(false, dsp).getURL();
         
         PageRenderSupport prs = TapestryUtils.getPageRenderSupport(cycle, component);
-        Resource resource = new ClasspathResource(_resolver, _elementScript);
+        Resource resource = getScript(component);
         
         Map elements = _invoker.getElementEvents();
         Iterator keys = elements.keySet().iterator();
@@ -118,10 +122,22 @@
     
     Resource getScript(IComponent component)
     {
-        if (IWidget.class.isInstance(component))
-            return new ClasspathResource(_resolver, _widgetScript);
+        if (IWidget.class.isInstance(component)) {
+            if (_widgetResource == null) 
+                _widgetResource = new ClasspathResource(_resolver, _widgetScript);
+            return _widgetResource;
+        }
+        
+        if (Body.class.isInstance(component)) {
+            if (_elementResource == null) 
+                _elementResource = new ClasspathResource(_resolver, _elementScript);
+            return _elementResource;
+        }
+        
+        if (_componentResource == null) 
+            _componentResource = new ClasspathResource(_resolver, _componentScript);
         
-        return new ClasspathResource(_resolver, _componentScript);
+        return _componentResource;
     }
     
     /**

Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/MockForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/MockForm.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/MockForm.java (original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/form/MockForm.java Thu
Jun  1 17:24:00 2006
@@ -140,6 +140,11 @@
     {
     }
 
+    public String getClientId()
+    {
+        return null;
+    }
+    
     public Map getAssets()
     {
         return null;

Modified: tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
(original)
+++ tapestry/tapestry4/trunk/framework/src/test/org/apache/tapestry/services/impl/ComponentEventConnectionWorkerTest.java
Thu Jun  1 17:24:00 2006
@@ -32,6 +32,9 @@
 import org.apache.tapestry.engine.IEngineService;
 import org.apache.tapestry.engine.ILink;
 import org.apache.tapestry.engine.IScriptSource;
+import org.apache.tapestry.html.Body;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
 
 
 /**
@@ -138,6 +141,41 @@
         replayControls();
         
         worker.renderComponent(cycle, widget);
+        
+        verifyControls();
+    }
+    
+    public void testScriptResource()
+    {   
+        ClassResolver resolver = new DefaultClassResolver();
+        ComponentEventInvoker invoker = new ComponentEventInvoker();
+        
+        String compScript = "/org/apache/tapestry/ComponentEvent.script";
+        String widScript = "/org/apache/tapestry/dojo/html/WidgetEvent.script";
+        String elementScript = "/org/apache/tapestry/html/ElementEvent.script";
+        
+        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
+        worker.setClassResolver(resolver);
+        worker.setComponentEventInvoker(invoker);
+        worker.setComponentScript(compScript);
+        worker.setWidgetScript(widScript);
+        worker.setElementScript(elementScript);
+        
+        IDirectEvent component = (IDirectEvent)newMock(IDirectEvent.class);
+        IWidget widget = (IWidget)newMock(IWidget.class);
+        MockControl bodyControl = MockClassControl.createControl(Body.class);
+        Body body = (Body) bodyControl.getMock();
+        
+        assertNotNull(worker.getScript(component));
+        assertEquals(compScript, worker.getScript(component).getPath());
+        
+        assertNotNull(worker.getScript(widget));
+        assertEquals(widScript, worker.getScript(widget).getPath());
+        
+        assertNotNull(worker.getScript(body));
+        assertEquals(elementScript, worker.getScript(body).getPath());
+        
+        replayControls();
         
         verifyControls();
     }

Modified: tapestry/tapestry4/trunk/status.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/status.xml?rev=411005&r1=411004&r2=411005&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/status.xml (original)
+++ tapestry/tapestry4/trunk/status.xml Thu Jun  1 17:24:00 2006
@@ -92,6 +92,9 @@
       <action type="add" dev="JK" due-to="James Carman" fixes-bug="TAPESTRY-947">
         Changed data squeezer to be a pipeline, allowing for a more flexible contribution/configuration.
       </action>
+      <action type="add" dev="JK" >
+        Added new IComponent.getClientId for global element id resolution on all components.
+      </action>
     </release>
     <release version="4.0.1" date="unreleased" >
       <action type="fix" dev="JK" fixes-bug="TAPESTRY-863" due-to="unknown contributor">



Mime
View raw message