tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r307306 - in /jakarta/tapestry/trunk: ./ contrib/src/java/org/apache/tapestry/contrib/palette/ examples/Workbench/src/context/ examples/Workbench/src/context/WEB-INF/ examples/Workbench/src/java/org/apache/tapestry/workbench/palette/ framew...
Date Sat, 08 Oct 2005 15:59:38 GMT
Author: hlship
Date: Sat Oct  8 08:59:15 2005
New Revision: 307306

URL: http://svn.apache.org/viewcvs?rev=307306&view=rev
Log:
TAPESTRY-696: Race condition during page loading can cause anomoylous exceptions related to annotations
TAPESTRY-685: Asset service sends a 200 response even when the provided md5 checksum is invalid
TAPESTRY-564: Automatically create an IPropertySelection model from a string

Added:
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringConvertedPropertySelectionModel.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToPropertySelectionModelConverter.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/coerce/StringToPropertySelectionModelConverterTest.java
Modified:
    jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java
    jakarta/tapestry/trunk/examples/Workbench/src/context/Palette.html
    jakarta/tapestry/trunk/examples/Workbench/src/context/WEB-INF/Palette.page
    jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/palette/Palette.java
    jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.coerce.xml
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/AssetService.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToIteratorConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToIteratorConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToBooleanConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToIteratorConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToIteratorConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IteratorToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/MapToBooleanConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToBooleanConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToIteratorConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NumberToBooleanConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectArrayToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToBooleanConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToIteratorConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToListConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToStringConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToBooleanConverter.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterContribution.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterWrapper.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java
    jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java
    jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java
    jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java
    jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
    jakarta/tapestry/trunk/status.xml

Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/palette/Palette.java Sat Oct  8 08:59:15 2005
@@ -156,49 +156,49 @@
  * use to format the palette component:
  * 
  * <pre>
- *     
  *      
  *       
  *        
  *         
  *          
  *           
- *                            TABLE.tapestry-palette TH
- *                            {
- *                              font-size: 9pt;
- *                              font-weight: bold;
- *                              color: white;
- *                              background-color: #330066;
- *                              text-align: center;
- *                            }
- *                           
- *                            TD.available-cell SELECT
- *                            {
- *                              font-weight: normal;
- *                              background-color: #FFFFFF;
- *                              width: 200px;
- *                            }
- *                            
- *                            TD.selected-cell SELECT
- *                            {
- *                              font-weight: normal;
- *                              background-color: #FFFFFF;
- *                              width: 200px;
- *                            }
+ *            
+ *                             TABLE.tapestry-palette TH
+ *                             {
+ *                               font-size: 9pt;
+ *                               font-weight: bold;
+ *                               color: white;
+ *                               background-color: #330066;
+ *                               text-align: center;
+ *                             }
  *                            
- *                            TABLE.tapestry-palette TD.controls
- *                            {
- *                              text-align: center;
- *                              vertical-align: middle;
- *                              width: 60px;
- *                            }
+ *                             TD.available-cell SELECT
+ *                             {
+ *                               font-weight: normal;
+ *                               background-color: #FFFFFF;
+ *                               width: 200px;
+ *                             }
+ *                             
+ *                             TD.selected-cell SELECT
+ *                             {
+ *                               font-weight: normal;
+ *                               background-color: #FFFFFF;
+ *                               width: 200px;
+ *                             }
+ *                             
+ *                             TABLE.tapestry-palette TD.controls
+ *                             {
+ *                               text-align: center;
+ *                               vertical-align: middle;
+ *                               width: 60px;
+ *                             }
+ *             
  *            
  *           
  *          
  *         
  *        
  *       
- *      
  * </pre>
  * 
  * <p>
@@ -459,7 +459,7 @@
 
     public boolean isSortUser()
     {
-        return getSort() == SortMode.USER;
+        return getSort().equals(SortMode.USER);
     }
 
     public abstract Block getAvailableTitleBlock();

