tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/web new.html
Date Wed, 23 Apr 2003 22:45:12 GMT
hlship      2003/04/23 15:45:12

  Modified:    framework/src/org/apache/tapestry/form Hidden.java Form.java
                        ListEdit.java
               framework/src/org/apache/tapestry IForm.java
               junit/src/org/apache/tapestry/junit/valid TestingForm.java
               framework/src/org/apache/tapestry/wml Go.java
               web      new.html
  Log:
  Let Form component write all <input type="hidden"> just after <form>, rather
than all over the place.
  
  Revision  Changes    Path
  1.5       +2 -5      jakarta-tapestry/framework/src/org/apache/tapestry/form/Hidden.java
  
  Index: Hidden.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Hidden.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Hidden.java	26 Mar 2003 19:52:05 -0000	1.4
  +++ Hidden.java	23 Apr 2003 22:45:10 -0000	1.5
  @@ -113,10 +113,7 @@
               else
                   externalValue = (String) getValueBinding().getObject("value", String.class);
   
  -            writer.beginEmpty("input");
  -            writer.attribute("type", "hidden");
  -            writer.attribute("name", name);
  -            writer.attribute("value", externalValue);
  +			form.addHiddenValue(name, externalValue);
   
               return;
           }
  
  
  
  1.7       +53 -18    jakarta-tapestry/framework/src/org/apache/tapestry/form/Form.java
  
  Index: Form.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/Form.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Form.java	17 Apr 2003 21:33:45 -0000	1.6
  +++ Form.java	23 Apr 2003 22:45:10 -0000	1.7
  @@ -107,6 +107,18 @@
   
   public abstract class Form extends AbstractComponent implements IForm, IDirect
   {
  +    private static class HiddenValue
  +    {
  +        String _name;
  +        String _value;
  +
  +        private HiddenValue(String name, String value)
  +        {
  +            _name = name;
  +            _value = value;
  +        }
  +    }
  +
       private boolean _rewinding;
       private boolean _rendering;
       private String _name;
  @@ -148,6 +160,8 @@
   
       private String _encodingType;
   
  +    private List _hiddenValues;
  +
       /**
        *  Returns the currently active {@link IForm}, or null if no form is
        *  active.  This is a convienience method, the result will be
  @@ -172,7 +186,7 @@
       {
           if (!_rendering)
               throw Tapestry.createRenderOnlyPropertyException(this, "rewinding");
  - 
  +
           return _rewinding;
       }
   
  @@ -267,8 +281,8 @@
           }
   
           _allocatedIdIndex++;
  -	
  -		component.setName(result);
  +
  +        component.setName(result);
   
           return result;
       }
  @@ -320,6 +334,9 @@
   
           _elementIdAllocator.clear();
   
  +        if (_hiddenValues != null)
  +            _hiddenValues.clear();
  +
           cycle.removeAttribute(ATTRIBUTE_NAME);
   
           _encodingType = null;
  @@ -399,7 +416,8 @@
               // of ids will change as well.
   
               writeHiddenField(writer, _name, buildAllocatedIdList());
  -
  +			writeHiddenValues(writer);
  +    		
               nested.close();
   
               writer.end(getTag());
  @@ -650,7 +668,7 @@
   
       protected void writeHiddenField(IMarkupWriter writer, String name, String value)
       {
  -        writer.beginEmpty(getInputTag());
  +        writer.beginEmpty("input");
           writer.attribute("type", "hidden");
           writer.attribute("name", name);
           writer.attribute("value", value);
  @@ -783,18 +801,6 @@
       }
   
       /**
  -     * Returns the tag of the input element used by the form.
  -     *
  -     *  @since 3.0
  -     *
  -     **/
  -
  -    protected String getInputTag()
  -    {
  -        return "input";
  -    }
  -
  -    /**
        * Returns the name of the element.
        *
        *
  @@ -805,4 +811,33 @@
       {
           return "Form";
       }
  +
  +    /** @since 3.0 */
  +
  +    public void addHiddenValue(String name, String value)
  +    {
  +        if (_hiddenValues == null)
  +            _hiddenValues = new ArrayList();
  +
  +        _hiddenValues.add(new HiddenValue(name, value));
  +    }
  +
  +	/** 
  +	 * Writes hidden values accumulated during the render
  +	 * (by components invoking {@link #addHiddenValue(String, String)}.
  +	 * 
  +	 * @since 3.0
  +	 */
  +	
  +	protected void writeHiddenValues(IMarkupWriter writer)
  +	{
  +		int count = Tapestry.size(_hiddenValues);
  +		
  +		for (int i = 0; i < count; i++)
  +		{
  +			HiddenValue hv = (HiddenValue)_hiddenValues.get(i);
  +			
  +			writeHiddenField(writer, hv._name, hv._value);
  +		}
  +	}
   }
  
  
  
  1.7       +5 -8      jakarta-tapestry/framework/src/org/apache/tapestry/form/ListEdit.java
  
  Index: ListEdit.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/form/ListEdit.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ListEdit.java	17 Apr 2003 21:33:45 -0000	1.6
  +++ ListEdit.java	23 Apr 2003 22:45:11 -0000	1.7
  @@ -138,7 +138,7 @@
               else
               {
                   value = i.next();
  -                writeValue(writer, name, value);
  +                writeValue(form, name, value);
               }
   
               valueBinding.setObject(value);
  @@ -160,7 +160,7 @@
           }
       }
   
  -    private void writeValue(IMarkupWriter writer, String name, Object value)
  +    private void writeValue(IForm form, String name, Object value)
       {
           String externalValue;
   
  @@ -176,11 +176,8 @@
                   ex);
           }
   
  -        writer.beginEmpty("input");
  -        writer.attribute("type", "hidden");
  -        writer.attribute("name", name);
  -        writer.attribute("value", externalValue);
  -        writer.println();
  +
  +		form.addHiddenValue(name, externalValue);
       }
   
       private Object convertValue(String value)
  
  
  
  1.5       +17 -1     jakarta-tapestry/framework/src/org/apache/tapestry/IForm.java
  
  Index: IForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/IForm.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IForm.java	17 Apr 2003 21:33:46 -0000	1.4
  +++ IForm.java	23 Apr 2003 22:45:11 -0000	1.5
  @@ -181,4 +181,20 @@
        **/
       
       public void setEncodingType(String encodingType);
  +    
  +    
  +    /**
  +     * Adds a hidden field value to be stored in the form. This ensures that all
  +     * of the &lt;input type="hidden"&gt; (or equivalent) are grouped together,

  +     * which ensures that the output HTML is valid (ie. doesn't 
  +     * have &lt;input&gt; improperly nested with &lt;tr&gt;, etc.).
  +     * 
  +     * <p>
  +     * It is acceptible to add multiple hidden fields with the same name.
  +     * They will be written in the order they are received.
  +     * 
  +     * @since 3.0
  +     */
  +
  +	public void addHiddenValue(String name, String value);
   }
  
  
  
  1.5       +7 -1      jakarta-tapestry/junit/src/org/apache/tapestry/junit/valid/TestingForm.java
  
  Index: TestingForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/junit/valid/TestingForm.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestingForm.java	15 Apr 2003 18:14:33 -0000	1.4
  +++ TestingForm.java	23 Apr 2003 22:45:11 -0000	1.5
  @@ -276,4 +276,10 @@
       {
       }
   
  +    /** @since 3.0 */
  +    public void addHiddenValue(String name, String value)
  +    {
  +
  +    }
  +
   }
  
  
  
  1.5       +2 -6      jakarta-tapestry/framework/src/org/apache/tapestry/wml/Go.java
  
  Index: Go.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/wml/Go.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Go.java	17 Apr 2003 21:33:44 -0000	1.4
  +++ Go.java	23 Apr 2003 22:45:11 -0000	1.5
  @@ -91,7 +91,7 @@
   
       protected void writeHiddenField(IMarkupWriter writer, String name, String value)
       {
  -        writer.beginEmpty(getInputTag());
  +        writer.beginEmpty("postfield");
           writer.attribute("name", name);
           writer.attribute("value", value);
           writer.println();
  @@ -125,10 +125,6 @@
           return "go";
       }
   
  -    protected String getInputTag()
  -    {
  -        return "postfield";
  -    }
   
       protected String getDisplayName()
       {
  
  
  
  1.158     +3 -2      jakarta-tapestry/web/new.html
  
  Index: new.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/web/new.html,v
  retrieving revision 1.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- new.html	21 Apr 2003 15:40:02 -0000	1.157
  +++ new.html	23 Apr 2003 22:45:12 -0000	1.158
  @@ -31,10 +31,11 @@
   Besides setting the page to be rendered, it also invokes page.validate() and handles the
page redirections.</li>
   <li>Added addValidateListener() and removeValidateListener()
   to <a href="doc/api/org/apache/tapestry/IPage.html">IPage</a>.</li>
  -<li>Squeezed strings are now always prefixed with 'S'</li>
  +<li><a href="doc/api/org/apache/tapestry/util/io/DataSqueezer.html">DataSqueezer</a>:
Squeezed strings are now always prefixed with 'S'</li>
   <li>Added mechanism for checking that super-class implementations of key methods
are invoked.</li>
   <li>Added checks that <a href="doc/api/org/apache/tapestry/IPage.html">IPage</a>
methods
   <code>validate()</code> and <code>detach</code> are properly overriden
by subclasses.</li>
  +<li>Changed Form, Hidden and ListEdit so that all hidden fields are written out with
the &lt;form&gt; tag.</li>
   </ul>
   
   <pre>
  
  
  

Mime
View raw message