tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r618438 - in /tapestry/tapestry4/trunk: tapestry-examples/Workbench/src/context/WEB-INF/ tapestry-framework/src/java/org/apache/tapestry/form/ tapestry-framework/src/scripts/ tapestry-framework/src/test/org/apache/tapestry/form/ tapestry-fr...
Date Mon, 04 Feb 2008 21:08:58 GMT
Author: jkuhnert
Date: Mon Feb  4 13:08:56 2008
New Revision: 618438

URL: http://svn.apache.org/viewvc?rev=618438&view=rev
Log:
Fixes TAPESTRY-2120.  Radio component needed to override setName(IForm form) to prevent id
allocation of individual radio elements as the naming is still supposed to be managed by the
containing RadioGroup.

Modified:
    tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/web.xml
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Radio.java
    tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestRadio.xml
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestRadio.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/TestMockApplications.java

Modified: tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/web.xml?rev=618438&r1=618437&r2=618438&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/web.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/web.xml Mon Feb
 4 13:08:56 2008
@@ -71,6 +71,11 @@
         <url-pattern>/assets/*</url-pattern>
     </servlet-mapping>
 
+    <servlet-mapping>
+        <servlet-name>workbench</servlet-name>
+        <url-pattern>*.html</url-pattern>
+    </servlet-mapping>
+
     <session-config>
         <session-timeout>15</session-timeout>
     </session-config>

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Radio.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Radio.java?rev=618438&r1=618437&r2=618438&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Radio.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/form/Radio.java
Mon Feb  4 13:08:56 2008
@@ -15,6 +15,7 @@
 package org.apache.tapestry.form;
 
 import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.tapestry.IForm;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.Tapestry;
@@ -26,13 +27,13 @@
  *
  *  [<a href="../../../../../ComponentReference/Radio.html">Component Reference</a>]
  *
- * 
+ *
  *  <p>{@link Radio} and {@link RadioGroup} are generally not used (except
  *  for very special cases).  Instead, a {@link PropertySelection} component is used.
  *
  *
  *  @author Howard Lewis Ship
- * 
+ *
  **/
 
 public abstract class Radio extends AbstractFormComponent
@@ -46,30 +47,30 @@
 
     protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
     {
-	    RadioGroup group = RadioGroup.get(cycle);
+        RadioGroup group = RadioGroup.get(cycle);
+
+        if (group == null)
+            throw new ApplicationRuntimeException(Tapestry.getMessage("Radio.must-be-contained-by-group"),
+                                                  this,
+                                                  null,
+                                                  null);
+
+        int option = group.getNextOptionId();
 
-	    if (group == null)
-            throw new ApplicationRuntimeException(
-                Tapestry.getMessage("Radio.must-be-contained-by-group"),
-                this,
-                null,
-                null);
-	    
-	    int option = group.getNextOptionId();
-        
         setClientId(group.getName()+option);
-        
+        setName(group.getName());
+
         writer.beginEmpty("input");
-        
+
         writer.attribute("type", "radio");
-        
-        writer.attribute("name", group.getName());
-        
+
+        writer.attribute("name", getName());
+
         renderIdAttribute(writer, cycle);
-        
+
         // As the group if the value for this Radio matches the selection
         // for the group as a whole; if so this is the default radio and is checked.
-        
+
         if (group.isSelection(getValue()))
             writer.attribute("checked", "checked");
 
@@ -84,31 +85,39 @@
 
         renderInformalParameters(writer, cycle);
 
-	    writer.closeTag();
+        writer.closeTag();
     }
 
-	protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
-	{
-		RadioGroup group = RadioGroup.get(cycle);
+    protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
+    {
+        RadioGroup group = RadioGroup.get(cycle);
 
         if (group == null)
             throw new ApplicationRuntimeException(
-                Tapestry.getMessage("Radio.must-be-contained-by-group"),
-                this,
-                null,
-                null);
+                    Tapestry.getMessage("Radio.must-be-contained-by-group"),
+                    this,
+                    null,
+                    null);
 
         int option = group.getNextOptionId();
 
-		// If not disabled and this is the selected button within the radio group,
-		// then update set the selection from the group to the value for this
-		// radio button.  This will update the selected parameter of the RadioGroup.
-
-		if (!isDisabled() && !group.isDisabled() && group.isSelected(option))
-			group.updateSelection(getValue());
-	}
+        // If not disabled and this is the selected button within the radio group,
+        // then update set the selection from the group to the value for this
+        // radio button.  This will update the selected parameter of the RadioGroup.
+
+        if (!isDisabled() && !group.isDisabled() && group.isSelected(option))
+            group.updateSelection(getValue());
+    }
+
+    /**
+     * Overridden to do nothing so that special {@link RadioGroup} semantics are handled
properly.
+     * @param form The form to set the name on.
+     */
+    protected void setName(IForm form)
+    {
+    }
 