Modified: jakarta/tapestry/trunk/examples/Workbench/src/context/Palette.html
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Workbench/src/context/Palette.html?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Workbench/src/context/Palette.html (original)
+++ jakarta/tapestry/trunk/examples/Workbench/src/context/Palette.html Sat Oct  8 08:59:15 2005
@@ -12,7 +12,7 @@
 
 <span jwcid="@ShowError" delegate="bean:delegate"/>
 
-<form jwcid="form@Form" delegate="bean:delegate" clientValidationEnabled="ognl:clientValidationEnabled">
+<form jwcid="form">
 
 <table class="form">
 	<tr>

Modified: jakarta/tapestry/trunk/examples/Workbench/src/context/WEB-INF/Palette.page
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Workbench/src/context/WEB-INF/Palette.page?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Workbench/src/context/WEB-INF/Palette.page (original)
+++ jakarta/tapestry/trunk/examples/Workbench/src/context/WEB-INF/Palette.page Sat Oct  8 08:59:15 2005
@@ -22,10 +22,16 @@
 <page-specification class="org.apache.tapestry.workbench.palette.Palette">
   
   <property name="clientValidationEnabled" persist="client" initial-value="true"/>
-  <property name="sort" persist="client" initial-value="@org.apache.tapestry.contrib.palette.SortMode@USER"/>
-
+ 
   <bean name="delegate" class="org.apache.tapestry.workbench.WorkbenchValidationDelegate" property="delegate"/>
   
+  <component id="form" type="Form">
+    <binding name="delegate" value="bean:delegate"/>
+    <binding name="clientValidationEnabled" value="clientValidationEnabled"/>
+    <binding name="refresh" value="listener:doRefresh"/>
+    <binding name="success" value="listener:doAdvance"/>    
+  </component>
+  
   <component id="inputEnabled" type="Checkbox">
     <binding name="value" value="clientValidationEnabled"/> 
     <binding name="onchange" value="literal:javascript:this.form.events.submit();"/>
@@ -33,7 +39,10 @@
 
   <component id="inputColorSort" type="PropertySelection">
   	<binding name="value" value="sort"/>
-  	<binding name="model" value="sortModel"/>
+  	<binding name="model" value="literal:None=NONE,Label=LABEL,Value=VALUE,Manual=USER"/>
+    <binding name="onchange">
+      literal:javascript:this.form.events.refresh();
+    </binding>
   </component>
   
   <component id="inputColor" type="contrib:Palette">
@@ -51,7 +60,6 @@
   
   <component id="continue" type="ImageSubmit">
   	<binding name="image" value="asset:continue"/>
-  	<binding name="listener" value="listener:advance"/>
   </component>
  
   <asset name="continue" path="images/Continue.gif"/>

Modified: jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/palette/Palette.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/palette/Palette.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/palette/Palette.java (original)
+++ jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/palette/Palette.java Sat Oct  8 08:59:15 2005
@@ -17,7 +17,9 @@
 import java.util.List;
 
 import org.apache.tapestry.IPage;
+import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.annotations.InjectPage;
+import org.apache.tapestry.annotations.Persist;
 import org.apache.tapestry.contrib.palette.SortMode;
 import org.apache.tapestry.form.IPropertySelectionModel;
 import org.apache.tapestry.form.StringPropertySelectionModel;
