You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/03/03 20:32:11 UTC
svn commit: r1076746 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/corelib/components/
main/resources/org/apache/tapestry5/corelib/components/ test/app1/
Author: hlship
Date: Thu Mar 3 19:32:11 2011
New Revision: 1076746
URL: http://svn.apache.org/viewvc?rev=1076746&view=rev
Log:
TAP5-1461: Remove Loop.volatile parameter (replaced with formState parameter in 5.1)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanDisplay.tml
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditor.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ToDoListVolatile.tml
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java?rev=1076746&r1=1076745&r2=1076746&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java Thu Mar 3 19:32:11 2011
@@ -4,7 +4,7 @@
// 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
+// 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,
@@ -14,8 +14,23 @@
package org.apache.tapestry5.corelib.components;
-import org.apache.tapestry5.*;
-import org.apache.tapestry5.annotations.*;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.ComponentAction;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.EventConstants;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.ValueEncoder;
+import org.apache.tapestry5.annotations.AfterRender;
+import org.apache.tapestry5.annotations.BeginRender;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.Events;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.SetupRender;
+import org.apache.tapestry5.annotations.SupportsInformalParameters;
import org.apache.tapestry5.corelib.LoopFormState;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
@@ -23,10 +38,6 @@ import org.apache.tapestry5.services.Com
import org.apache.tapestry5.services.FormSupport;
import org.apache.tapestry5.services.Heartbeat;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.List;
-
/**
* Basic looping class; loops over a number of items (provided by its source parameter), rendering its body for each
* one. It turns out that gettting the component to <em>not</em> store its state in the Form is very tricky and, in
@@ -36,8 +47,9 @@ import java.util.List;
* an encoder). For a Loop that doesn't need to be aware of the enclosing Form (if any), the formState parameter should
* be bound to 'none'.
* <p/>
- * When the Loop is used inside a Form, it will generate an {@link org.apache.tapestry5.EventConstants#SYNCHRONIZE_VALUES}
- * event to inform its container what values were submitted and in what order.
+ * When the Loop is used inside a Form, it will generate an
+ * {@link org.apache.tapestry5.EventConstants#SYNCHRONIZE_VALUES} event to inform its container what values were
+ * submitted and in what order.
*/
@SupportsInformalParameters
@Events(EventConstants.SYNCHRONIZE_VALUES)
@@ -220,24 +232,12 @@ public class Loop<T>
private ValueEncoder<T> encoder;
/**
- * If true and the Loop is enclosed by a Form, then the normal state saving logic is turned off. Defaults to false,
- * enabling state saving logic within Forms. With the addition of the formState parameter, volatile simply sets a
- * default for formState is formState is not specified.
- *
- * @deprecated in release 5.1.0.4, use the formState parameter instead.
- */
- @Parameter(name = "volatile", principal = true)
- @Deprecated
- private boolean volatileState;
-
- /**
- * Controls what information, if any, is encoded into an enclosing Form. The default value for this is set by the
- * deprecated volatile parameter. The normal default is {@link org.apache.tapestry5.corelib.LoopFormState#VALUES},
- * but changes to {@link org.apache.tapestry5.corelib.LoopFormState#ITERATION} if volatile is true. This parameter
+ * Controls what information, if any, is encoded into an enclosing Form. The default value
+ * is {@link org.apache.tapestry5.corelib.LoopFormState#VALUES}. This parameter
* is only used if the component is enclosed by a Form.
*/
@Parameter(allowNull = false, defaultPrefix = BindingConstants.LITERAL)
- private LoopFormState formState;
+ private LoopFormState formState = LoopFormState.VALUES;
@Environmental(false)
private FormSupport formSupport;
@@ -262,7 +262,7 @@ public class Loop<T>
private int index;
/**
- * A Block to render instead of the loop when the source is empty. The default is to render nothing.
+ * A Block to render instead of the loop when the source is empty. The default is to render nothing.
*/
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private Block empty;
@@ -288,10 +288,9 @@ public class Loop<T>
*/
private List<T> synchonizedValues;
-
LoopFormState defaultFormState()
{
- return volatileState ? LoopFormState.ITERATION : LoopFormState.VALUES;
+ return LoopFormState.VALUES;
}
String defaultElement()
@@ -313,7 +312,6 @@ public class Loop<T>
boolean insideForm = formSupport != null;
-
storeValuesInForm = insideForm && formState == LoopFormState.VALUES;
storeIncrementsInForm = insideForm && formState == LoopFormState.ITERATION;
@@ -328,8 +326,10 @@ public class Loop<T>
if (insideForm && hasContent)
{
- if (storeValuesInForm) formSupport.store(this, RESET_INDEX);
- if (storeIncrementsInForm) formSupport.store(this, SETUP_FOR_VOLATILE);
+ if (storeValuesInForm)
+ formSupport.store(this, RESET_INDEX);
+ if (storeIncrementsInForm)
+ formSupport.store(this, SETUP_FOR_VOLATILE);
}
cleanupBlock = hasContent ? null : empty;
@@ -339,7 +339,6 @@ public class Loop<T>
return hasContent;
}
-
/**
* Returns the empty block, or null, after the render has finished. It will only be the empty block (which itself
* may be null) if the source was null or empty.
@@ -412,7 +411,8 @@ public class Loop<T>
@AfterRender
boolean after(MarkupWriter writer)
{
- if (element != null) writer.end();
+ if (element != null)
+ writer.end();
endHeartbeat();
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanDisplay.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanDisplay.tml?rev=1076746&r1=1076745&r2=1076746&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanDisplay.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanDisplay.tml Thu Mar 3 19:32:11 2011
@@ -1,7 +1,7 @@
<dl class="t-beandisplay" xml:space="default"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
- <t:loop t:source="model.propertyNames" t:volatile="true" t:value="propertyName">
+ <t:loop t:source="model.propertyNames" formState="ITERATION" t:value="propertyName">
<dt class="${propertyClass}">${propertyModel.label}</dt>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditor.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditor.tml?rev=1076746&r1=1076745&r2=1076746&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditor.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/BeanEditor.tml Thu Mar 3 19:32:11 2011
@@ -1,6 +1,4 @@
-<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default"
- class="t-beaneditor-row" t:type="loop" t:source="model.propertyNames"
- t:volatile="true" t:value="propertyName">
- <t:propertyEditor property="propertyName" object="object"
- model="model" overrides="overrides"/>
+<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default" class="t-beaneditor-row"
+ t:type="loop" t:source="model.propertyNames" t:formState="ITERATION" t:value="propertyName">
+ <t:propertyEditor property="propertyName" object="object" model="model" overrides="overrides"/>
</div>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ToDoListVolatile.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ToDoListVolatile.tml?rev=1076746&r1=1076745&r2=1076746&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ToDoListVolatile.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ToDoListVolatile.tml Thu Mar 3 19:32:11 2011
@@ -1,36 +1,35 @@
<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
- <h1>ToDo List</h1>
+ <h1>ToDo List</h1>
- <form t:id="form">
+ <form t:id="form">
- <t:errors/>
+ <t:errors/>
- <table class="t-data-table">
- <tr>
- <th> Title </th>
- <th> Reorder </th>
- </tr>
- <tr t:type="Loop" source="items" value="item" volatile="true">
- <td>
- <input t:type="TextField" t:id="title" value="item.title" size="30"
- validate="required"/>
- </td>
- <td> NOT YET </td>
- </tr>
- <tr>
- <td colspan="2">
- <input type="submit" value="Update ToDos"/>
- <input t:type="Submit" t:id="addNew" value="Add new ToDo"/>
- </td>
- </tr>
-
- </table>
- </form>
-
-
- <p>
- <a t:type="ActionLink" t:id="reset">reset the database</a>
- </p>
+ <table class="t-data-table">
+ <tr>
+ <th> Title </th>
+ <th> Reorder </th>
+ </tr>
+ <tr t:type="Loop" source="items" value="item" formState="ITERATION">
+ <td>
+ <input t:type="TextField" t:id="title" value="item.title" size="30" validate="required"/>
+ </td>
+ <td> NOT YET </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="submit" value="Update ToDos"/>
+ <input t:type="Submit" t:id="addNew" value="Add new ToDo"/>
+ </td>
+ </tr>
+
+ </table>
+ </form>
+
+
+ <p>
+ <a t:type="ActionLink" t:id="reset">reset the database</a>
+ </p>
</html>
\ No newline at end of file