tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r535694 - in /tapestry/tapestry4/trunk: tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/ tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/table/ tapestry-framework/src/java/org/apache/tapestry/bind...
Date Mon, 07 May 2007 00:33:21 GMT
Author: jkuhnert
Date: Sun May  6 17:33:20 2007
New Revision: 535694

URL: http://svn.apache.org/viewvc?view=rev&rev=535694
Log:
Resolves TAPESTRY-1068. Ability to throw RenderRewoundException from listener method.

Modified:
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/TreeDataView.java
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ListenerMethodBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/FormSupportImpl.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestListenerMethodBinding.java

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/TreeDataView.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/TreeDataView.java?view=diff&rev=535694&r1=535693&r2=535694
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/TreeDataView.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/TreeDataView.java
Sun May  6 17:33:20 2007
@@ -14,8 +14,6 @@
 
 package org.apache.tapestry.contrib.tree.components;
 
-import java.util.Iterator;
-
 import org.apache.tapestry.BaseComponent;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRequestCycle;
@@ -24,13 +22,13 @@
 import org.apache.tapestry.contrib.tree.model.ITreeRowSource;
 import org.apache.tapestry.contrib.tree.model.TreeRowObject;
 
+import java.util.Iterator;
+
 /**
  * @author tsveltin ?
  */
 public abstract class TreeDataView extends BaseComponent implements
-        ITreeRowSource
-{
-
+        ITreeRowSource {
     private TreeRowObject m_objTreeRowObject = null;
 
     private int m_nTreeDeep = -1;
@@ -52,8 +50,7 @@
     public void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
         // render data
-        Object objExistedTreeModelSource = cycle
-                .getAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE);
+        Object objExistedTreeModelSource = cycle.getAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE);
         cycle.setAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE, this);
 
         TreeView objView = getTreeView();
@@ -62,46 +59,45 @@
 
         Object objRoot = objTreeDataModel.getRoot();
         Object objRootUID = objTreeDataModel.getUniqueKey(objRoot, null);
-        if (getShowRootNode())
-        {
+        
+        if (getShowRootNode()) {
+
             walkTree(objRoot, objRootUID, 0, objTreeModel, writer, cycle,
-                    TreeRowObject.FIRST_LAST_ROW, new int[0], true);
-        }
-        else
-        {
+                     TreeRowObject.FIRST_LAST_ROW, new int[0], true);
+        } else {
+
             boolean bFirst = true;
-            int nChildenCount = objTreeModel.getTreeDataModel().getChildCount(
-                    objRoot);
-            int nRowPossiotionType = nChildenCount == 1 ? TreeRowObject.FIRST_LAST_ROW
-                    : TreeRowObject.FIRST_ROW;
-            for(Iterator iter = objTreeModel.getTreeDataModel().getChildren(
-                    objRoot); iter.hasNext();)
+
+            int nChildenCount = objTreeModel.getTreeDataModel().getChildCount(objRoot);
+            int nRowPossiotionType = nChildenCount == 1 ? TreeRowObject.FIRST_LAST_ROW :
TreeRowObject.FIRST_ROW;
+
+            for (Iterator iter = objTreeModel.getTreeDataModel().getChildren(objRoot); iter.hasNext();)
             {
                 Object objChild = iter.next();
-                Object objChildUID = objTreeModel.getTreeDataModel()
-                        .getUniqueKey(objChild, objRoot);
+                Object objChildUID = objTreeModel.getTreeDataModel().getUniqueKey(objChild,
objRoot);
+
                 boolean bChildLast = !iter.hasNext();
-                if (!bFirst)
-                {
+                if (!bFirst) {
+
                     if (bChildLast)
                         nRowPossiotionType = TreeRowObject.LAST_ROW;
-                    else nRowPossiotionType = TreeRowObject.MIDDLE_ROW;
+                    else
+                        nRowPossiotionType = TreeRowObject.MIDDLE_ROW;
                 }
 
                 walkTree(objChild, objChildUID, 0, objTreeModel, writer, cycle,
-                        nRowPossiotionType, new int[0], bChildLast);
+                         nRowPossiotionType, new int[0], bChildLast);
 
                 bFirst = false;
             }
         }
 