@@ -32,23 +34,28 @@
 {
     public abstract List getSelectedColors();
 
+    @Persist("client:app")
     public abstract String getSort();
 
-    public abstract IValidationDelegate getDelegate();
-    
-    private IPropertySelectionModel _sortModel;
+    public abstract void setSort(String sort);
 
-    /**
-     * Invoked before {@link #formSubmit(IRequestCycle)} if the user clicks the "advance" button.
-     */
+    public abstract IValidationDelegate getDelegate();
 
     @InjectPage("PaletteResults")
     public abstract PaletteResults getResultsPage();
 
-    public IPage advance()
+    protected void finishLoad()
+    {
+        setSort(SortMode.USER);
+    }
+
+    public void doRefresh()
+    {
+        getDelegate().clearErrors();
+    }
+
+    public IPage doAdvance()
     {
-        if (getDelegate().getHasErrors()) return null;
-        
         // Since Palette and palette.Results come from
         // a library now, we need to make sure
         // the namespace id is part of the name.
@@ -71,18 +78,5 @@
             colorModel = new StringPropertySelectionModel(colors);
 
         return colorModel;
-    }
-
-    public IPropertySelectionModel getSortModel()
-    {
-        if (_sortModel == null)
-        {
-            String[] options = new String[]
-            { SortMode.NONE, SortMode.LABEL, SortMode.VALUE, SortMode.USER };
-
-            _sortModel = new StringPropertySelectionModel(options);
-        }
-
-        return _sortModel;
     }
 }

Modified: jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.coerce.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.coerce.xml?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.coerce.xml (original)
+++ jakarta/tapestry/trunk/framework/src/descriptor/META-INF/tapestry.coerce.xml Sat Oct  8 08:59:15 2005
@@ -112,12 +112,27 @@
     
   </configuration-point>
   
+  <configuration-point id="PropertySelectionModelConverters" schema-id="Converters"/>
+  
+  <contribution configuration-id="PropertySelectionModelConverters">
+    <converter class="java.lang.String" object="instance:StringToPropertySelectionModelConverter"/>
+  </contribution>
+    
+  <service-point id="PropertySelectionModelConverter" interface="TypeConverter">
+    <invoke-factory>
+      <construct class="TypeConverterWrapper">
+        <set-configuration property="contributions" configuration-id="PropertySelectionModelConverters"/>
+      </construct>
+    </invoke-factory>   
+  </service-point>
+    
   <contribution configuration-id="TypeConverters">
     <converter class="java.lang.Boolean" object="service:BooleanConverter"/>
     <converter class="java.util.Iterator" object="service:IteratorConverter"/>
     <converter class="java.util.List" object="service:ListConverter"/>
     <converter class="java.lang.String" object="instance:ObjectToStringConverter"/>
