You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2004/01/09 22:53:16 UTC
cvs commit: jakarta-struts/web/examples/upload upload.jsp display.jsp
husted 2004/01/09 13:53:16
Modified: web/examples/upload upload.jsp display.jsp
Log:
Change upload modules to use message tags for validation errors; refine markup on display page.
Revision Changes Path
1.2 +21 -37 jakarta-struts/web/examples/upload/upload.jsp
Index: upload.jsp
===================================================================
RCS file: /home/cvs/jakarta-struts/web/examples/upload/upload.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- upload.jsp 8 Jan 2004 16:20:45 -0000 1.1
+++ upload.jsp 9 Jan 2004 21:53:16 -0000 1.2
@@ -7,46 +7,30 @@
<title>File Upload Example</title>
</head>
<body>
- <!-- Find out if the maximum length has been exceeded. -->
- <logic:present name="<%= Globals.ERROR_KEY %>" scope="request">
- <%
- ActionErrors errors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
- //note that this error is created in the validate() method of UploadForm
- Iterator iterator = errors.get(UploadForm.ERROR_PROPERTY_MAX_LENGTH_EXCEEDED);
- //there's only one possible error in this
- ActionError error = (ActionError) iterator.next();
- pageContext.setAttribute("maxlength.error", error, PageContext.REQUEST_SCOPE);
- %>
- </logic:present>
- <!-- If there was an error, print it out -->
- <logic:present name="maxlength.error" scope="request">
- <font color="red">
- <bean:message name="maxlength.error" property="key" />
- </font>
- </logic:present>
- <logic:notPresent name="maxlength.error" scope="request">Note that the maximum allowed size of an uploaded file for this application is two megabytes. See the /WEB-INF/struts-config.xml file for this application to change it.</logic:notPresent>
- <br />
- <br />
+<logic:messagesPresent>
+ <ul>
+ <html:messages id="error">
+ <li><bean:write name="error"/></li>
+ </html:messages>
+ </ul><hr />
+</logic:messagesPresent>
+
<!--
The most important part is to declare your form's enctype to be "multipart/form-data",
and to have a form:file element that maps to your ActionForm's FormFile property
-->
- <html:form action="upload-submit.do?queryParam=Successful" enctype="multipart/form-data">Please enter some text, just to demonstrate the handling of text elements as opposed to file elements:
- <br />
- <html:text property="theText" />
- <br />
- <br />Please select the file that you would like to upload:
- <br />
- <html:file property="theFile" />
- <br />
- <br />If you would rather write this file to another file, please check here:
- <html:checkbox property="writeFile" />
- <br />
- <br />If you checked the box to write to a file, please specify the file path here:
- <br />
- <html:text property="filePath" />
- <br />
- <br />
- <html:submit /></html:form>
+ <html:form action="upload-submit.do?queryParam=Successful" enctype="multipart/form-data">
+ <p>Please enter some text, just to demonstrate the handling of text elements as opposed to file elements: <br />
+ <html:text property="theText" /></p>
+ <p>Please select the file that you would like to upload: <br />
+ <html:file property="theFile" /></p>
+ <p>If you would rather write this file to another file, please check here: <br />
+ <html:checkbox property="writeFile" /></p>
+ <p>If you checked the box to write to a file, please specify the file path here: <br />
+ <html:text property="filePath" /></p>
+ <p>
+ <html:submit />
+ </p>
+ </html:form>
</body>
</html>
1.2 +18 -12 jakarta-struts/web/examples/upload/display.jsp
Index: display.jsp
===================================================================
RCS file: /home/cvs/jakarta-struts/web/examples/upload/display.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- display.jsp 8 Jan 2004 16:20:45 -0000 1.1
+++ display.jsp 9 Jan 2004 21:53:16 -0000 1.2
@@ -1,15 +1,21 @@
-<b>The Text</b><%= request.getAttribute("text") %>
-<br />
-<b>The Query Parameter</b><%= request.getAttribute("queryValue") %>
-<br />
-<b>The File name</b><%= request.getAttribute("fileName") %>
-<br />
-<b>The File content type</b><%= request.getAttribute("contentType") %>
-<br />
-<b>The File size</b><%= request.getAttribute("size") %>
-<br />
-<b>The File data</b>
-<br />
+<p>
+<b>The Text:</b> <%= request.getAttribute("text") %>
+</p>
+<p>
+<b>The Query Parameter:</b> <%= request.getAttribute("queryValue") %>
+</p>
+<p>
+<b>The File name:</b> <%= request.getAttribute("fileName") %>
+</p>
+<p>
+<b>The File content type:</b> <%= request.getAttribute("contentType") %>
+</p>
+<p>
+<b>The File size:</b> <%= request.getAttribute("size") %>
+</p>
+<p>
+<b>The File data:</b>
+</p>
<hr />
<pre>
<%= request.getAttribute("data") %>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org