-        cycle.setAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE,
-                objExistedTreeModelSource);
+        cycle.setAttribute(ITreeRowSource.TREE_ROW_SOURCE_ATTRIBUTE, objExistedTreeModelSource);
     }
 
     public void walkTree(Object objParent, Object objParentUID, int nDepth,
-            ITreeModel objTreeModel, IMarkupWriter writer, IRequestCycle cycle,
-            int nRowPossiotionType, int[] arrConnectImages, boolean bLast)
+                         ITreeModel objTreeModel, IMarkupWriter writer, IRequestCycle cycle,
+                         int nRowPossiotionType, int[] arrConnectImages, boolean bLast)
     {
         int rowPositionType = nRowPossiotionType;
         m_nTreeDeep = nDepth;
@@ -109,24 +105,22 @@
                 objParent);
         boolean bLeaf = (nNumberOfChildren == 0) ? true : false;
         m_objTreeRowObject = new TreeRowObject(objParent, objParentUID, nDepth,
-                bLeaf, rowPositionType, arrConnectImages);
+                                               bLeaf, rowPositionType, arrConnectImages);
 
         super.renderComponent(writer, cycle);
 
         boolean bContain = objTreeModel.getTreeStateModel()
                 .isUniqueKeyExpanded(objParentUID);
-        if (bContain)
-        {
+        if (bContain) {
             int[] arrConnectImagesNew = new int[arrConnectImages.length + 1];
             System.arraycopy(arrConnectImages, 0, arrConnectImagesNew, 0,
-                    arrConnectImages.length);
+                             arrConnectImages.length);
             if (bLast)
                 arrConnectImagesNew[arrConnectImagesNew.length - 1] = TreeRowObject.EMPTY_CONN_IMG;
             else arrConnectImagesNew[arrConnectImagesNew.length - 1] = TreeRowObject.LINE_CONN_IMG;
 
-            for(Iterator iter = objTreeModel.getTreeDataModel().getChildren(
-                    objParent); iter.hasNext();)
-            {
+            for (Iterator iter = objTreeModel.getTreeDataModel().getChildren(
+                    objParent); iter.hasNext();) {
                 Object objChild = iter.next();
                 Object objChildUID = objTreeModel.getTreeDataModel()
                         .getUniqueKey(objChild, objParentUID);
@@ -135,8 +129,8 @@
                     rowPositionType = TreeRowObject.LAST_ROW;
                 else rowPositionType = TreeRowObject.MIDDLE_ROW;
                 walkTree(objChild, objChildUID, nDepth + 1, objTreeModel,
-                        writer, cycle, rowPositionType, arrConnectImagesNew,
-                        bChildLast);
+                         writer, cycle, rowPositionType, arrConnectImagesNew,
+                         bChildLast);
             }
         }
     }

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java?view=diff&rev=535694&r1=535693&r2=535694
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/tree/components/table/TreeTableDataView.java
Sun May  6 17:33:20 2007
@@ -14,10 +14,6 @@
 
 package org.apache.tapestry.contrib.tree.components.table;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.tapestry.BaseComponent;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRequestCycle;
@@ -28,14 +24,14 @@
 import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumnModel;
 import org.apache.tapestry.contrib.table.model.simple.SimpleTableModel;
 import org.apache.tapestry.contrib.table.model.simple.SimpleTableSessionStateManager;
-import org.apache.tapestry.contrib.tree.model.ITreeDataModel;
-import org.apache.tapestry.contrib.tree.model.ITreeModel;
-import org.apache.tapestry.contrib.tree.model.ITreeModelSource;
-import org.apache.tapestry.contrib.tree.model.ITreeRowSource;
-import org.apache.tapestry.contrib.tree.model.TreeRowObject;
+import org.apache.tapestry.contrib.tree.model.*;
 import org.apache.tapestry.event.PageDetachListener;
 import org.apache.tapestry.event.PageEvent;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  */
 public abstract class TreeTableDataView extends BaseComponent implements
@@ -94,6 +90,7 @@
 
             Object objRoot = objTreeDataModel.getRoot();
             Object objRootUID = objTreeDataModel.getUniqueKey(objRoot, null);
