http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/execute-and-wait-interceptor.html ---------------------------------------------------------------------- diff --git a/content/docs/execute-and-wait-interceptor.html b/content/docs/execute-and-wait-interceptor.html index 7a80995..3a9cf48 100644 --- a/content/docs/execute-and-wait-interceptor.html +++ b/content/docs/execute-and-wait-interceptor.html @@ -203,7 +203,7 @@ background process extension, extend ExecuteAndWaitInterceptor and implement the <h2 id="ExecuteandWaitInterceptor-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="completeStack"/> <interceptor-ref name="execAndWait"/>
http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/expression-validator.html ---------------------------------------------------------------------- diff --git a/content/docs/expression-validator.html b/content/docs/expression-validator.html index 2ac8ac4..e4b8d48 100644 --- a/content/docs/expression-validator.html +++ b/content/docs/expression-validator.html @@ -150,7 +150,7 @@ under the License. <h1 id="expressionvalidator-Examples">Examples</h1> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <validators> <validator type="expression"> <param name="expression"> .... </param> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/expressionvalidator-annotation.html ---------------------------------------------------------------------- diff --git a/content/docs/expressionvalidator-annotation.html b/content/docs/expressionvalidator-annotation.html index 0b973a8..e0a727d 100644 --- a/content/docs/expressionvalidator-annotation.html +++ b/content/docs/expressionvalidator-annotation.html @@ -155,7 +155,7 @@ under the License. <h2 id="ExpressionValidatorAnnotation-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ @ExpressionValidator(message = "Default message", key = "i18n.key", shortCircuit = true, expression = "an OGNL expression" ) ]]></script> </div></div></div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/fielderror.html ---------------------------------------------------------------------- diff --git a/content/docs/fielderror.html b/content/docs/fielderror.html index 888a2fe..76e5a9e 100644 --- a/content/docs/fielderror.html +++ b/content/docs/fielderror.html @@ -153,7 +153,7 @@ The field error strings will be html escaped by default.</p> <h2 id="fielderror-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <!-- example 1 --> <s:fielderror /> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/fieldexpression-validator.html ---------------------------------------------------------------------- diff --git a/content/docs/fieldexpression-validator.html b/content/docs/fieldexpression-validator.html index 651f2e8..b1cc327 100644 --- a/content/docs/fieldexpression-validator.html +++ b/content/docs/fieldexpression-validator.html @@ -149,7 +149,7 @@ under the License. <h1 id="fieldexpressionvalidator-Examples">Examples</h1> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <!-- Plain Validator Syntax --> <validators> <!-- Plain Validator Syntax --> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/fieldexpressionvalidator-annotation.html ---------------------------------------------------------------------- diff --git a/content/docs/fieldexpressionvalidator-annotation.html b/content/docs/fieldexpressionvalidator-annotation.html index 1f06f9a..7e6387e 100644 --- a/content/docs/fieldexpressionvalidator-annotation.html +++ b/content/docs/fieldexpressionvalidator-annotation.html @@ -155,7 +155,7 @@ false when it is evaluated against the value stack.</p> <h2 id="FieldExpressionValidatorAnnotation-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ @FieldExpressionValidator(message = "Default message", key = "i18n.key", shortCircuit = true, expression = "an OGNL expression") ]]></script> </div></div></div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/file-upload-interceptor.html ---------------------------------------------------------------------- diff --git a/content/docs/file-upload-interceptor.html b/content/docs/file-upload-interceptor.html index b73a365..89c23cf 100644 --- a/content/docs/file-upload-interceptor.html +++ b/content/docs/file-upload-interceptor.html @@ -186,7 +186,7 @@ are supported and which are not. <h2 id="FileUploadInterceptor-Examples">Examples</h2> <p><strong>Example action mapping:</strong></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <action name="doUpload" class="com.example.UploadAction"> <interceptor-ref name="fileUpload"/> <interceptor-ref name="basicStack"/> @@ -199,7 +199,7 @@ are supported and which are not. <p><strong>Example JSP form tags:</strong></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <s:form action="doUpload" method="post" enctype="multipart/form-data"> <s:file name="upload" label="File"/> <s:submit/> @@ -211,7 +211,7 @@ You must set the encoding to <code>multipart/form-data</code> in the form where </p> <p><strong>Example Action class:</strong></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ package com.example; import java.io.File; @@ -244,7 +244,7 @@ You must set the encoding to <code>multipart/form-data</code> in the form where <p><strong>Setting parameters example:</strong></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"> +<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> <interceptor-ref name="fileUpload"> <param name="allowedTypes"> image/png,image/gif,image/jpeg http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/file-upload.html ---------------------------------------------------------------------- diff --git a/content/docs/file-upload.html b/content/docs/file-upload.html index bad3f45..c67eefc 100644 --- a/content/docs/file-upload.html +++ b/content/docs/file-upload.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,19 +125,7 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><p>The Struts 2 framework provides built-in support for processing file uploads that conform to <a shape="rect" class="external-link" href="http://www.ietf.org/rfc/rfc1867.txt" rel="nofollow">RFC 1867</a>, "Form-based File Upload in HTML". When correctly configured the framework will pass uploaded file(s) into your Action class. Support for individual and multiple file uploads are provided. When a file is uploaded it will typically be stored in a temporary directory. Uploaded files should be processed or moved by your Action class to ensure the data is not lost. Be aware that servers may have a security policy in place that prohibits you from writing to directories other than the temporary directory and the directories that belong to your web application.</p><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1499928483092 {padding: 0px;} -div.rbtoc1499928483092 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1499928483092 li {margin-left: 0px;padding-left: 0px;} - -/*]]>*/</style></p><div class="toc-macro rbtoc1499928483092"> -<ul class="toc-indentation"><li><a shape="rect" href="#FileUpload-Dependencies">Dependencies</a></li><li><a shape="rect" href="#FileUpload-BasicUsage">Basic Usage</a></li><li><a shape="rect" href="#FileUpload-UploadingMultipleFiles">Uploading Multiple Files</a> -<ul class="toc-indentation"><li><a shape="rect" href="#FileUpload-UploadingMultipleFilesusingArrays">Uploading Multiple Files using Arrays</a></li><li><a shape="rect" href="#FileUpload-UploadingMultipleFilesusingLists">Uploading Multiple Files using Lists</a></li></ul> -</li><li><a shape="rect" href="#FileUpload-AdvancedConfiguration">Advanced Configuration</a> -<ul class="toc-indentation"><li><a shape="rect" href="#FileUpload-FileSizeLimits">File Size Limits</a></li><li><a shape="rect" href="#FileUpload-FileTypes">File Types</a></li><li><a shape="rect" href="#FileUpload-ErrorMessages">Error Messages</a></li><li><a shape="rect" href="#FileUpload-TemporaryDirectories">Temporary Directories</a></li><li><a shape="rect" href="#FileUpload-AlternateLibraries">Alternate Libraries</a></li><li><a shape="rect" href="#FileUpload-Requestvalidation">Request validation</a></li><li><a shape="rect" href="#FileUpload-Disablingfileuploadsupport">Disabling file upload support</a></li></ul> -</li></ul> -</div><h2 id="FileUpload-Dependencies">Dependencies</h2><p>The Struts 2 framework leverages add-on libraries to handle the parsing of uploaded files. These libraries are not included in the Struts distribution, you must add them into your project. The libraries needed are:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Library</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>URL</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Struts 2.0.x</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Struts 2.1.x</p></th><th colspan="1" rowspan="1" class="confluenceTh">Struts 2.5.x</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Commons-FileUpload</p></td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://commons.apache.org/fileupload/">http://commons.apache.org/fileupload/</a></td><td colspan="1" rowspan="1" class="confluenc eTd"><p>1.1.1</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.2.1</p></td><td colspan="1" rowspan="1" class="confluenceTd">1.3.2</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Commons-IO</p></td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://commons.apache.org/io/">http://commons.apache.org/io/</a></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.0</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.3.2</p></td><td colspan="1" rowspan="1" class="confluenceTd">2.4</td></tr></tbody></table></div><p>If you are using Maven then you can add these libraries as dependencies in your project's pom.xml.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Struts 2.0.x File Upload Dependencies</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency> + <div id="ConfluenceContent"><p>The Struts 2 framework provides built-in support for processing file uploads that conform to <a shape="rect" class="external-link" href="http://www.ietf.org/rfc/rfc1867.txt" rel="nofollow">RFC 1867</a>, "Form-based File Upload in HTML". When correctly configured the framework will pass uploaded file(s) into your Action class. Support for individual and multiple file uploads are provided. When a file is uploaded it will typically be stored in a temporary directory. Uploaded files should be processed or moved by your Action class to ensure the data is not lost. Be aware that servers may have a security policy in place that prohibits you from writing to directories other than the temporary directory and the directories that belong to your web application.</p><p><parameter ac:name="minLevel">2</parameter></p><h2 id="FileUpload-Dependencies">Dependencies</h2><p>The Struts 2 framework leverages add-on libraries to handle the parsing of uploaded f iles. These libraries are not included in the Struts distribution, you must add them into your project. The libraries needed are:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Library</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>URL</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Struts 2.0.x</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Struts 2.1.x</p></th><th colspan="1" rowspan="1" class="confluenceTh">Struts 2.5.x</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Commons-FileUpload</p></td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://commons.apache.org/fileupload/">http://commons.apache.org/fileupload/</a></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.1.1</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.2.1</p></td><td colspan="1" rowspan="1" class="confluenceTd">1.3.2</ td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Commons-IO</p></td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://commons.apache.org/io/">http://commons.apache.org/io/</a></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.0</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1.3.2</p></td><td colspan="1" rowspan="1" class="confluenceTd">2.4</td></tr></tbody></table></div><p>If you are using Maven then you can add these libraries as dependencies in your project's pom.xml.</p><parameter ac:name="lang">xml</parameter><parameter ac:name="title">Struts 2.0.x File Upload Dependencies</parameter><plain-text-body><dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.1.1</version> @@ -161,9 +135,7 @@ div.rbtoc1499928483092 li {margin-left: 0px;padding-left: 0px;} <artifactId>commons-io</artifactId> <version>1.0</version> </dependency> -</pre> -</div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Struts 2.1.x File Upload Dependencies</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency> +</plain-text-body><parameter ac:name="lang">xml</parameter><parameter ac:name="title">Struts 2.1.x File Upload Dependencies</parameter><plain-text-body><dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.2.1</version> @@ -173,21 +145,10 @@ div.rbtoc1499928483092 li {margin-left: 0px;padding-left: 0px;} <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency> -</pre> -</div></div><h2 id="FileUpload-BasicUsage">Basic Usage</h2><p>The <code>org.apache.struts2.interceptor.FileUploadInterceptor</code> class is included as part of the <code>defaultStack</code>. As long as the required libraries are added to your project you will be able to take advantage of of the Struts 2 fileUpload capability. Configure an Action mapping for your Action class as you typically would.</p><p><strong>Example action mapping:</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><action name="doUpload" class="com.example.UploadAction"> +</plain-text-body><h2 id="FileUpload-BasicUsage">Basic Usage</h2><p>The <code>org.apache.struts2.interceptor.FileUploadInterceptor</code> class is included as part of the <code>defaultStack</code>. As long as the required libraries are added to your project you will be able to take advantage of of the Struts 2 fileUpload capability. Configure an Action mapping for your Action class as you typically would.</p><p><strong>Example action mapping:</strong></p><parameter ac:name="lang">xml</parameter><plain-text-body><action name="doUpload" class="com.example.UploadAction"> <result name="success">good_result.jsp</result> </action> -</pre> -</div></div><p>A form must be create with a form field of type file, <code><INPUT type="file" name="upload"></code>. The form used to upload the file must have its encoding type set to multipart/form-data, <code><FORM action="doUpload" enctype="multipart/form-data" method="post"></code>. The standard procedure for adding these elements is by using the Struts 2 tag libraries as shown in the following example:</p><p><strong>Example JSP form tags:</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<s:form action="doUpload" method="post" enctype="multipart/form-data"> - <s:file name="upload" label="File"/> - <s:submit/> -</s:form> -]]></script> -</div></div>The fileUpload interceptor will use setter injection to insert the uploaded file and related data into your Action class. For a form field named <strong>upload</strong> you would provide the three setter methods shown in the following example:<p><strong>Example Action class:</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">package com.example; +</plain-text-body><p>A form must be create with a form field of type file, <code><INPUT type="file" name="upload"></code>. The form used to upload the file must have its encoding type set to multipart/form-data, <code><FORM action="doUpload" enctype="multipart/form-data" method="post"></code>. The standard procedure for adding these elements is by using the Struts 2 tag libraries as shown in the following example:</p><p><strong>Example JSP form tags:</strong><plain-text-body>{snippet:id=example-form|lang=xml|javadoc=true|url=org.apache.struts2.interceptor.FileUploadInterceptor}</plain-text-body>The fileUpload interceptor will use setter injection to insert the uploaded file and related data into your Action class. For a form field named <strong>upload</strong> you would provide the three setter methods shown in the following example:</p><p><strong>Example Action class:</strong></p><parameter ac:name="lang">java</parameter><plain-text-body>package com.example; import java.io.File; import com.opensymphony.xwork2.ActionSupport; @@ -214,16 +175,12 @@ div.rbtoc1499928483092 li {margin-left: 0px;padding-left: 0px;} return SUCCESS; } } -</pre> -</div></div><p>The purpose of each one of these methods is described in the table below. Notice that if you have multiple file form elements with different names you would be required to have another corresponding set of these methods for each file uploaded.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method Signature</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>setX(File file)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The file that contains the content of the uploaded file. This is a temporary file and <code>file.getName()</code> will not return the original name of the file</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>setXContentType(String contentType)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The mime type of the uploaded file</p></td></tr><tr><td co lspan="1" rowspan="1" class="confluenceTd"><p>setXFileName(String fileName)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The actual file name of the uploaded file (not the HTML name)</p></td></tr></tbody></table></div><h2 id="FileUpload-UploadingMultipleFiles">Uploading Multiple Files</h2><p>As mentioned in the previous section one technique for uploading multiple files would be to simply have multiple form input elements of type file all with different names. This would require a number of setter methods that was equal to 3 times the number of files being uploaded. Another option is to use Arrays or java.util.Lists. The following examples are taken from the Showcase example application that is part sample applications you can download at <a shape="rect" class="external-link" href="http://struts.apache.org/download.cgi">http://struts.apache.org/download.cgi</a>. For the Action mapping details see <code>struts-fileupload.xml</code> in the sample application download.</ p><h3 id="FileUpload-UploadingMultipleFilesusingArrays">Uploading Multiple Files using Arrays</h3><p><strong>multipleUploadUsingArray.jsp</strong> Notice all file input types have the same name.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: html; gutter: false; theme: Default" style="font-size:12px;"><s:form action="doMultipleUploadUsingArray" method="POST" enctype="multipart/form-data"> +</plain-text-body><p>The purpose of each one of these methods is described in the table below. Notice that if you have multiple file form elements with different names you would be required to have another corresponding set of these methods for each file uploaded.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method Signature</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>setX(File file)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The file that contains the content of the uploaded file. This is a temporary file and <code>file.getName()</code> will not return the original name of the file</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>setXContentType(String contentType)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The mime type of the uploaded file</p></td></tr><tr> <td colspan="1" rowspan="1" class="confluenceTd"><p>setXFileName(String fileName)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The actual file name of the uploaded file (not the HTML name)</p></td></tr></tbody></table></div><h2 id="FileUpload-UploadingMultipleFiles">Uploading Multiple Files</h2><p>As mentioned in the previous section one technique for uploading multiple files would be to simply have multiple form input elements of type file all with different names. This would require a number of setter methods that was equal to 3 times the number of files being uploaded. Another option is to use Arrays or java.util.Lists. The following examples are taken from the Showcase example application that is part sample applications you can download at <a shape="rect" class="external-link" href="http://struts.apache.org/download.cgi">http://struts.apache.org/download.cgi</a>. For the Action mapping details see <code>struts-fileupload.xml</code> in the sample application downl oad.</p><h3 id="FileUpload-UploadingMultipleFilesusingArrays">Uploading Multiple Files using Arrays</h3><p><strong>multipleUploadUsingArray.jsp</strong> Notice all file input types have the same name.</p><parameter ac:name="">html</parameter><plain-text-body><s:form action="doMultipleUploadUsingArray" method="POST" enctype="multipart/form-data"> <s:file label="File (1)" name="upload" /> <s:file label="File (2)" name="upload" /> <s:file label="FIle (3)" name="upload" /> <s:submit cssClass="btn btn-primary"/> -</s:form></pre> -</div></div><p><strong>MultipleFileUploadUsingArrayAction.java</strong></p><p> </p><p><strong><br clear="none"></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class MultipleFileUploadUsingArrayAction extends ActionSupport { +</s:form></plain-text-body><p><strong>MultipleFileUploadUsingArrayAction.java</strong></p><p> </p><p><strong><br clear="none"></strong></p><parameter ac:name="">java</parameter><plain-text-body>public class MultipleFileUploadUsingArrayAction extends ActionSupport { private File[] uploads; private String[] uploadFileNames; private String[] uploadContentTypes; @@ -263,16 +220,12 @@ div.rbtoc1499928483092 li {margin-left: 0px;padding-left: 0px;} public void setUploadContentType(String[] uploadContentType) { this.uploadContentTypes = uploadContentType; } -}</pre> -</div></div><p> </p><h3 id="FileUpload-UploadingMultipleFilesusingLists">Uploading Multiple Files using Lists</h3><p><strong>multipleUploadUsingList.jsp</strong> Notice all file input types have the same name.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><s:form action="doMultipleUploadUsingList" method="POST" enctype="multipart/form-data"> +}</plain-text-body><p> </p><h3 id="FileUpload-UploadingMultipleFilesusingLists">Uploading Multiple Files using Lists</h3><p><strong>multipleUploadUsingList.jsp</strong> Notice all file input types have the same name.</p><parameter ac:name="">xml</parameter><plain-text-body><s:form action="doMultipleUploadUsingList" method="POST" enctype="multipart/form-data"> <s:file label="File (1)" name="upload" /> <s:file label="File (2)" name="upload" /> <s:file label="FIle (3)" name="upload" /> <s:submit cssClass="btn btn-primary"/> -</s:form></pre> -</div></div><p><strong>MultipleFileUploadUsingListAction.java</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class MultipleFileUploadUsingListAction extends ActionSupport { +</s:form></plain-text-body><p><strong>MultipleFileUploadUsingListAction.java</strong></p><parameter ac:name="">java</parameter><plain-text-body>public class MultipleFileUploadUsingListAction extends ActionSupport { private List<File> uploads = new ArrayList<File>(); private List<String> uploadFileNames = new ArrayList<String>(); private List<String> uploadContentTypes = new ArrayList<String>(); @@ -312,14 +265,10 @@ div.rbtoc1499928483092 li {margin-left: 0px;padding-left: 0px;} System.out.println("\n\n"); return SUCCESS; } -}</pre> -</div></div><h2 id="FileUpload-AdvancedConfiguration">Advanced Configuration</h2><p>The Struts 2 <code>default.properties</code> file defines several settings that affect the behavior of file uploading. You may find in necessary to change these values. The names and default values are:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: plain; gutter: false; theme: Default" style="font-size:12px;">struts.multipart.parser=jakarta +}</plain-text-body><h2 id="FileUpload-AdvancedConfiguration">Advanced Configuration</h2><p>The Struts 2 <code>default.properties</code> file defines several settings that affect the behavior of file uploading. You may find in necessary to change these values. The names and default values are:</p><parameter ac:name="lang">none</parameter><plain-text-body>struts.multipart.parser=jakarta struts.multipart.saveDir= struts.multipart.maxSize=2097152 -</pre> -</div></div><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Please remember that the <strong>struts.multipart.maxSize</strong> is the size limit of the whole request, which means when you uploading multiple files, the sum of their size must be below the <strong>struts.multipart.maxSize</strong>!</p></div></div><p>In order to change theses settings you define a constant in your applications <code>struts.xml</code> file like so:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><?xml version="1.0" encoding="UTF-8"?> +</plain-text-body><rich-text-body><p>Please remember that the <strong>struts.multipart.maxSize</strong> is the size limit of the whole request, which means when you uploading multiple files, the sum of their size must be below the <strong>struts.multipart.maxSize</strong>!</p></rich-text-body><p>In order to change theses settings you define a constant in your applications <code>struts.xml</code> file like so:</p><parameter ac:name="lang">xml</parameter><plain-text-body><?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> @@ -327,9 +276,7 @@ struts.multipart.maxSize=2097152 <constant name="struts.multipart.maxSize" value="1000000" /> ... </struts> -</pre> -</div></div><p>Additionally the <code>fileUpload</code> interceptor has settings that can be put in place for individual action mappings by customizing your interceptor stack.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><action name="doUpload" class="com.example.UploadAction"> +</plain-text-body><p>Additionally the <code>fileUpload</code> interceptor has settings that can be put in place for individual action mappings by customizing your interceptor stack.</p><parameter ac:name="lang">xml</parameter><plain-text-body><action name="doUpload" class="com.example.UploadAction"> <interceptor-ref name="basicStack"/> <interceptor-ref name="fileUpload"> <param name="allowedTypes">text/plain</param> @@ -339,9 +286,7 @@ struts.multipart.maxSize=2097152 <result name="success">good_result.jsp</result> </action> -</pre> -</div></div><h3 id="FileUpload-FileSizeLimits">File Size Limits</h3><p>There are two separate file size limits. First is <code>struts.multipart.maxSize</code> which comes from the Struts 2 <code>default.properties</code> file. This setting exists for security reasons to prohibit a malicious user from uploading extremely large files to file up your servers disk space. This setting defaults to approximately 2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need the framework to receive. If you are uploading more than one file on a form the <code>struts.multipart.maxSize</code> applies to the combined total, not the individual file sizes. The other setting, <code>maximumSize</code>, is an interceptor setting that is used to ensure a particular Action does not receive a file that is too large. Notice the locations of both settings in the following example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><?xml version="1.0" encoding="UTF-8"?> +</plain-text-body><h3 id="FileUpload-FileSizeLimits">File Size Limits</h3><p>There are two separate file size limits. First is <code>struts.multipart.maxSize</code> which comes from the Struts 2 <code>default.properties</code> file. This setting exists for security reasons to prohibit a malicious user from uploading extremely large files to file up your servers disk space. This setting defaults to approximately 2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need the framework to receive. If you are uploading more than one file on a form the <code>struts.multipart.maxSize</code> applies to the combined total, not the individual file sizes. The other setting, <code>maximumSize</code>, is an interceptor setting that is used to ensure a particular Action does not receive a file that is too large. Notice the locations of both settings in the following example:</p><parameter ac:name="lang">xml</parameter><plain-text-body><?xml version="1.0" enco ding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> @@ -359,9 +304,7 @@ struts.multipart.maxSize=2097152 <result name="success">good_result.jsp</result> </action> </struts> -</pre> -</div></div><h3 id="FileUpload-FileTypes">File Types</h3><p>There are two ways to limit the uploaded file type, declaratively and programmatically. To declaratively limit the file type a comma separated list of allowedTypes can be specified as a fileUpload interceptor param as shown in the following example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><action name="doUpload" class="com.example.UploadAction"> +</plain-text-body><h3 id="FileUpload-FileTypes">File Types</h3><p>There are two ways to limit the uploaded file type, declaratively and programmatically. To declaratively limit the file type a comma separated list of allowedTypes can be specified as a fileUpload interceptor param as shown in the following example:</p><parameter ac:name="lang">xml</parameter><plain-text-body><action name="doUpload" class="com.example.UploadAction"> <interceptor-ref name="basicStack"/> <interceptor-ref name="fileUpload"> <param name="allowedTypes">image/jpeg,image/gif</param> @@ -371,12 +314,7 @@ struts.multipart.maxSize=2097152 <result name="success">good_result.jsp</result> </action> -</pre> -</div></div><p>When the uploaded file type does not match one of the MIME types specified a field error will be created as described in the next section entitled Error Messages. Programmatically limiting the file type means using the information passed in to your Action class via the <code>setXContentType(String contentType)</code> method. The benefit to this type of approach would be that it's more flexible and no interceptor configuration would be needed if file sizes are keep under 2 megs.</p><h3 id="FileUpload-ErrorMessages">Error Messages</h3><p>If an error occurs several field errors will be added assuming that the action implements <code>com.opensymphony.xwork2.ValidationAware</code> or extends <code>com.opensymphony.xwork2.ActionSupport</code>. These error messages are based on several i18n values stored in struts-messages.properties, a default i18n file processed for all i18n requests. You can override the text of these messages by providing text for the following keys:</p> <div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Error Key</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.error.uploading</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>A general error that occurs when the file could not be uploaded</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.error.file.too.large</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when the uploaded file is too large as specified by maximumSize.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.error.content.type.not.allowed</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when the uploaded file does not match the expected content types specified</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts. messages.error.file.extension.not.allowed</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when uploaded file has disallowed extension</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.upload.error.SizeLimitExceededException</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when the upload request (as a whole) exceed configured <strong>struts.multipart.maxSize</strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.upload.error.<Exception class SimpleName></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when any other exception took place during file upload process</p></td></tr></tbody></table></div><h3 id="FileUpload-TemporaryDirectories">Temporary Directories</h3><p>All uploaded files are saved to a temporary directory by the framework before being passed in to an Action. Depending on the allowed file sizes it may be necessary to have the framework s tore these temporary files in an alternate location. To do this change <code>struts.multipart.saveDir</code> to the directory where the uploaded files will be placed. If this property is not set it defaults to <code>javax.servlet.context.tempdir</code>. Keep in mind that on some operating systems, like Solaris, <code>/tmp</code> is memory based and files stored in that directory would consume an amount of RAM approximately equal to the size of the uploaded file.</p><h3 id="FileUpload-AlternateLibraries">Alternate Libraries</h3><p>The <code>struts.multipart.parser</code> used by the fileUpload interceptor to handle HTTP POST requests, encoded using the MIME-type multipart/form-data, can be changed out. Currently there are two choices, jakarta and pell. The jakarta parser is a standard part of the Struts 2 framework needing only its required libraries added to a project. The pell parser uses Jason Pell's multipart parser instead of the Commons-FileUpload library. The pell parser is a Struts 2 plugin, for more details see: <a shape="rect" href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=33353">pell multipart plugin</a>. There was a third alternative, cos, but it was removed due to licensing incompatibilities.</p><p>As from Struts version 2.3.18 a new implementation of <code>MultiPartRequest</code> was added - <code>JakartaStreamMultiPartRequest</code>. It can be used to handle large files, see <a shape="rect" class="external-link" href="https://issues.apache.org/jira/browse/WW-3025">WW-3025</a> for more details, but you can simple set</p><pre><constant name="struts.multipart.parser" value="jakarta-stream" /></pre><p>in struts.xml to start using it.</p><h3 id="FileUpload-Requestvalidation">Request validation</h3><p>The <code>struts.multipart.validationRegex</code> is used to define a RegEx to be used to validate if the incoming request is a multipart request. The request must use the <code>POST</code> metho d and match the RegEx, by default the RegEx is defined as follow:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">^multipart\\/form-data(; boundary=[a-zA-Z0-9]{1,70})?</pre> -</div></div><p>Please read <a shape="rect" class="external-link" href="https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html" rel="nofollow">RFC1341</a> the <strong>Multipart section</strong> for more details, existing Struts <code>Multipart</code> parsers support only <code>multipart/form-data</code> content type. This option is available since Struts 2.3.11.</p><h3 id="FileUpload-Disablingfileuploadsupport">Disabling file upload support</h3><p>You can alternatively disable the whole file upload mechanism defining a constant in <code>struts.xml</code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><constant name="struts.multipart.enabled" value="false"/></pre> -</div></div><p>With this constant in place, Struts will ignore a <code>Content-Type</code> header and will treat each request as an ordinary http request. This option is available since Struts 2.3.11.</p><p> </p></div> +</plain-text-body><p>When the uploaded file type does not match one of the MIME types specified a field error will be created as described in the next section entitled Error Messages. Programmatically limiting the file type means using the information passed in to your Action class via the <code>setXContentType(String contentType)</code> method. The benefit to this type of approach would be that it's more flexible and no interceptor configuration would be needed if file sizes are keep under 2 megs.</p><h3 id="FileUpload-ErrorMessages">Error Messages</h3><p>If an error occurs several field errors will be added assuming that the action implements <code>com.opensymphony.xwork2.ValidationAware</code> or extends <code>com.opensymphony.xwork2.ActionSupport</code>. These error messages are based on several i18n values stored in struts-messages.properties, a default i18n file processed for all i18n requests. You can override the text of these messages by providing text for the following key s:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Error Key</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.error.uploading</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>A general error that occurs when the file could not be uploaded</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.error.file.too.large</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when the uploaded file is too large as specified by maximumSize.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.error.content.type.not.allowed</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when the uploaded file does not match the expected content types specified</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>s truts.messages.error.file.extension.not.allowed</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when uploaded file has disallowed extension</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.upload.error.SizeLimitExceededException</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when the upload request (as a whole) exceed configured <strong>struts.multipart.maxSize</strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>struts.messages.upload.error.<Exception class SimpleName></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Occurs when any other exception took place during file upload process</p></td></tr></tbody></table></div><h3 id="FileUpload-TemporaryDirectories">Temporary Directories</h3><p>All uploaded files are saved to a temporary directory by the framework before being passed in to an Action. Depending on the allowed file sizes it may be necessary to have the frame work store these temporary files in an alternate location. To do this change <code>struts.multipart.saveDir</code> to the directory where the uploaded files will be placed. If this property is not set it defaults to <code>javax.servlet.context.tempdir</code>. Keep in mind that on some operating systems, like Solaris, <code>/tmp</code> is memory based and files stored in that directory would consume an amount of RAM approximately equal to the size of the uploaded file.</p><h3 id="FileUpload-AlternateLibraries">Alternate Libraries</h3><p>The <code>struts.multipart.parser</code> used by the fileUpload interceptor to handle HTTP POST requests, encoded using the MIME-type multipart/form-data, can be changed out. Currently there are two choices, jakarta and pell. The jakarta parser is a standard part of the Struts 2 framework needing only its required libraries added to a project. The pell parser uses Jason Pell's multipart parser instead of the Commons-FileUpload library. The pell parser is a Struts 2 plugin, for more details see: <a shape="rect" href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=33353">pell multipart plugin</a>. There was a third alternative, cos, but it was removed due to licensing incompatibilities.</p><p>As from Struts version 2.3.18 a new implementation of <code>MultiPartRequest</code> was added - <code>JakartaStreamMultiPartRequest</code>. It can be used to handle large files, see <a shape="rect" class="external-link" href="https://issues.apache.org/jira/browse/WW-3025">WW-3025</a> for more details, but you can simple set</p><pre><constant name="struts.multipart.parser" value="jakarta-stream" /></pre><p>in struts.xml to start using it.</p><h3 id="FileUpload-Requestvalidation">Request validation</h3><p>The <code>struts.multipart.validationRegex</code> is used to define a RegEx to be used to validate if the incoming request is a multipart request. The request must use the <code>POST</code>  ;method and match the RegEx, by default the RegEx is defined as follow:</p><plain-text-body>^multipart\\/form-data(; boundary=[a-zA-Z0-9]{1,70})?</plain-text-body><p>Please read <a shape="rect" class="external-link" href="https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html" rel="nofollow">RFC1341</a> the <strong>Multipart section</strong> for more details, existing Struts <code>Multipart</code> parsers support only <code>multipart/form-data</code> content type. This option is available since Struts 2.3.11.</p><h3 id="FileUpload-Disablingfileuploadsupport">Disabling file upload support</h3><p>You can alternatively disable the whole file upload mechanism defining a constant in <code>struts.xml</code>:</p><parameter ac:name="">xml</parameter><plain-text-body><constant name="struts.multipart.enabled" value="false"/></plain-text-body><p>With this constant in place, Struts will ignore a <code>Content-Type</code> header and will treat each request as an ordinary http request. This option is available since Struts 2.3.11.</p><p> </p></div> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/file.html ---------------------------------------------------------------------- diff --git a/content/docs/file.html b/content/docs/file.html index af0d06c..0ceaddd 100644 --- a/content/docs/file.html +++ b/content/docs/file.html @@ -152,7 +152,7 @@ under the License. <h2 id="file-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <s:file name="anUploadFile" accept="text/*" /> <s:file name="anohterUploadFIle" accept="text/html,text/plain" /> ]]></script> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/form-tags.html ---------------------------------------------------------------------- diff --git a/content/docs/form-tags.html b/content/docs/form-tags.html index 19a0525..5db587a 100644 --- a/content/docs/form-tags.html +++ b/content/docs/form-tags.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,116 +125,15 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Please make sure you have read the <a shape="rect" href="tag-syntax.html">Tag Syntax</a> document and understand how tag attribute syntax works.</p></div></div><p>Within the form tags, there are two classes of tags: the form tag itself, and all other tags, which make up the individual form elements. The behavior of the form tag is different than the elements enclosed within it.</p><h2 id="FormTags-FormTagThemes">Form Tag Themes</h2><p>As explained in <a shape="rect" href="themes-and-templates.html">Themes and Templates</a>, the HTML Tags (which includes Form Tags) are all driven by templates. Templates are grouped together to create themes. The framework bundles three themes in the distribution.</p><div class="table-wrap" ><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" >class="confluenceTh"><p>simple</p></th><td colspan="1" rowspan="1" >class="confluenceTd"><p>Sometimes <em>too</em> simple</p></td></tr><tr><th >colspan="1" rowspan="1" class="confluenceTh"><p>xhtml</p></th><td colspan="1" >rowspan="1" class="confluenceTd"><p>Extends simple</p></td><td colspan="1" >rowspan="1" class="confluenceTd"><p>(default)</p></td></tr><tr><th >colspan="1" rowspan="1" class="confluenceTh"><p>ajax</p></th><td colspan="1" >rowspan="1" class="confluenceTd"><p>Extends >xhtml</p></td></tr></tbody></table></div><p>The predefined themes can be used >"as is" or customized.</p><div class="confluence-information-macro >confluence-information-macro-tip"><p class="title">xhtml layout</p><span >class="aui-icon aui-icon-small aui-iconfont-approve >confluence-information-macro-icon"></span><div >class="confluence-information-macro-body"><p>The xhtml theme renders out a >two-column table. If a different layout is needed, do <em>not</em> write your own HTML. Create a new theme or utilize the simple theme.</p></div></div><h3 id="FormTags-Simplethemecaveats">Simple theme caveats</h3><p>The downside of using the simple theme is that it doesn't support as many of the attributes that the other themes do. For example, the <code>label</code> attribute does nothing in the simple theme, and the automatic display of error messages is not supported.</p><h2 id="FormTags-CommonAttributes">Common Attributes</h2><p>All the form tags extend the UIBean class. This base class provides a set of common attributes, that can be grouped in to three categories: <code>templated-related</code>, javascript-related, and general attributes. The individual attributes are documented on each tag's reference page.</p><p>In addition to the common attributes, a special attribute exists for all form element tags: <code>form</code> (${parameters.form}). The <code>form</code> property represents the attributes used to render the form tag , such as the form's id. In a template, the form's ID can be found by calling ${parameters.form.id}.</p><h2 id="FormTags-Template-RelatedAttributes">Template-Related Attributes</h2> -<p><table border="1" summary=""><thead><tr><td colspan="1" rowspan="1">Attribute</td><td colspan="1" rowspan="1">Theme</td><td colspan="1" rowspan="1">Data Types</td><td colspan="1" rowspan="1">Description</td></tr></thead><tbody><tr><td colspan="1" rowspan="1">templateDir</td><td colspan="1" rowspan="1">n/a</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define the template directory</td></tr><tr><td colspan="1" rowspan="1">theme</td><td colspan="1" rowspan="1">n/a</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define the theme name</td></tr><tr><td colspan="1" rowspan="1">template</td><td colspan="1" rowspan="1">n/a</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define the template name</td></tr><tr><td colspan="1" rowspan="1">themeExpansionToken</td><td colspan="1" rowspan="1">n/a</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">special token (defined with struts.ui.theme.expansion.token) used to search for template in parent theme - (don't use it separately!)</td></tr><tr><td colspan="1" rowspan="1">expandTheme</td><td colspan="1" rowspan="1">n/a</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">concatenation of themeExpansionToken and theme which tells internal template loader mechanism - to try load template from current theme and then from parent theme (and parent theme, and so on) - when used with <#include/> directive</td></tr></tbody></table></p> -<h2 id="FormTags-Javascript-RelatedAttributes">Javascript-Related Attributes</h2> -<p><table border="1" summary=""><thead><tr><td colspan="1" rowspan="1">Attribute</td><td colspan="1" rowspan="1">Theme</td><td colspan="1" rowspan="1">Data Types</td><td colspan="1" rowspan="1">Description</td></tr></thead><tbody><tr><td colspan="1" rowspan="1">onclick</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onclick attribute</td></tr><tr><td colspan="1" rowspan="1">ondblclick</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript ondbclick attribute</td></tr><tr><td colspan="1" rowspan="1">onmousedown</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onmousedown attribute</td></tr><tr><td colspan="1" rowspan="1">onmouseup</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onmouse up attribute</td></tr><tr><td colspan="1" rowspan="1">onmouseover</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onmouseover attribute</td></tr><tr><td colspan="1" rowspan="1">onmouseout</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onmouseout attribute</td></tr><tr><td colspan="1" rowspan="1">onfocus</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onfocus attribute</td></tr><tr><td colspan="1" rowspan="1">onblur</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onblur attribute</td></tr><tr><td colspan="1" rowspan="1">onkeypress</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onkeypress attribute</ td></tr><tr><td colspan="1" rowspan="1">onkeyup</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onkeyup attribute</td></tr><tr><td colspan="1" rowspan="1">onkeydown</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onkeydown attribute</td></tr><tr><td colspan="1" rowspan="1">onselect</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onselect attribute</td></tr><tr><td colspan="1" rowspan="1">onchange</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">html javascript onchange attribute</td></tr></tbody></table></p> -<h2 id="FormTags-TooltipRelatedAttributes">Tooltip Related Attributes</h2> -<p><table border="1" summary=""><tr><td colspan="1" rowspan="1">Attribute</td><td colspan="1" rowspan="1">Data Type</td><td colspan="1" rowspan="1">Default</td><td colspan="1" rowspan="1">Description</td></tr><tr><td colspan="1" rowspan="1">tooltip</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">none</td><td colspan="1" rowspan="1">Set the tooltip of this particular component</td></tr><tr><td colspan="1" rowspan="1">jsTooltipEnabled</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">false</td><td colspan="1" rowspan="1">Enable js tooltip rendering</td></tr><tr><td colspan="1" rowspan="1">tooltipIcon</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">/struts/static/tooltip/tooltip.gif</td><td colspan="1" rowspan="1">The url to the tooltip icon</td></tr><tr><td colspan="1" rowspan="1">tooltipDelay</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">500</td><td colspan="1" rowspan="1">Tooltip shows up aft er the specified timeout (miliseconds). A behavior similar to that of OS based tooltips.</td></tr><tr><td colspan="1" rowspan="1">key</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">The name of the property this input field represents. This will auto populate the name, label, and value</td></tr></table></p> -<h2 id="FormTags-GeneralAttributes">General Attributes</h2> -<p><table border="1" summary=""><thead><tr><td colspan="1" rowspan="1">Attribute</td><td colspan="1" rowspan="1">Theme</td><td colspan="1" rowspan="1">Data Types</td><td colspan="1" rowspan="1">Description</td></tr></thead><tbody><tr><td colspan="1" rowspan="1">cssClass</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define html class attribute</td></tr><tr><td colspan="1" rowspan="1">cssStyle</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define html style attribute</td></tr><tr><td colspan="1" rowspan="1">cssErrorClass</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">error class attribute</td></tr><tr><td colspan="1" rowspan="1">cssErrorStyle</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">error style attribute</td></tr><tr><td colspan=" 1" rowspan="1">title</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define html title attribute</td></tr><tr><td colspan="1" rowspan="1">disabled</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define html disabled attribute</td></tr><tr><td colspan="1" rowspan="1">label</td><td colspan="1" rowspan="1">xhtml</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define label of form element</td></tr><tr><td colspan="1" rowspan="1">labelPosition</td><td colspan="1" rowspan="1">xhtml</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define label position of form element (top/left), default to left</td></tr><tr><td colspan="1" rowspan="1">requiredPosition</td><td colspan="1" rowspan="1">xhtml</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define required label position of form element (left/right), defa ult to right</td></tr><tr><td colspan="1" rowspan="1">errorPosition</td><td colspan="1" rowspan="1">xhtml</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define error position of form element (top|bottom), default to top</td></tr><tr><td colspan="1" rowspan="1">name</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">Form Element's field name mapping</td></tr><tr><td colspan="1" rowspan="1">requiredLabel</td><td colspan="1" rowspan="1">xhtml</td><td colspan="1" rowspan="1">Boolean</td><td colspan="1" rowspan="1">add * to label (true to add false otherwise)</td></tr><tr><td colspan="1" rowspan="1">tabIndex</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">String</td><td colspan="1" rowspan="1">define html tabindex attribute</td></tr><tr><td colspan="1" rowspan="1">value</td><td colspan="1" rowspan="1">simple</td><td colspan="1" rowspan="1">Object</td><td colspan="1" rowspan="1">defin e value of form element</td></tr></tbody></table></p> -<div class="confluence-information-macro confluence-information-macro-note"><p class="title">When some attributes don't apply</p><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Some tag attributes may not be utilized by all, or any, of the templates. For example, the form tag supports the <code>tabindex</code> attribute, but none of the themes render the <code>tabindex</code>.</p></div></div><h2 id="FormTags-Value/NameRelationship">Value/Name Relationship</h2><p>In many of the tags (except for the form tag) there is a unique relationship between the <code>name</code> and <code>value</code> attributes. The <code>name</code> attribute provides the name for the tag, which in turn is used as the control attribute when the form is submitted. The value submitted is bound to the <code>name</code>. In most cases, the <code>name</code> maps to a simple JavaBean property, such as "postalCode" . On a submit, the value would be set to the property by calling the <code>setPostalCode</code> mutator.</p><p>Likewise, a form control could be populated by calling a JavaBean accessor, like <code>getPostalCode</code>. In the expression language, we can refer to the JavaBean property by name. An expression like "%{postalCode}" would in turn call <code>getPostalCode</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Using Expressions to populate a form for editing</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><@s.form action="updateAddress"> + <div id="ConfluenceContent"><rich-text-body><p>Please make sure you have read the <a shape="rect" href="tag-syntax.html">Tag Syntax</a> document and understand how tag attribute syntax works.</p></rich-text-body><p>Within the form tags, there are two classes of tags: the form tag itself, and all other tags, which make up the individual form elements. The behavior of the form tag is different than the elements enclosed within it.</p><h2 id="FormTags-FormTagThemes">Form Tag Themes</h2><p>As explained in <a shape="rect" href="themes-and-templates.html">Themes and Templates</a>, the HTML Tags (which includes Form Tags) are all driven by templates. Templates are grouped together to create themes. The framework bundles three themes in the distribution.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>simple</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>Sometimes <em>too</em> simple</p></td></ tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>xhtml</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>Extends simple</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>(default)</p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>ajax</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>Extends xhtml</p></td></tr></tbody></table></div><p>The predefined themes can be used "as is" or customized.</p><parameter ac:name="title">xhtml layout</parameter><rich-text-body><p>The xhtml theme renders out a two-column table. If a different layout is needed, do <em>not</em> write your own HTML. Create a new theme or utilize the simple theme.</p></rich-text-body><h3 id="FormTags-Simplethemecaveats">Simple theme caveats</h3><p>The downside of using the simple theme is that it doesn't support as many of the attributes that the other themes do. For example, the <code>label</code> attribute does nothing in the simple theme, and the automatic disp lay of error messages is not supported.</p><h2 id="FormTags-CommonAttributes">Common Attributes</h2><p>All the form tags extend the UIBean class. This base class provides a set of common attributes, that can be grouped in to three categories: <code>templated-related</code>, javascript-related, and general attributes. The individual attributes are documented on each tag's reference page.</p><p>In addition to the common attributes, a special attribute exists for all form element tags: <code>form</code> (${parameters.form}). The <code>form</code> property represents the attributes used to render the form tag, such as the form's id. In a template, the form's ID can be found by calling ${parameters.form.id}.</p><h2 id="FormTags-Template-RelatedAttributes">Template-Related Attributes</h2><plain-text-body>{snippet:id=templateRelatedAttributes|javadoc=true|url=org.apache.struts2.components.UIBean}</plain-text-body><h2 id="FormTags-Javascript-RelatedAttributes">Javascript-Related Attributes< /h2><plain-text-body>{snippet:id=javascriptRelatedAttributes|javadoc=true|url=org.apache.struts2.components.UIBean}</plain-text-body><h2 id="FormTags-TooltipRelatedAttributes">Tooltip Related Attributes</h2><plain-text-body>{snippet:id=tooltipattributes|javadoc=true|url=org.apache.struts2.components.UIBean}</plain-text-body><h2 id="FormTags-GeneralAttributes">General Attributes</h2><plain-text-body>{snippet:id=generalAttributes|javadoc=true|url=org.apache.struts2.components.UIBean}</plain-text-body><parameter ac:name="title">When some attributes don't apply</parameter><rich-text-body><p>Some tag attributes may not be utilized by all, or any, of the templates. For example, the form tag supports the <code>tabindex</code> attribute, but none of the themes render the <code>tabindex</code>.</p></rich-text-body><h2 id="FormTags-Value/NameRelationship">Value/Name Relationship</h2><p>In many of the tags (except for the form tag) there is a unique relationship between the <code>name</code> a nd <code>value</code> attributes. The <code>name</code> attribute provides the name for the tag, which in turn is used as the control attribute when the form is submitted. The value submitted is bound to the <code>name</code>. In most cases, the <code>name</code> maps to a simple JavaBean property, such as "postalCode". On a submit, the value would be set to the property by calling the <code>setPostalCode</code> mutator.</p><p>Likewise, a form control could be populated by calling a JavaBean accessor, like <code>getPostalCode</code>. In the expression language, we can refer to the JavaBean property by name. An expression like "%{postalCode}" would in turn call <code>getPostalCode</code>.</p><parameter ac:name="">xml</parameter><parameter ac:name="title">Using Expressions to populate a form for editing</parameter><plain-text-body><@s.form action="updateAddress"> <@s.textfield label="Postal Code" name="postalCode" value="%{postalCode}"/> ... </@s.form> -</pre> -</div></div><p>However, since the tags imply a relationship between the <code>name</code> and <code>value</code>, the <code>value</code> attribute is optional. If a <code>value</code> is not specified, by default, the JavaBean accessor is used instead.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Populating a form for editing, the easy way</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><@s.form action="updateAddress"> +</plain-text-body><p>However, since the tags imply a relationship between the <code>name</code> and <code>value</code>, the <code>value</code> attribute is optional. If a <code>value</code> is not specified, by default, the JavaBean accessor is used instead.</p><parameter ac:name="">xml</parameter><parameter ac:name="title">Populating a form for editing, the easy way</parameter><plain-text-body><@s.form action="updateAddress"> <@s.textfield label="Postal Code" name="postalCode"/> ... </@s.form> -</pre> -</div></div><p>While most attributes are exposed to the underlying templates as the same key as the attribute (${parameters.label}), the <code>value</code> attribute is not. Instead, it can be accessed via the <code>nameValue</code> key (${parameters.nameValue}). The <code>nameValue</code> key indicates that the value may have been generated from the <code>name</code> attribute rather than explicitly defined in the <code>value</code> attribute.</p><h2 id="FormTags-IDNameAssignment">ID Name Assignment</h2><p>All form tags automatically assign an ID to the control, but the ID can be overridden if needed.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Forms</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>The default ID is the action name. For example, "updateAddress".</p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Controls</p></th><td colspan="1" rowspan="1" class="confluenceTd"> <p>The default ID is the form's name concatenated with the tag name. For example, "updateAddress_postalCode".</p></td></tr></tbody></table></div><h2 id="FormTags-Formlabelpositionpropagation">Form labelposition propagation</h2><p>When <code>labelposition</code> attribute was defined for <code><s:form></code> tag it will be propagated to all form elements, but if form element defines its own <code>labelposition</code> it will take precedence over <code><s:form></code>'s attribute. Since 2.3.17.</p><h2 id="FormTags-RequiredAttribute">Required Attribute</h2><p>The <code>required</code> attribute on many UI tags defaults to true only if you have client-side validation enabled, and a validator is associated with that particular field.</p><h2 id="FormTags-Tooltip">Tooltip</h2><p></p><p> -<b>tooltipConfig is deprecated, use individual tooltip configuration attributes instead </b> -</p> - -<p></p><p> -Every Form UI component (in xhtml / css_xhtml or any other that extends them) can -have tooltips assigned to them. The Form component's tooltip related attribute, once -defined, will be applied to all form UI components that are created under it unless -explicitly overridden by having the Form UI component itself defined with their own tooltip attribute. -</p> - -<p></p><p> -In Example 1, the textfield will inherit the tooltipDelay and tooltipIconPath attribute from -its containing form. In other words, although it doesn't define a tooltipIconPath -attribute, it will have that attribute inherited from its containing form. -</p> - -<p></p><p> -In Example 2, the textfield will inherit both the tooltipDelay and -tooltipIconPath attribute from its containing form, but the tooltipDelay -attribute is overridden at the textfield itself. Hence, the textfield actually will -have its tooltipIcon defined as /myImages/myIcon.gif, inherited from its containing form, and -tooltipDelay defined as 5000. -</p> - -<p></p><p> -Example 3, 4 and 5 show different ways of setting the tooltip configuration attribute.<br clear="none"> -<b>Example 3:</b> Set tooltip config through the body of the param tag<br clear="none"> -<b>Example 4:</b> Set tooltip config through the value attribute of the param tag<br clear="none"> -<b>Example 5:</b> Set tooltip config through the tooltip attributes of the component tag<br clear="none"> -</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -<!-- Example 1: --> -<s:form - tooltipDelay="500" - tooltipIconPath="/myImages/myIcon.gif" .... > - .... - <s:textfield label="Customer Name" tooltip="Enter the customer name" .... /> - .... -</s:form> - -<!-- Example 2: --> -<s:form - tooltipDelay="500" - tooltipIconPath="/myImages/myIcon.gif" .... > - .... - <s:textfield label="Address" - tooltip="Enter your address" - tooltipDelay="5000" /> - .... -</s:form> - - -<-- Example 3: --> -<s:textfield - label="Customer Name" - tooltip="One of our customer Details"> - <s:param name="tooltipDelay"> - 500 - </s:param> - <s:param name="tooltipIconPath"> - /myImages/myIcon.gif - </s:param> -</s:textfield> - - -<-- Example 4: --> -<s:textfield - label="Customer Address" - tooltip="Enter The Customer Address" > - <s:param - name="tooltipDelay" - value="500" /> -</s:textfield> - - -<-- Example 5: --> -<s:textfield - label="Customer Telephone Number" - tooltip="Enter customer Telephone Number" - tooltipDelay="500" - tooltipIconPath="/myImages/myIcon.gif" /> - -]]></script> -</div></div><h2 id="FormTags-Next:">Next: <a shape="rect" href="ui-tag-reference.html">UI Tag Reference</a></h2></div> +</plain-text-body><p>While most attributes are exposed to the underlying templates as the same key as the attribute (${parameters.label}), the <code>value</code> attribute is not. Instead, it can be accessed via the <code>nameValue</code> key (${parameters.nameValue}). The <code>nameValue</code> key indicates that the value may have been generated from the <code>name</code> attribute rather than explicitly defined in the <code>value</code> attribute.</p><h2 id="FormTags-IDNameAssignment">ID Name Assignment</h2><p>All form tags automatically assign an ID to the control, but the ID can be overridden if needed.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Forms</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>The default ID is the action name. For example, "updateAddress".</p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Controls</p></th><td colspan="1" rowspan="1" class="confluen ceTd"><p>The default ID is the form's name concatenated with the tag name. For example, "updateAddress_postalCode".</p></td></tr></tbody></table></div><h2 id="FormTags-Formlabelpositionpropagation">Form labelposition propagation</h2><p>When <code>labelposition</code> attribute was defined for <code><s:form></code> tag it will be propagated to all form elements, but if form element defines its own <code>labelposition</code> it will take precedence over <code><s:form></code>'s attribute. Since 2.3.17.</p><h2 id="FormTags-RequiredAttribute">Required Attribute</h2><p>The <code>required</code> attribute on many UI tags defaults to true only if you have client-side validation enabled, and a validator is associated with that particular field.</p><h2 id="FormTags-Tooltip">Tooltip</h2><plain-text-body>{snippet:id=tooltipdescription|javadoc=true|url=org.apache.struts2.components.UIBean}</plain-text-body><plain-text-body>{snippet:id=tooltipexample|lang=xml|javad oc=true|url=org.apache.struts2.components.UIBean}</plain-text-body><h2 id="FormTags-Next:">Next: <a shape="rect" href="ui-tag-reference.html">UI Tag Reference</a></h2></div> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/form.html ---------------------------------------------------------------------- diff --git a/content/docs/form.html b/content/docs/form.html index 2a572a9..2b686f1 100644 --- a/content/docs/form.html +++ b/content/docs/form.html @@ -176,7 +176,7 @@ from it and using UrlHelper to generate the final url. <h2 id="form-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <s:form ... /> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/freemarker-result.html ---------------------------------------------------------------------- diff --git a/content/docs/freemarker-result.html b/content/docs/freemarker-result.html index 5c8a45c..c5283f9 100644 --- a/content/docs/freemarker-result.html +++ b/content/docs/freemarker-result.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,9 +125,7 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><p>Renders a view using the Freemarker template engine. The <code>FreemarkarManager</code> class configures the template loaders so that the template location can be either</p><ul style="list-style-type: square;"><li>relative to the web root folder, e.g.: <code>/WEB-INF/views/home.ftl</code></li><li>a classpath resource, e.g.: <code>/com/company/web/views/home.ftl</code></li></ul><p> </p><p>Also see <a shape="rect" href="freemarker-support.html">Freemarker Support</a>.</p><h2 id="FreeMarkerResult-Parameters">Parameters</h2><ul style="list-style-type: square;"><li><strong>location</strong> (default) - the location of the template to process.</li><li><strong>parse </strong>- true by default. If set to false, the location param will not be parsed for expressions.</li><li><strong>contentType</strong> - defaults to <code>text/html</code> unless specified.</li><li><strong>writeIfCompleted</strong> - <code>false</co de> by default, write to stream only if there isn't any error processing the template. Setting <code>template_exception_handler=rethrow</code> in <code>freemarker.properties</code> will have the same effect.</li></ul><h2 id="FreeMarkerResult-Examples">Examples</h2><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><result name="success" type="freemarker">foo.ftl</result></pre> -</div></div><p> </p><p> </p></div> + <div id="ConfluenceContent"><p>Renders a view using the Freemarker template engine. The <code>FreemarkarManager</code> class configures the template loaders so that the template location can be either</p><ul style="list-style-type: square;"><li>relative to the web root folder, e.g.: <code>/WEB-INF/views/home.ftl</code></li><li>a classpath resource, e.g.: <code>/com/company/web/views/home.ftl</code></li></ul><p> </p><p>Also see <a shape="rect" href="freemarker-support.html">Freemarker Support</a>.</p><h2 id="FreeMarkerResult-Parameters">Parameters</h2><ul style="list-style-type: square;"><li><strong>location</strong> (default) - the location of the template to process.</li><li><strong>parse </strong>- true by default. If set to false, the location param will not be parsed for expressions.</li><li><strong>contentType</strong> - defaults to <code>text/html</code> unless specified.</li><li><strong>writeIfCompleted</strong> - <code>false</co de> by default, write to stream only if there isn't any error processing the template. Setting <code>template_exception_handler=rethrow</code> in <code>freemarker.properties</code> will have the same effect.</li></ul><h2 id="FreeMarkerResult-Examples">Examples</h2><parameter ac:name="">xml</parameter><plain-text-body><result name="success" type="freemarker">foo.ftl</result></plain-text-body><p> </p><p> </p></div> </div> <div class="tabletitle">