-	public abstract boolean isDisabled();
+    public abstract boolean isDisabled();
 
     public abstract Object getValue();
 }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestRadio.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestRadio.xml?rev=618438&r1=618437&r2=618438&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestRadio.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/scripts/TestRadio.xml Mon Feb  4 13:08:56
2008
@@ -52,7 +52,7 @@
         <parameter name="page" value="Home" />
         <parameter name="component" value="$Form" />
         <parameter name="RadioGroup" value="2" />
-        <parameter name="formids" value="RadioGroup,Radio,Radio_0,Radio_1,Radio_2" />
+        <parameter name="formids" value="RadioGroup" />
 
         <assert-output name="Page Title">
             <![CDATA[
@@ -83,7 +83,7 @@
         <parameter name="service" value="direct" />
         <parameter name="page" value="Home" />
         <parameter name="component" value="$Form" />
-        <parameter name="formids" value="RadioGroup,Radio,Radio_0,Radio_1,Radio_2" />
+        <parameter name="formids" value="RadioGroup" />
 
         <assert-output name="Page Title">
             <![CDATA[
@@ -115,7 +115,7 @@
         <parameter name="page" value="Home" />
         <parameter name="component" value="$Form" />
         <parameter name="RadioGroup" value="3" />
-        <parameter name="formids" value="RadioGroup,Radio,Radio_0,Radio_1,Radio_2" />
+        <parameter name="formids" value="RadioGroup" />
 
         <assert-output name="Page Title">
             <![CDATA[
@@ -318,7 +318,7 @@
         <parameter name="session" value="T" />
         <parameter name="page" value="NullSelection" />
         <parameter name="component" value="$Form" />
-        <parameter name="formids" value="group,r0,r1,r2,r3" />
+        <parameter name="formids" value="group" />
         
         <parameter name="group" value="1" />
 
@@ -349,7 +349,7 @@
         <parameter name="session" value="T" />
         <parameter name="page" value="NullSelection" />
         <parameter name="component" value="$Form" />
-        <parameter name="formids" value="group,r0,r1,r2,r3" />
+        <parameter name="formids" value="group" />
 
         <assert-output name="No Choice">
             <![CDATA[<input type="radio" name="group" id="group0" checked="checked"
value="0" /> No Choice]]>
@@ -399,7 +399,7 @@
         <parameter name="session" value="T" />
         <parameter name="page" value="LanguageSelection" />
         <parameter name="component" value="form" />
-        <parameter name="formids" value="group,Radio,Radio_0,Radio_1" />
+        <parameter name="formids" value="group" />
         <parameter name="group" value="2" />
 
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestRadio.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestRadio.java?rev=618438&r1=618437&r2=618438&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestRadio.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/TestRadio.java
Mon Feb  4 13:08:56 2008
@@ -17,7 +17,7 @@
 	private IMarkupWriter writer;
 	private IRequestCycle cycle;
 
-	public void testRenderSelected()
+	public void test_Render_Selected()
 	{
 		setupComponent(0, false);
 
@@ -30,7 +30,7 @@
 		assertBuffer("<input type=\"radio\" name=\"group\" id=\"group0\" checked=\"checked\"
value=\"0\" />");
 	}
 
-	public void testRenderUnselected()
+	public void test_Render_Unselected()
 	{
 		setupComponent(1, false);
 
@@ -43,7 +43,7 @@
 		assertBuffer("<input type=\"radio\" name=\"group\" id=\"group0\" value=\"0\" />");
 	}
 
-	public void testRewindSelected()
+	public void test_Rewind_Selected()
 	{
 		setupComponent(0, true);
 
@@ -59,7 +59,7 @@
 		verify();
 	}
 
-	public void testRewindUnselected()
+	public void test_Rewind_Unselected()
 	{
 		setupComponent(1, true);
 
@@ -87,14 +87,13 @@
 		MockDelegate delegate = new MockDelegate();
 
 		expect(cycle.getAttribute(RadioGroup.ATTRIBUTE_NAME)).andReturn(group);
-
 		expect(cycle.renderStackPush(radio)).andReturn(radio);
 
 		trainGetForm(cycle, form);
 		trainWasPrerendered(form, writer, radio, false);
 		trainGetDelegate(form, delegate);
 
-		trainGetElementId(form, radio, "id");
+		//trainGetElementId(form, radio, "id");
 		trainIsRewinding(form, rewinding);
 		if (!rewinding)
 		{

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/TestMockApplications.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/TestMockApplications.java?rev=618438&r1=618437&r2=618438&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/TestMockApplications.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/TestMockApplications.java
Mon Feb  4 13:08:56 2008
@@ -159,7 +159,7 @@
     /**
      * Invoked to execute the request cycle.
      */
-    @Test(dataProvider = "mockTestScripts", enabled = false)
+    @Test(dataProvider = "mockTestScripts", enabled = true)
     public void execute(String testRootDirectory, String path, String fileName)
       throws Exception
     {



Mime
View raw message