-  </contribution>
+    <converter class="org.apache.tapestry.form.IPropertySelectionModel" object="service:PropertySelectionModelConverter"/>
+  </contribution>  
   
   <service-point id="ValueConverter" interface="ValueConverter">
     

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/AssetService.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/AssetService.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/AssetService.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/asset/AssetService.java Sat Oct  8 08:59:15 2005
@@ -185,28 +185,30 @@
     /**
      * Retrieves a resource from the classpath and returns it to the client in a binary output
      * stream.
-     * <p>
-     * TBD: Security issues. Hackers can download .class files.
      */
 
     public void service(IRequestCycle cycle) throws IOException
     {
-        // If they were vended an asset in the past then it must be up-to date.
-        // Asset URIs change if the underlying file is modified.
-
-        if (_request.getHeader("If-Modified-Since") != null)
-        {
-            _response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
-            return;
-        }
-
         String path = cycle.getParameter(PATH);
-        String md5 = cycle.getParameter(DIGEST);
+        String md5Digest = cycle.getParameter(DIGEST);
 
         try
         {
-            if (!_digestSource.getDigestForResource(path).equals(md5))
-                throw new ApplicationRuntimeException(AssetMessages.md5Mismatch(path));
+            if (!_digestSource.getDigestForResource(path).equals(md5Digest))
+            {
+                _response.sendError(HttpServletResponse.SC_FORBIDDEN, AssetMessages
+                        .md5Mismatch(path));
+                return;
+            }
+
+            // If they were vended an asset in the past then it must be up-to date.
+            // Asset URIs change if the underlying file is modified.
+
+            if (_request.getHeader("If-Modified-Since") != null)
+            {
+                _response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+                return;
+            }
 
             URL resourceURL = _classResolver.getResource(path);
 

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToIteratorConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToIteratorConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToIteratorConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToIteratorConverter.java Sat Oct  8 08:59:15 2005
@@ -23,7 +23,7 @@
  * @author Laurent ETIEMBLE, Howard M. Lewis Ship
  * @since 4.0
  */
-public class BooleanArrayToIteratorConverter implements TypeConverter
+public final class BooleanArrayToIteratorConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToListConverter.java Sat Oct  8 08:59:15 2005
@@ -23,7 +23,7 @@
  * @author Laurent ETIEMBLE, Howard M. Lewis Ship
  * @since 4.0
  */
-public class BooleanArrayToListConverter implements TypeConverter
+public final class BooleanArrayToListConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToIteratorConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToIteratorConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToIteratorConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToIteratorConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Laurent ETIEMBLE, Howard M. Lewis Ship
  * @since 4.0
  */
-public class CharArrayToIteratorConverter implements TypeConverter
+public final class CharArrayToIteratorConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CharArrayToListConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Laurent ETIEMBLE, Howard M. Lewis Ship
  * @since 4.0
  */
-public class CharArrayToListConverter implements TypeConverter
+public final class CharArrayToListConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToBooleanConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToBooleanConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToBooleanConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToBooleanConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * 
  * @author Howard M. Lewis Ship
  */
-public class CollectionToBooleanConverter implements TypeConverter
+public final class CollectionToBooleanConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToIteratorConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToIteratorConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToIteratorConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToIteratorConverter.java Sat Oct  8 08:59:15 2005
@@ -20,7 +20,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class CollectionToIteratorConverter implements TypeConverter
+public final class CollectionToIteratorConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/CollectionToListConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class CollectionToListConverter implements TypeConverter
+public final class CollectionToListConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToIteratorConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToIteratorConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToIteratorConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToIteratorConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Laurent ETIEMBLE, Howard M. Lewis Ship
  * @since 4.0
  */
-public class IntArrayToIteratorConverter implements TypeConverter
+public final class IntArrayToIteratorConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IntArrayToListConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Laurent ETIEMBLE, Howard M. Lewis Ship
  * @since 4.0
  */
-public class IntArrayToListConverter implements TypeConverter
+public final class IntArrayToListConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IteratorToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IteratorToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IteratorToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/IteratorToListConverter.java Sat Oct  8 08:59:15 2005
@@ -22,7 +22,7 @@
  * @author Mindbridge
  * @since 4.0
  */
-public class IteratorToListConverter implements TypeConverter
+public final class IteratorToListConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/MapToBooleanConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/MapToBooleanConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/MapToBooleanConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/MapToBooleanConverter.java Sat Oct  8 08:59:15 2005
@@ -22,7 +22,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class MapToBooleanConverter implements TypeConverter
+public final class MapToBooleanConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToBooleanConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToBooleanConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToBooleanConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToBooleanConverter.java Sat Oct  8 08:59:15 2005
@@ -20,7 +20,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class NullToBooleanConverter implements TypeConverter
+public  final class NullToBooleanConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToIteratorConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToIteratorConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToIteratorConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToIteratorConverter.java Sat Oct  8 08:59:15 2005
@@ -20,7 +20,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class NullToIteratorConverter implements TypeConverter
+public final class NullToIteratorConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NullToListConverter.java Sat Oct  8 08:59:15 2005
@@ -20,7 +20,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class NullToListConverter implements TypeConverter
+public final class NullToListConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NumberToBooleanConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NumberToBooleanConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NumberToBooleanConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/NumberToBooleanConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class NumberToBooleanConverter implements TypeConverter
+public final class NumberToBooleanConverter implements TypeConverter
 {
     public Object convertValue(Object value)
     {

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectArrayToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectArrayToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectArrayToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectArrayToListConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class ObjectArrayToListConverter implements TypeConverter
+public final class ObjectArrayToListConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToBooleanConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToBooleanConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToBooleanConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToBooleanConverter.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class ObjectToBooleanConverter implements TypeConverter
+public final class ObjectToBooleanConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToIteratorConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToIteratorConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToIteratorConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToIteratorConverter.java Sat Oct  8 08:59:15 2005
@@ -22,7 +22,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class ObjectToIteratorConverter implements TypeConverter
+public final class ObjectToIteratorConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToListConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToListConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToListConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToListConverter.java Sat Oct  8 08:59:15 2005
@@ -22,7 +22,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class ObjectToListConverter implements TypeConverter
+public final class ObjectToListConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToStringConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToStringConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToStringConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/ObjectToStringConverter.java Sat Oct  8 08:59:15 2005
@@ -18,7 +18,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class ObjectToStringConverter implements TypeConverter
+public final class ObjectToStringConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringConvertedPropertySelectionModel.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringConvertedPropertySelectionModel.java?rev=307306&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringConvertedPropertySelectionModel.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringConvertedPropertySelectionModel.java Sat Oct  8 08:59:15 2005
@@ -0,0 +1,103 @@
+// Copyright 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.coerce;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hivemind.util.Defense;
+import org.apache.tapestry.form.IPropertySelectionModel;
+
+/**
+ * {@link org.apache.tapestry.form.IPropertySelectionModel} created from a comma-seperated string by
+ * {@link org.apache.tapestry.coerce.StringToPropertySelectionModelConverter}.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public final class StringConvertedPropertySelectionModel implements IPropertySelectionModel
+{
+    private static class Entry
+    {
+        String _label;
+
+        String _value;
+
+        Entry(String term)
+        {
+            Defense.notNull(term, "term");
+
+            int equalx = term.indexOf('=');
+
+            if (equalx < 0)
+            {
+                _label = term.trim();
+                _value = _label;
+            }
+            else
+            {
+                _label = term.substring(0, equalx).trim();
+                _value = term.substring(equalx + 1).trim();
+            }
+        }
+    }
+
+    private final List _entries;
+
+    public StringConvertedPropertySelectionModel(String[] terms)
+    {
+        Defense.notNull(terms, "terms");
+
+        _entries = new ArrayList(terms.length);
+
+        for (int i = 0; i < terms.length; i++)
+        {
+            _entries.add(new Entry(terms[i]));
+        }
+    }
+
+    public int getOptionCount()
+    {
+        return _entries.size();
+    }
+
+    private Entry getEntry(int index)
+    {
+        return (Entry) _entries.get(index);
+    }
+
+    public Object getOption(int index)
+    {
+        return getValue(index);
+    }
+
+    public String getLabel(int index)
+    {
+        // TODO Auto-generated method stub
+        return getEntry(index)._label;
+    }
+
+    public String getValue(int index)
+    {
+        return getEntry(index)._value;
+    }
+
+    public Object translateValue(String value)
+    {
+        // Values are the same on the client and the server, so no translation needed.
+        return value;
+    }
+
+}

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToBooleanConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToBooleanConverter.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToBooleanConverter.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToBooleanConverter.java Sat Oct  8 08:59:15 2005
@@ -24,7 +24,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class StringToBooleanConverter implements TypeConverter
+public final class StringToBooleanConverter implements TypeConverter
 {
 
     public Object convertValue(Object value)

Added: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToPropertySelectionModelConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToPropertySelectionModelConverter.java?rev=307306&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToPropertySelectionModelConverter.java (added)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/StringToPropertySelectionModelConverter.java Sat Oct  8 08:59:15 2005
@@ -0,0 +1,39 @@
+// Copyright 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.coerce;
+
+import org.apache.tapestry.TapestryUtils;
+
+/**
+ * Converts a string to a {@link org.apache.tapestry.form.IPropertySelectionModel}. The string is
+ * broken apart at commas into terms. Each term consists of a label (displayed to the user) and a
+ * value (used as a client-side value and as the server-side property) seperated by an equals sign;
+ * if the equals sign is omitted, then the value is the same as the label.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public final class StringToPropertySelectionModelConverter implements TypeConverter
+{
+    public Object convertValue(Object value)
+    {
+        String input = (String) value;
+
+        String[] terms = TapestryUtils.split(input);
+
+        return new StringConvertedPropertySelectionModel(terms);
+    }
+
+}

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterContribution.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterContribution.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterContribution.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterContribution.java Sat Oct  8 08:59:15 2005
@@ -21,7 +21,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TypeConverterContribution
+public final class TypeConverterContribution
 {
     private TypeConverter _converter;
 

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterWrapper.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterWrapper.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/coerce/TypeConverterWrapper.java Sat Oct  8 08:59:15 2005
@@ -30,7 +30,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TypeConverterWrapper implements TypeConverter
+public final class TypeConverterWrapper implements TypeConverter
 {
     private StrategyRegistry _registry = new StrategyRegistryImpl();
 

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/services/impl/ComponentConstructorFactoryImpl.java Sat Oct  8 08:59:15 2005
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.hivemind.ClassResolver;
 import org.apache.hivemind.service.ClassFactory;
+import org.apache.hivemind.util.Defense;
 import org.apache.tapestry.enhance.EnhancedClassValidator;
 import org.apache.tapestry.enhance.EnhancementOperationImpl;
 import org.apache.tapestry.enhance.EnhancementWorker;
@@ -40,7 +41,7 @@
         ResetEventListener
 {
     private Log _log;
-    
+
     private ClassFactory _classFactory;
 
     private ClassResolver _classResolver;
@@ -64,33 +65,36 @@
     public ComponentConstructor getComponentConstructor(IComponentSpecification specification,
             String className)
     {
-        ComponentConstructor result = (ComponentConstructor) _cachedConstructors.get(specification);
+        Defense.notNull(specification, "specification");
 
-        if (result == null)
+        synchronized (specification)
         {
-            Class baseClass = _classResolver.findClass(className);
+            ComponentConstructor result = (ComponentConstructor) _cachedConstructors
+                    .get(specification);
 
-            EnhancementOperationImpl eo = new EnhancementOperationImpl(_classResolver,
-                    specification, baseClass, _classFactory, _log);
+            if (result == null)
+            {
+                Class baseClass = _classResolver.findClass(className);
 
-            // Invoking on the chain is the same as invoking on every
-            // object in the chain (because method performEnhancement() is type void).
+                EnhancementOperationImpl eo = new EnhancementOperationImpl(_classResolver,
+                        specification, baseClass, _classFactory, _log);
 
-            _chain.performEnhancement(eo, specification);
+                // Invoking on the chain is the same as invoking on every
+                // object in the chain (because method performEnhancement() is type void).
 
-            result = eo.getConstructor();
+                _chain.performEnhancement(eo, specification);
 
-            // TODO: This should be optional to work around that IBM JVM bug.
-            // Also, to some degree, it should be passed into EnhancementOperationImpl,
-            // as it generally only needs to be done if a enhanced class
-            // is fabricated.
+                result = eo.getConstructor();
 
-            _validator.validate(baseClass, result.getComponentClass(), specification);
+                // TODO: This should be optional to work around that IBM JVM bug.
 
-            _cachedConstructors.put(specification, result);
-        }
+                _validator.validate(baseClass, result.getComponentClass(), specification);
 
-        return result;
+                _cachedConstructors.put(specification, result);
+            }
+
+            return result;
+        }
     }
 
     public void setClassFactory(ClassFactory classFactory)

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/ServletWebResponse.java Sat Oct  8 08:59:15 2005
@@ -134,4 +134,9 @@
         _servletResponse.setIntHeader(name, value);
     }
 
+    public void sendError(int statusCode, String message) throws IOException
+    {
+        _servletResponse.sendError(statusCode, message);
+    }
+
 }

Modified: jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java (original)
+++ jakarta/tapestry/trunk/framework/src/java/org/apache/tapestry/web/WebResponse.java Sat Oct  8 08:59:15 2005
@@ -109,4 +109,10 @@
      * Sets the status code for this response.
      */
     public void setStatus(int status);
+
+    /**
+     * Sends an error response.
+     */
+
+    public void sendError(int statusCode, String message) throws IOException;
 }

Added: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/coerce/StringToPropertySelectionModelConverterTest.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/coerce/StringToPropertySelectionModelConverterTest.java?rev=307306&view=auto
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/coerce/StringToPropertySelectionModelConverterTest.java (added)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/coerce/StringToPropertySelectionModelConverterTest.java Sat Oct  8 08:59:15 2005
@@ -0,0 +1,85 @@
+// Copyright 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.coerce;
+
+import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.form.IPropertySelectionModel;
+
+/**
+ * Tests for {@link org.apache.tapestry.coerce.StringToPropertySelectionModelConverter} and
+ * {@link org.apache.tapestry.coerce.StringConvertedPropertySelectionModel}.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 4.0
+ */
+public class StringToPropertySelectionModelConverterTest extends HiveMindTestCase
+{
+    private IPropertySelectionModel newModel(String value)
+    {
+        return (IPropertySelectionModel) new StringToPropertySelectionModelConverter()
+                .convertValue(value);
+    }
+
+    private void assertValues(IPropertySelectionModel model, String... values)
+    {
+        assertEquals(values.length, model.getOptionCount());
+
+        for (int i = 0; i < values.length; i++)
+        {
+            assertEquals(values[i], model.getValue(i));
+            assertEquals(values[i], model.getOption(i));
+        }
+    }
+
+    private void assertLabels(IPropertySelectionModel model, String... labels)
+    {
+        assertEquals(labels.length, model.getOptionCount());
+
+        for (int i = 0; i < labels.length; i++)
+            assertEquals(labels[i], model.getLabel(i));
+    }
+
+    public void testJustLabels()
+    {
+        IPropertySelectionModel model = newModel("Green,Red,Blue");
+
+        assertValues(model, "Green", "Red", "Blue");
+        assertLabels(model, "Green", "Red", "Blue");
+    }
+
+    public void testLabelsAndValues()
+    {
+        IPropertySelectionModel model = newModel("Red=RED,Green=GREEN,Blue=BLUE");
+
+        assertValues(model, "RED", "GREEN", "BLUE");
+        assertLabels(model, "Red", "Green", "Blue");
+    }
+
+    public void testBlankValue()
+    {
+        IPropertySelectionModel model = newModel("--Colors--=,Red=RED,Green=GREEN,Blue=BLUE");
+
+        assertValues(model, "", "RED", "GREEN", "BLUE");
+        assertLabels(model, "--Colors--", "Red", "Green", "Blue");
+    }
+
+    public void testWhiteSpaceTrimmed()
+    {
+        IPropertySelectionModel model = newModel("--Colors--=\t,\n\tRed\t=\tRED\t,\n\tGreen\t=\tGREEN\t,\n\tBlue\t=\tBLUE\n");
+
+        assertValues(model, "", "RED", "GREEN", "BLUE");
+        assertLabels(model, "--Colors--", "Red", "Green", "Blue");
+    }
+}

Modified: jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java (original)
+++ jakarta/tapestry/trunk/framework/src/test/org/apache/tapestry/web/TestServletWebResponse.java Sat Oct  8 08:59:15 2005
@@ -48,7 +48,7 @@
 
         response.setContentType("foo/bar");
         response.getOutputStream();
-        setReturnValue(response,stream);
+        setReturnValue(response, stream);
 
         replayControls();
 
@@ -95,7 +95,7 @@
 
         response.setContentType("foo/bar");
         response.getWriter();
-        setReturnValue(response,writer);
+        setReturnValue(response, writer);
 
         replayControls();
 
@@ -115,7 +115,7 @@
 
         response.setContentType("foo/bar");
         response.getWriter();
-        setReturnValue(response,writer1);
+        setReturnValue(response, writer1);
 
         replayControls();
 
@@ -128,7 +128,7 @@
         response.reset();
         response.setContentType("zip/zap");
         response.getWriter();
-        setReturnValue(response,writer2);
+        setReturnValue(response, writer2);
 
         replayControls();
 
@@ -185,13 +185,14 @@
         return (HttpServletResponse) newMock(HttpServletResponse.class);
     }
 
-    public void testSetHeaderMethods()
+    public void testSetHeaderMethods() throws Exception
     {
         HttpServletResponse response = newResponse();
 
         response.setHeader("fie", "fie");
         response.setDateHeader("expires", -1);
         response.setIntHeader("size", 33);
+        response.sendError(99, "foo!");
 
         replayControls();
 
@@ -200,6 +201,7 @@
         swr.setHeader("fie", "fie");
         swr.setDateHeader("expires", -1);
         swr.setIntHeader("size", 33);
+        swr.sendError(99, "foo!");
 
         verifyControls();
 

Modified: jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java (original)
+++ jakarta/tapestry/trunk/portlet/src/java/org/apache/tapestry/portlet/PortletWebResponse.java Sat Oct  8 08:59:15 2005
@@ -110,4 +110,10 @@
         unsupported("setIntHeader");
     }
 
+    /** Unsupported. */
+    public void sendError(int statusCode, String message) throws IOException
+    {
+        unsupported("sendError");
+    }
+
 }

Modified: jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java (original)
+++ jakarta/tapestry/trunk/portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java Sat Oct  8 08:59:15 2005
@@ -150,6 +150,27 @@
         verifyControls();
     }
 