+            
             if (getShowRootNode())
             {
                 walkTree(arrAllExpandedNodes, objRoot, objRootUID, 0,

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ListenerMethodBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ListenerMethodBinding.java?view=diff&rev=535694&r1=535693&r2=535694
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ListenerMethodBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ListenerMethodBinding.java
Sun May  6 17:33:20 2007
@@ -84,8 +84,12 @@
         {
             throw ex;
         }
-        catch (RuntimeException ex)
+        catch (RenderRewoundException ex)
         {
+            throw ex;
+        }
+        catch (RuntimeException ex)
+        {   
             throw new BindingException(BindingMessages.listenerMethodFailure(
                     _component,
                     _methodName,

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=535694&r1=535693&r2=535694
==============================================================================
--- 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
Sun May  6 17:33:20 2007
@@ -14,30 +14,11 @@
 
 package org.apache.tapestry.form;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.Location;
 import org.apache.hivemind.util.Defense;
-import org.apache.tapestry.IComponent;
-import org.apache.tapestry.IForm;
-import org.apache.tapestry.IMarkupWriter;
-import org.apache.tapestry.IRender;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.NestedMarkupWriter;
-import org.apache.tapestry.PageRenderSupport;
-import org.apache.tapestry.StaleLinkException;
-import org.apache.tapestry.Tapestry;
-import org.apache.tapestry.TapestryUtils;
+import org.apache.tapestry.*;
 import org.apache.tapestry.engine.ILink;
 import org.apache.tapestry.event.BrowserEvent;
 import org.apache.tapestry.json.JSONObject;
@@ -46,11 +27,11 @@
 import org.apache.tapestry.util.IdAllocator;
 import org.apache.tapestry.valid.IValidationDelegate;
 
+import java.util.*;
+
 /**
  * Encapsulates most of the behavior of a Form component.
  * 
- * @author Howard M. Lewis Ship
- * @since 4.0
  */
 public class FormSupportImpl implements FormSupport
 {
@@ -159,8 +140,14 @@
 
     private final PageRenderSupport _pageRenderSupport;
 
+    /**
+     * Client side validation is built up using a json object syntax structure
+     */
     private final JSONObject _profile;
     
+    /**
+     * Used to detect whether or not a form component has been updated and will require form
sync on ajax requests
+     */
     private boolean _fieldUpdating;
     
     public FormSupportImpl(IMarkupWriter writer, IRequestCycle cycle, IForm form)
@@ -185,6 +172,7 @@
      * Alternate constructor used for testing only.
      * 
      * @param cycle
+     *          The current cycle.
      */
     FormSupportImpl(IRequestCycle cycle)
     {
@@ -554,16 +542,16 @@
         // then do nothing.
         
         if (!_cycle.isFocusDisabled() && fieldId != null && _form.getFocus()

-                && _cycle.getAttribute(FIELD_FOCUS_ATTRIBUTE) == null) {
-            
+                && _cycle.getAttribute(FIELD_FOCUS_ATTRIBUTE) == null)
+        {
             _pageRenderSupport.addInitializationScript(_form, "dojo.require(\"tapestry.form\");tapestry.form.focusField('"
+ fieldId + "');");
             _cycle.setAttribute(FIELD_FOCUS_ATTRIBUTE, Boolean.TRUE);
         }
         
         // register the validation profile with client side form manager
         
-        if (_form.isClientValidationEnabled()) {
-            
+        if (_form.isClientValidationEnabled())
+        {    
             _pageRenderSupport.addInitializationScript(_form, "dojo.require(\"tapestry.form\");tapestry.form.clearProfiles('"
                     + formId + "'); tapestry.form.registerProfile('" + formId + "'," 
                     + _profile.toString() + ");");
@@ -573,6 +561,9 @@
     /**
      * Pre-renders the form, setting up some client-side form support. Returns the name of
the
      * client-side form event manager variable.
+     *
+     * @param formId
+     *          The client id of the form.
      */
     protected void emitEventManagerInitialization(String formId)
     {
@@ -631,7 +622,6 @@
             throw new StaleLinkException(FormMessages.formTooFewIds(_form, expected
                     - _allocatedIdIndex, nextExpectedId), _form);
         }
-
         
         runDeferredRunnables();
         
@@ -642,7 +632,6 @@
         // javascript enabled.
         
         return FormConstants.SUBMIT_NORMAL;
-
     }
 
     private void runDeferredRunnables()
@@ -651,7 +640,7 @@
         while (i.hasNext())
         {
             Runnable r = (Runnable) i.next();
-
+            
             r.run();
         }
     }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestListenerMethodBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestListenerMethodBinding.java?view=diff&rev=535694&r1=535693&r2=535694
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestListenerMethodBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestListenerMethodBinding.java
Sun May  6 17:33:20 2007
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.binding;
 
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.Location;
 import org.apache.tapestry.*;
 import org.apache.tapestry.coerce.ValueConverter;
@@ -141,6 +142,33 @@
         {
             assertSame(t, ex);
         }
+
+        verify();
+    }
+
+    @Test(expectedExceptions = RenderRewoundException.class)
+    public void test_Invoke_Render_Rewound()
+    {        
+        IComponent component = newMock(IComponent.class);
+        ListenerMap map = newListenerMap();
+        IActionListener listener = newMock(IActionListener.class);
+        ValueConverter vc = newMock(ValueConverter.class);
+        IComponent sourceComponent = newMock(IComponent.class);
+        Location l = newMock(Location.class);
+        IRequestCycle cycle = newMock(IRequestCycle.class);
+
+        trainGetListener(component, map, listener);
+
+        listener.actionTriggered(sourceComponent, cycle);
+
+        ApplicationRuntimeException t = new RenderRewoundException(null);
+        expectLastCall().andThrow(t);
+
+        replay();
+
+        ListenerMethodBinding b = new ListenerMethodBinding("param", vc, l, component, "foo");
+
+        b.actionTriggered(sourceComponent, cycle);
 
         verify();
     }



Mime
View raw message