Author: jkuhnert
Date: Tue Mar 21 14:34:29 2006
New Revision: 387654
URL: http://svn.apache.org/viewcvs?rev=387654&view=rev
Log:
Re fixed Upload component, took out maxSize parameter and left the maxSize
value in MultipartDecoderImpl..Also updated
documentation to show how to override this default value.
Modified:
jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.jwc
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderFilter.java
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/ServletMultipartDecoder.java
Modified:
jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/documentation/content/xdocs/tapestry/ComponentReference/Upload.xml
Tue Mar 21 14:34:29 2006
@@ -30,8 +30,23 @@
<p>A form element used to handle file uploads. The uploaded file is
represented by an instance of &IUploadFile;.</p>
+<p>The maximum upload size of a file can be set by configuring the <link
href="&apiroot;/multipart/MultipartDecoder.html">MultipartDecoder</link>
+ service in hivemind. The default is 10000000(10kb).</p>
+
+<section>
+<source><![CDATA[
+Example of how to set the default maximum file upload size.
+<implementation service-id="tapestry.multipart.MultipartDecoder">
+<create-instance
class="org.apache.tapestry.multipart.MultipartDecoderImpl,maxSize=-1"
model="threaded" />
+</implementation>
+]]></source>
+</section>
+
<p>
- <strong>See also: <link
href="&apiroot;/form/Upload.html">org.apache.tapestry.form.Upload</link>,
&Form;</strong>
+ <strong>See also:
+
+ <link
href="&apiroot;/form/Upload.html">org.apache.tapestry.form.Upload</link>,
&Form;</strong>,
+ <link
href="&apiroot;/multipart/MultipartDecoder.html">MultipartDecoder</link>
</p>
<warning>
@@ -107,20 +122,6 @@
<td></td>
<td>
Sets the id attribute for the rendered <input> element.
- </td>
-
- </tr>
- <tr>
-
- <td>maxSize</td>
- <td>long</td>
- <td>in</td>
- <td>no</td>
- <td>10000000</td>
- <td>
- The default maximum file upload size, in bytes. Default is 10kb.
- Note: This parameter will be ignored if the maximum size is set manually
- on the <link
href="&apiroot;/multipart/MultipartDecoder.html">MultipartDecoder</link>
service.
</td>
</tr>
Modified:
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.java
Tue Mar 21 14:34:29 2006
@@ -59,15 +59,15 @@
{
writer.attribute("disabled", "disabled");
}
-
+
renderIdAttribute(writer, cycle);
-
+
renderDelegateAttributes(writer, cycle);
-
+
getValidatableFieldSupport().renderContributions(this, writer, cycle);
-
+
renderInformalParameters(writer, cycle);
-
+
writer.closeTag();
renderDelegateSuffix(writer, cycle);
@@ -79,11 +79,6 @@
*/
protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle
cycle)
{
- // set the max file upload size first, but only if
- // not already set manually on the decoder service
- if (!getDecoder().isMaxSizeSet())
- getDecoder().setSizeMax(getMaxSize());
-
IUploadFile file = getDecoder().getFileUpload(getName());
if (HiveMind.isBlank(file.getFileName()))
@@ -102,14 +97,6 @@
getForm().getDelegate().record(e);
}
}
-
- /**
- * Max size parameter, in bytes. Parameter is ignored if
- * [EMAIL PROTECTED] MultipartDecoder#isMaxSizeSet()} returns true.
- *
- * @return The maximum file size that may be uploaded.
- */
- public abstract long getMaxSize();
/**
* Injected.
Modified:
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.jwc
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.jwc?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.jwc
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/form/Upload.jwc
Tue Mar 21 14:34:29 2006
@@ -39,8 +39,6 @@
<parameter name="validators"/>
<parameter name="id" property="idParameter" default-value="id"/>
- <parameter name="maxSize" default-value="10000000" />
-
<reserved-parameter name="type"/>
<reserved-parameter name="name"/>
Modified:
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoder.java
Tue Mar 21 14:34:29 2006
@@ -32,24 +32,6 @@
*/
public IUploadFile getFileUpload(String parameterName);
-
- /**
- * Sets the maximum upload file size on the resulting [EMAIL PROTECTED]
FileUpload}
- * object. Also sets the internal state so that [EMAIL PROTECTED]
#isMaxSizeSet()} will
- * return true.
- *
- * @see <a
href="http://jakarta.apache.org/commons/fileupload/apidocs/org/apache/commons/fileupload/FileUploadBase.html#setSizeMax(long)">FileUpload</a>
- * @param sizeMax The maximum file size allowed for uploads, default is
10kb
- */
-
- public void setSizeMax(long sizeMax);
-
- /**
- * Checks if the [EMAIL PROTECTED] #setSizeMax(long)} value has been
manually set.
- * @return True, if the [EMAIL PROTECTED] #setSizeMax(long)} method has
been called.
- */
-
- public boolean isMaxSizeSet();
/**
* Cleans up any temporary resources created during the request
processing.
Modified:
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderFilter.java
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderFilter.java?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderFilter.java
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderFilter.java
Tue Mar 21 14:34:29 2006
@@ -48,7 +48,7 @@
try
{
HttpServletRequest newRequest = encoded ? _decoder.decode(request)
: request;
-
+
servicer.service(newRequest, response);
}
finally
Modified:
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/MultipartDecoderImpl.java
Tue Mar 21 14:34:29 2006
@@ -37,12 +37,7 @@
public class MultipartDecoderImpl extends AbstractMultipartDecoder implements
ServletMultipartDecoder
{
/* maximum size of file allowed to be uploaded */
- protected long _sizeMax = 10000000;
- /*
- * boolean check for whether someone has manually set
- * the maximum upload size directly on this service
- */
- protected boolean _sizeMaxSet = false;
+ protected long _maxSize = 10000000;
public HttpServletRequest decode(HttpServletRequest request)
{
@@ -71,7 +66,7 @@
ServletFileUpload upload = new ServletFileUpload(factory);
// set maximum file upload size
- upload.setSizeMax(_sizeMax);
+ upload.setSizeMax(_maxSize);
if (_encoding != null)
upload.setHeaderEncoding(_encoding);
@@ -80,19 +75,11 @@
}
/**
- * [EMAIL PROTECTED]
- */
- public void setSizeMax(long sizeMax)
- {
- _sizeMaxSet = true;
- _sizeMax = sizeMax;
- }
-
- /**
- * [EMAIL PROTECTED]
+ * Sets the maximum size that an uploaded file will be allowed to have.
+ * @param maxSize The maximum size, in bytes.
*/
- public boolean isMaxSizeSet()
+ public void setMaxSize(long maxSize)
{
- return _sizeMaxSet;
+ _maxSize = maxSize;
}
}
Modified:
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/ServletMultipartDecoder.java
URL:
http://svn.apache.org/viewcvs/jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/ServletMultipartDecoder.java?rev=387654&r1=387653&r2=387654&view=diff
==============================================================================
---
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/ServletMultipartDecoder.java
(original)
+++
jakarta/tapestry/branches/4.0/framework/src/java/org/apache/tapestry/multipart/ServletMultipartDecoder.java
Tue Mar 21 14:34:29 2006
@@ -25,6 +25,7 @@
* Decodes the request, returning a new [EMAIL PROTECTED]
javax.servlet.http.HttpServletRequest}
* implementation that will allow access to the form fields submitted in
the request (but omits
* uploaded files.
+ * @param request The incoming servlet request
*/
public HttpServletRequest decode(HttpServletRequest request);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]