+    public void testSendErrorUnsupported() throws Exception
+    {
+        PortletResponse response = newResponse();
+
+        replayControls();
+
+        PortletWebResponse pwr = new PortletWebResponse(response);
+
+        try
+        {
+            pwr.sendError(99, "foo!");
+            unreachable();
+        }
+        catch (UnsupportedOperationException ex)
+        {
+            // Expected.
+        }
+
+        verifyControls();
+    }
+
     public void testEncodeURL()
     {
         MockControl control = newControl(PortletResponse.class);

Modified: jakarta/tapestry/trunk/status.xml
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/status.xml?rev=307306&r1=307305&r2=307306&view=diff
==============================================================================
--- jakarta/tapestry/trunk/status.xml (original)
+++ jakarta/tapestry/trunk/status.xml Sat Oct  8 08:59:15 2005
@@ -53,7 +53,10 @@
     <release version="4.0-beta-10" date="unreleased">
       <action type="fix" dev="HLS" fixes-bug="TAPESTRY-344">Unimplemented abstract method check broken</action>
       <action type="add" dev="HLS">Add DefaultPrimaryKeyConverter for use with the For component</action>
-      <action type="update" dev="HLS">Change For component to interleave rendering/rewinding with access to its primary key converter</action>      
+      <action type="update" dev="HLS">Change For component to interleave rendering/rewinding with access to its primary key converter</action>
+      <action type="fix" dev="HLS" fixes-bug="TAPESTRY-696">Race condition during page loading can cause anomoylous exceptions related to annotations</action>
+      <action type="fix" dev="HLS" fixes-bug="TAPESTRY-685">Asset service sends a 200 response even when the provided md5 checksum is invalid</action>
+      <action type="fix" dev="HLS" fixes-bug="TAPESTRY-564">Automatically create an IPropertySelection model from a string</action>      
     </release>
     <release version="4.0-beta-9" date="Oct 1 2005">
       <action type="fix" dev="DS" fixes-bug="TAPESTRY-663">Document Button component</action>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message