Repository: struts-site Updated Branches: refs/heads/asf-site 29713114c -> b16cc4ef7
http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/webxml.html ---------------------------------------------------------------------- diff --git a/content/docs/webxml.html b/content/docs/webxml.html index 8f40240..2666810 100644 --- a/content/docs/webxml.html +++ b/content/docs/webxml.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,17 +125,7 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1488973941985 {padding: 0px;} -div.rbtoc1488973941985 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1488973941985 li {margin-left: 0px;padding-left: 0px;} - -/*]]>*/</style></p><div class="toc-macro rbtoc1488973941985"> -<ul class="toc-indentation"><li><a shape="rect" href="#web.xml-SimpleExample">Simple Example</a> -<ul class="toc-indentation"><li><a shape="rect" href="#web.xml-ChangedfilterpackageinStruts>=2.5">Changed filter package in Struts >= 2.5</a></li><li><a shape="rect" href="#web.xml-ChangedFilterStructureinStruts>=2.1.3">Changed Filter Structure in Struts >= 2.1.3</a></li><li><a shape="rect" href="#web.xml-ExcludespecificURLs">Exclude specific URLs</a></li></ul> -</li><li><a shape="rect" href="#web.xml-TaglibExample">Taglib Example</a></li><li><a shape="rect" href="#web.xml-CustomFileManagerandFileManagerFactoryimplementations">Custom FileManager and FileManagerFactory implementations</a></li><li><a shape="rect" href="#web.xml-Customconfigurationprovider">Custom configuration provider</a></li></ul> -</div><p>The <code>web.xml</code> web application descriptor file represents the core of the Java web application, so it is appropriate that it is also part of the core of the Struts framework. In the <code>web.xml</code> file, Struts defines its FilterDispatcher, the Servlet Filter class that initializes the Struts framework and handles all requests. This filter can contain initialization parameters that affect what, if any, additional configuration files are loaded and how the framework should behave.</p><h1 id="web.xml-SimpleExample">Simple Example</h1><p>Configuring <code>web.xml</code> for the framework is a matter of adding a filter and filter-mapping.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Filter Example (web.xml)</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><web-app id="MyStrutsApp" version="2.4" + <div id="ConfluenceContent"><p>The <code>web.xml</code> web application descriptor file represents the core of the Java web application, so it is appropriate that it is also part of the core of the Struts framework. In the <code>web.xml</code> file, Struts defines its FilterDispatcher, the Servlet Filter class that initializes the Struts framework and handles all requests. This filter can contain initialization parameters that affect what, if any, additional configuration files are loaded and how the framework should behave.</p><h1 id="web.xml-SimpleExample">Simple Example</h1><p>Configuring <code>web.xml</code> for the framework is a matter of adding a filter and filter-mapping.</p><parameter ac:name="title">Filter Example (web.xml)</parameter><plain-text-body><web-app id="MyStrutsApp" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> @@ -167,9 +143,7 @@ div.rbtoc1488973941985 li {margin-left: 0px;padding-left: 0px;} <!-- ... --> </web-app> -</pre> -</div></div><h2 id="web.xml-ChangedfilterpackageinStruts>=2.5">Changed filter package in Struts >= 2.5</h2><p><span>As from Struts 2.5 all filters were moved to top package, if you are using older version you must use the old package, see example:</span></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;"><web-app id="WebApp_9" version="2.4" +</plain-text-body><h2 id="web.xml-ChangedfilterpackageinStruts>=2.5">Changed filter package in Struts >= 2.5</h2><p><span>As from Struts 2.5 all filters were moved to top package, if you are using older version you must use the old package, see example:</span></p><parameter ac:name="language">xml</parameter><plain-text-body><web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> @@ -177,22 +151,16 @@ div.rbtoc1488973941985 li {margin-left: 0px;padding-left: 0px;} <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> - ...</pre> -</div></div><h2 id="web.xml-ChangedFilterStructureinStruts>=2.1.3">Changed Filter Structure in Struts >= 2.1.3</h2><p><span>To split up the the dispatcher phases, FilterDispatcher is deprecated since Struts 2.1.3. If working with older versions, you need to use</span></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;"> ... + ...</plain-text-body><h2 id="web.xml-ChangedFilterStructureinStruts>=2.1.3">Changed Filter Structure in Struts >= 2.1.3</h2><p><span>To split up the the dispatcher phases, FilterDispatcher is deprecated since Struts 2.1.3. If working with older versions, you need to use</span></p><parameter ac:name="">XML</parameter><plain-text-body> ... <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> ... -</pre> -</div></div><p><span>See </span><a shape="rect" href="sitemesh-plugin.html">SiteMesh Plugin</a><span> for an example on when to use seperate Filters for prepare and execution phase</span></p><h2 id="web.xml-ExcludespecificURLs">Exclude specific URLs</h2><p>In the example above we've mapped the Struts 2 dispatcher to <code>/*</code>, so Struts 2 has a crack at all incoming requests. This is because Struts 2 serves static content from its jar files, including Dojo JavaScript files (if using S2.0, or the Dojo plugin in S2.1+) and FreeMarker templates for the Struts 2 tags that produce HTML.</p><p>If we change the filter mapping to something else, for example <code>/*.html</code>, we must take this in to account and extract the content that would normally be served from the Struts 2 jar files, or some other solution.</p><p>Since Struts 2.1.7, you are able to provide a comma seperated list of patterns for which when matching against the<br clear="none"> request URL the Filter will just p ass by. This is done via the configuration option struts.action.excludePattern, for example in your struts.xml</p><p> </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;"><struts> +</plain-text-body><p><span>See </span><a shape="rect" href="sitemesh-plugin.html">SiteMesh Plugin</a><span> for an example on when to use seperate Filters for prepare and execution phase</span></p><h2 id="web.xml-ExcludespecificURLs">Exclude specific URLs</h2><p>In the example above we've mapped the Struts 2 dispatcher to <code>/*</code>, so Struts 2 has a crack at all incoming requests. This is because Struts 2 serves static content from its jar files, including Dojo JavaScript files (if using S2.0, or the Dojo plugin in S2.1+) and FreeMarker templates for the Struts 2 tags that produce HTML.</p><p>If we change the filter mapping to something else, for example <code>/*.html</code>, we must take this in to account and extract the content that would normally be served from the Struts 2 jar files, or some other solution.</p><p>Since Struts 2.1.7, you are able to provide a comma seperated list of patterns for which when matching against the<br clear="none"> request URL the Filter will just pass by. This is done via the configuration option struts.action.excludePattern, for example in your struts.xml</p><p> </p><parameter ac:name="">XML</parameter><plain-text-body><struts> <constant name="struts.action.excludePattern" value=".*unfiltered.*,.*\\.nofilter"/> ... -</struts></pre> -</div></div><h1 id="web.xml-TaglibExample">Taglib Example</h1><p>Typically, configuring a taglib is neither required nor recommended. The taglib is included in <code>struts-core.jar</code>, and the container will discover it automatically.</p><p><img class="emoticon emoticon-tick" src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/emoticons/check.png" data-emoticon-name="tick" alt="(tick)"> If, for some reason, a taglib configuration is needed within web.xml, extract the TLD file from the <code>struts-core.jar</code> <code>META-INF</code> folder, and add a <code>taglib</code> element to the <code>web.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;"> <!-- ... --> +</struts></plain-text-body><h1 id="web.xml-TaglibExample">Taglib Example</h1><p>Typically, configuring a taglib is neither required nor recommended. The taglib is included in <code>struts-core.jar</code>, and the container will discover it automatically.</p><p><img class="emoticon emoticon-tick" src="https://cwiki.apache.org/confluence/s/en_GB/5997/6f42626d00e36f53fe51440403446ca61552e2a2.1/_/images/icons/emoticons/check.png" data-emoticon-name="tick" alt="(tick)"> If, for some reason, a taglib configuration is needed within web.xml, extract the TLD file from the <code>struts-core.jar</code> <code>META-INF</code> folder, and add a <code>taglib</code> element to the <code>web.xml</code>.</p><parameter ac:name="">XML</parameter><plain-text-body> <!-- ... --> </welcome-file-list> <taglib> @@ -200,9 +168,7 @@ div.rbtoc1488973941985 li {margin-left: 0px;padding-left: 0px;} <taglib-location>/WEB-INF/struts-tags.tld</taglib-location> </taglib> </web-app> -</pre> -</div></div><h1 id="web.xml-CustomFileManagerandFileManagerFactoryimplementations">Custom FileManager and FileManagerFactory implementations</h1><p>If there is a need to support an App Server's specific file system (eg. VFS in JBoss), you can implement your own version of FileManager. But it must be registered at "the beginning" to support bootstrap of the whole framework.</p><p>To register your own FileManger you can do it with <init-param/> as below:</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;"><filter> +</plain-text-body><h1 id="web.xml-CustomFileManagerandFileManagerFactoryimplementations">Custom FileManager and FileManagerFactory implementations</h1><p>If there is a need to support an App Server's specific file system (eg. VFS in JBoss), you can implement your own version of FileManager. But it must be registered at "the beginning" to support bootstrap of the whole framework.</p><p>To register your own FileManger you can do it with <init-param/> as below:</p><parameter ac:name="">xml</parameter><plain-text-body><filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> @@ -210,9 +176,7 @@ div.rbtoc1488973941985 li {margin-left: 0px;padding-left: 0px;} <param-value>com.company.MyFileManager</param-value> </init-param> </filter> -</pre> -</div></div><p>You can as well register your own FileManagerFactory with <init-param/>, see 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;"><filter> +</plain-text-body><p>You can as well register your own FileManagerFactory with <init-param/>, see example:</p><parameter ac:name="">xml</parameter><plain-text-body><filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> @@ -220,17 +184,14 @@ div.rbtoc1488973941985 li {margin-left: 0px;padding-left: 0px;} <param-value>com.company.MyFileManagerFactory</param-value> </init-param> </filter> -</pre> -</div></div><p>Take a look on default implementations - DefaultFileManager.java and DefaultFileManagerFactory.java to understand how and why.</p><h1 id="web.xml-Customconfigurationprovider">Custom configuration provider</h1><p>It is possible to use your custom <code>ConfigurationProvider</code> to programmatically configure your application. To do this use <code>configProviders</code> (it can be a comma-separated list of class names) <code><init-param/></code> as below:</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;"><filter> +</plain-text-body><p>Take a look on default implementations - DefaultFileManager.java and DefaultFileManagerFactory.java to understand how and why.</p><h1 id="web.xml-Customconfigurationprovider">Custom configuration provider</h1><p>It is possible to use your custom <code>ConfigurationProvider</code> to programmatically configure your application. To do this use <code>configProviders</code> (it can be a comma-separated list of class names) <code><init-param/></code> as below:</p><plain-text-body><filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>configProviders</param-name> <param-value>com.company.MyConfigurationProvider</param-value> </init-param> -</filter></pre> -</div></div><p>See <a shape="rect" href="configuration-provider-configuration.html">Configuration Provider & Configuration</a> for more details.</p><p> </p></div> +</filter></plain-text-body><p>See <a shape="rect" href="configuration-provider-configuration.html">Configuration Provider & Configuration</a> for more details.</p><p> </p></div> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/xhtml-form-template.html ---------------------------------------------------------------------- diff --git a/content/docs/xhtml-form-template.html b/content/docs/xhtml-form-template.html index 7eb9ae0..1a00efa 100644 --- a/content/docs/xhtml-form-template.html +++ b/content/docs/xhtml-form-template.html @@ -142,7 +142,7 @@ under the License. <div id="ConfluenceContent"><p>The xhtml form template sets up the wrapping table around all the other <a shape="rect" href="xhtml-theme.html">xhtml theme</a> form elements. In addition to creating this wrapping table, the opening and closing templates also, if the <em>validate</em> parameter is set to true, enable <a shape="rect" href="pure-javascript-client-side-validation.html">Pure JavaScript Client Side Validation</a>. See the <strong>form.ftl</strong> contents:</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[ <#-- /* * $Id$ @@ -182,7 +182,7 @@ under the License. <p>The closing template, <strong>form-close.ftl</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[ <#-- /* * $Id$ http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/xhtml-theme.html ---------------------------------------------------------------------- diff --git a/content/docs/xhtml-theme.html b/content/docs/xhtml-theme.html index 124ab63..90566a2 100644 --- a/content/docs/xhtml-theme.html +++ b/content/docs/xhtml-theme.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; @@ -147,208 +133,22 @@ under the License. <h2 id="xhtmltheme-WrappingtheSimpleTheme">Wrapping the Simple Theme</h2> <p>The xhtml theme uses the "wrapping" technique described by <a shape="rect" href="extending-themes.html">Extending Themes</a>. Let's look at how the HTML tags are wrapped by a standard header and footer. For example, in the <code>text.ftl</code> template, the <code>controlheader.ftl</code> and <code>controlfooter.ftl</code> templates are wrapped around the simple template.</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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> -<#include "/${parameters.templateDir}/simple/text.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> -]]></script> -</div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/text.ftl}</plain-text-body> <p><img class="emoticon emoticon-question" src="https://cwiki.apache.org/confluence/s/en_GB/5997/6f42626d00e36f53fe51440403446ca61552e2a2.1/_/images/icons/emoticons/help_16.png" data-emoticon-name="question" alt="(question)"> The <code>controlheader.ftl</code> is referenced using ${parameters.theme} so that the code can be reused by the <a shape="rect" href="ajax-theme.html">ajax theme</a>.</p> <h2 id="xhtmltheme-XHTMLThemeHeader">XHTML Theme Header</h2> <p>Now let's look at the <code>controlheader.ftl</code> and <code>controlheader-core.ftl</code>. Again, these are split up for easy re-use with the <a shape="rect" href="ajax-theme.html">ajax theme</a>) contents:</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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader-core.ftl" /> - <td - <#if parameters.align?? > - class="align-${parameters.align?html}" - <#else > - class="tdInput" - </#if> -><#t/> -]]></script> -</div></div> -<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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -<#-- - Only show message if errors are available. - This will be done if ActionSupport is used. ---> -<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> -<#if (parameters.errorposition!"top") == 'top'> -<#if hasFieldErrors> -<#list fieldErrors[parameters.name] as error> -<tr errorFor="${parameters.id}"> - <td class="tdErrorMessage" colspan="2"><#rt/> - <span class="errorMessage">${error?html}</span><#t/> - </td><#lt/> -</tr> -</#list> -</#if> -</#if> -<#if !parameters.labelposition?? && (parameters.form.labelposition)??> -<#assign labelpos = parameters.form.labelposition/> -<#elseif parameters.labelposition??> -<#assign labelpos = parameters.labelposition/> -</#if> -<#-- - if the label position is top, - then give the label it's own row in the table ---> -<tr> -<#if (labelpos!"") == 'top'> - <td class="tdLabelTop" colspan="2"><#rt/> -<#else> - <td class="tdLabel"><#rt/> -</#if> -<#if parameters.label??> - <label <#t/> -<#if parameters.id??> - for="${parameters.id?html}" <#t/> -</#if> -<#if hasFieldErrors> - class="errorLabel"<#t/> -<#else> - class="label"<#t/> -</#if> - ><#t/> -<#if (parameters.required!false) && ((parameters.requiredPosition!"right") != 'right')> - <span class="required">*</span><#t/> -</#if> -${parameters.label?html}<#t/> -<#if (parameters.required!false) && ((parameters.requiredPosition!"right") == 'right')> - <span class="required">*</span><#t/> -</#if> -${parameters.labelseparator!":"?html}<#t/> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/tooltip.ftl" /> -</label><#t/> -</#if> - </td><#lt/> -<#-- add the extra row --> -<#if (labelpos!"") == 'top'> -</tr> -<tr> -</#if> -]]></script> -</div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/controlheader.ftl}</plain-text-body> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/controlheader-core.ftl}</plain-text-body> <p>The header used by the HTML tags in the xhtml theme is complicated. However, a close look reveals that the logic produces two behaviors: either a two-column format or a two-row format. Generally the two-column approach is what we want, so that is the default option. To use the two-row approach, change the <code>labelposition</code> parameter to <code>top</code>.</p> -<div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Moving fieldErrors</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"> -<p>The <code>fieldErrors</code>, usually caused by <a shape="rect" href="validation.html">Validation</a>, are printed out as a row above the HTML form element. Some people prefer that the errors display elsewhere, such as in a third column. If you wish to place these elsehwere, overriding the headers is easy, allowing you to continue to use the other features provided by this theme. See <a shape="rect" href="template-loading.html">Template Loading</a> for more information on how to do this.</p></div></div> +<parameter ac:name="title">Moving fieldErrors</parameter><rich-text-body> +<p>The <code>fieldErrors</code>, usually caused by <a shape="rect" href="validation.html">Validation</a>, are printed out as a row above the HTML form element. Some people prefer that the errors display elsewhere, such as in a third column. If you wish to place these elsehwere, overriding the headers is easy, allowing you to continue to use the other features provided by this theme. See <a shape="rect" href="template-loading.html">Template Loading</a> for more information on how to do this.</p></rich-text-body> <h2 id="xhtmltheme-XHTMLThemeFooter">XHTML Theme Footer</h2> <p>The primary objective of <code>controlfooter.ftl</code> is to close the table. But, before the table closes, the template checks for an <code>after</code> parameter.</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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -${parameters.after!}<#t/> - </td><#lt/> -</tr> -<#if (parameters.errorposition!"top") == 'bottom'> -<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> -<#if hasFieldErrors> -<#list fieldErrors[parameters.name] as error> -<tr errorFor="${parameters.id}"> - <td class="tdErrorMessage" colspan="2"><#rt/> - <span class="errorMessage">${error?html}</span><#t/> - </td><#lt/> -</tr> -</#list> -</#if> -</#if> - -]]></script> -</div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/controlfooter.ftl}</plain-text-body> <p>While "after" isn't an attribute supported by any of the <a shape="rect" href="struts-tags.html">Struts Tags</a>, if you are using <a shape="rect" href="freemarker-tags.html">FreeMarker Tags</a>, <a shape="rect" href="velocity-tags.html">Velocity Tags</a>, or the <a shape="rect" href="param.html">param</a> tag in any template language, you can add an <code>after</code> parameter to place any content you like after the <a shape="rect" href="simple-theme.html">simple theme</a> template renders. The <code>after</code> attribute makes it easier to fine-tune HTML forms for your specific environment.</p> <h2 id="xhtmltheme-SpecialInterest">Special Interest</h2> @@ -358,164 +158,16 @@ ${parameters.after!}<#t/> <h3 id="xhtmltheme-headtemplate">head template</h3> <p>The xhtml <a shape="rect" href="head.html">head</a> template extends the <a shape="rect" href="simple-head-template.html">simple head template</a> and provides an additional CSS that helps render the <a shape="rect" href="xhtml-theme.html">xhtml theme</a> form elements.</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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -<link rel="stylesheet" href="<@s.url value='/struts/xhtml/styles.css' includeParams='none' encode='false' />" type="text/css"/> -<#include "/${parameters.templateDir}/simple/head.ftl" /> -]]></script> -</div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/head.ftl}</plain-text-body> <p>The head template imports a style sheet.</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[ -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -.wwFormTable {} -.label {font-style:italic; } -.errorLabel {font-style:italic; color:red; } -.errorMessage {font-weight:bold; color:red; } -.checkboxLabel {} -.checkboxErrorLabel {color:red; } -.required {color:red;} -.tdLabel {text-align:right; vertical-align:top; } - -.tdTransferSelect {text-align:center; vertical-align:middle;} -.tdLabelTop {text-align:left; vertical-align:top;} -.tdCheckboxLabel {text-align:right; vertical-align:top;} -.tdCheckboxInput {text-align:left; vertical-align:top;} -.tdCheckboxErrorMessage {text-align:left; vertical-align:top;} -.tdErrorMessage {text-align:center; vertical-align:top;} -.formButton {text-align:right;} -.tdInput {text-align:left;} - - -.align-center{text-align:center;} -.align-right{text-align:right;} -.align-left{text-align:left;} -.align-justify{text-align:justify;} -]]></script> -</div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/styles.css}</plain-text-body> <h3 id="xhtmltheme-formtemplate">form template</h3> <p>The xhtml form template sets up the wrapping table around all the other <a shape="rect" href="xhtml-theme.html">xhtml theme</a> form elements. In addition to creating this wrapping table, the opening and closing templates also, if the <code>validate</code> parameter is set to true, enable <a shape="rect" href="pure-javascript-client-side-validation.html">Pure JavaScript Client Side Validation</a>.</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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/form-validate.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/form-common.ftl" /> -<#if (parameters.validate!false)> - onreset="${parameters.onreset!'clearErrorMessages(this);clearErrorLabels(this);'}" -<#else> - <#if parameters.onreset??> - onreset="${parameters.onreset?html}" - </#if> -</#if> -> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/control.ftl" /> -]]></script> -</div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/form.ftl}</plain-text-body> <p>The closing template, <code>form-close.ftl*</code>:</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[ -<#-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ ---> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/control-close.ftl" /> -<#include "/${parameters.templateDir}/simple/form-close.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/form-close-validate.ftl" /> -<#if parameters.focusElement??> -<script type="text/javascript"> - StrutsUtils.addOnLoad(function() { - var element = document.getElementById("${parameters.focusElement?html}"); - if(element) { - element.focus(); - } - }); -</script> -</#if> -]]></script> -</div></div></div> +<plain-text-body>{snippet:id=all|lang=xml|url=struts2/core/src/main/resources/template/xhtml/form-close.ftl}</plain-text-body></div> </div> <div class="tabletitle"> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/xsl-result.html ---------------------------------------------------------------------- diff --git a/content/docs/xsl-result.html b/content/docs/xsl-result.html index 5a5dced..28af0fa 100644 --- a/content/docs/xsl-result.html +++ b/content/docs/xsl-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,50 +125,29 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1488973594627 {padding: 0px;} -div.rbtoc1488973594627 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1488973594627 li {margin-left: 0px;padding-left: 0px;} - -/*]]>*/</style></p><div class="toc-macro rbtoc1488973594627"> -<ul class="toc-indentation"><li><a shape="rect" href="#XSLResult-Description">Description</a></li><li><a shape="rect" href="#XSLResult-Parameters">Parameters</a></li><li><a shape="rect" href="#XSLResult-Examples">Examples</a></li></ul> -</div><h1 id="XSLResult-Description">Description</h1><p>XSLTResult uses XSLT to transform an action object to XML. The recent version has been specifically modified to deal with Xalan flaws. When using Xalan you may notice that even though you have a very minimal stylesheet like this one</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;"><xsl:template match="/result"> + <div id="ConfluenceContent"><h1 id="XSLResult-Description">Description</h1><p>XSLTResult uses XSLT to transform an action object to XML. The recent version has been specifically modified to deal with Xalan flaws. When using Xalan you may notice that even though you have a very minimal stylesheet like this one</p><parameter ac:name="">xml</parameter><plain-text-body><xsl:template match="/result"> <result/> -</xsl:template></pre> -</div></div><p>Xalan would still iterate through every property of your action and all its descendants.</p><p>If you had double-linked objects, Xalan would work forever analysing an infinite object tree. Even if your stylesheet was not constructed to process them all. It's because the current Xalan eagerly and extensively converts<br clear="none">everything to its internal DTM model before further processing.</p><p>That's why there's a loop eliminator added that works by indexing every object-property combination during processing. If it notices that some object's property was already walked through, it doesn't go any deeper. Say you have two objects, x and y, with the following properties set (pseudocode):</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;">x.y = y; +</xsl:template></plain-text-body><p>Xalan would still iterate through every property of your action and all its descendants.</p><p>If you had double-linked objects, Xalan would work forever analysing an infinite object tree. Even if your stylesheet was not constructed to process them all. It's because the current Xalan eagerly and extensively converts<br clear="none">everything to its internal DTM model before further processing.</p><p>That's why there's a loop eliminator added that works by indexing every object-property combination during processing. If it notices that some object's property was already walked through, it doesn't go any deeper. Say you have two objects, x and y, with the following properties set (pseudocode):</p><plain-text-body>x.y = y; and y.x = x; -action.x=x;</pre> -</div></div><p>Due to that modification, the resulting XML document based on x would be:</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;"><result> +action.x=x;</plain-text-body><p>Due to that modification, the resulting XML document based on x would be:</p><parameter ac:name="">xml</parameter><plain-text-body><result> <x> <y/> </x> -</result></pre> -</div></div><p>Without it there would be endless <code>x/y/x/y/x/y/...</code> elements.</p><p>The <code>XSLTResult</code> code tries also to deal with the fact that DTM model is built in a manner that children are processed before siblings. The result is that if there is object x that is both set in action's x property, and very deeply under action's a property then it would only appear under a, not under x. That's not what we expect, and that's why <code>XSLTResult</code> allows objects to repeat in various places to some extent.</p><p>Sometimes the object mesh is still very dense and you may notice that even though you have a relatively simple stylesheet, execution takes a tremendous amount of time. To help you to deal with that obstacle of Xalan, you may attach regexp filters to elements paths (xpath).</p><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>In your .xsl file the root match must be named <strong>result</strong>. This example will output the username by using <strong>getUsername</strong> on your action class:</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;"><xsl:template match="result"> +</result></plain-text-body><p>Without it there would be endless <code>x/y/x/y/x/y/...</code> elements.</p><p>The <code>XSLTResult</code> code tries also to deal with the fact that DTM model is built in a manner that children are processed before siblings. The result is that if there is object x that is both set in action's x property, and very deeply under action's a property then it would only appear under a, not under x. That's not what we expect, and that's why <code>XSLTResult</code> allows objects to repeat in various places to some extent.</p><p>Sometimes the object mesh is still very dense and you may notice that even though you have a relatively simple stylesheet, execution takes a tremendous amount of time. To help you to deal with that obstacle of Xalan, you may attach regexp filters to elements paths (xpath).</p><rich-text-body><p>In your .xsl file the root match must be named <strong>result</strong>. This example will output the username by using <st rong>getUsername</strong> on your action class:</p><parameter ac:name="">xml</parameter><plain-text-body><xsl:template match="result"> <html> <body> Hello <xsl:value-of select="username"/> how are you? </body> </html> -</xsl:template></pre> -</div></div></div></div><p>In the following example the XSLT result would only walk through action's properties without their childs. It would also skip every property that has <code>hugeCollection</code> in their name. Element's path is first compared to <code>excludingPattern</code> - if it matches it's no longer processed. Then it is compared to <code>matchingPattern</code> and processed only if there's a match.</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;"><result name="success" type="xslt"> +</xsl:template></plain-text-body></rich-text-body><p>In the following example the XSLT result would only walk through action's properties without their childs. It would also skip every property that has <code>hugeCollection</code> in their name. Element's path is first compared to <code>excludingPattern</code> - if it matches it's no longer processed. Then it is compared to <code>matchingPattern</code> and processed only if there's a match.</p><parameter ac:name="">xml</parameter><plain-text-body><result name="success" type="xslt"> <param name="stylesheetLocation">foo.xslt</param> <param name="matchingPattern">^/result/[^/*]$</param> <param name="excludingPattern">.*(hugeCollection).*</param> -</result></pre> -</div></div><p>In the following example the XSLT result would use the action's user property instead of the action as it's base document and walk through it's properties. The <code>exposedValue</code> uses an OGNL expression to derive it's value.</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;"><result name="success" type="xslt"> +</result></plain-text-body><p>In the following example the XSLT result would use the action's user property instead of the action as it's base document and walk through it's properties. The <code>exposedValue</code> uses an OGNL expression to derive it's value.</p><parameter ac:name="">xml</parameter><plain-text-body><result name="success" type="xslt"> <param name="stylesheetLocation">foo.xslt</param> <param name="exposedValue">${user}</param> -</result></pre> -</div></div><h1 id="XSLResult-Parameters">Parameters</h1><p>This result type takes the following parameters:</p><ul style="list-style-type: square;"><li><strong>stylesheetLocation</strong> (default) - the location to go to after execution.</li><li><strong>location</strong> (deprecated) - the same as <strong>stylesheetLocation</strong> but it was dropped since Struts 2.5.</li><li><strong>encoding </strong>- character encoding used in XML, default UTF-8.</li><li><strong>parse</strong> - <code>true</code> by default. If set to false, the location param will not be parsed for Ognl expressions.</li><li><strong>matchingPattern </strong>- <code>Pattern</code> that matches only desired elements, by default it matches everything.</li><li><strong>excludingPattern</strong> - <code>Pattern</code> that eliminates unwanted elements, by default it matches none.</li></ul><p><code>struts.properties</code> related configuration:</p><ul style="list-style-type: s quare;"><li><strong>struts.xslt.nocache</strong> - Defaults to false. If set to true, disables stylesheet caching. Good for development, bad for production.</li></ul><h1 id="XSLResult-Examples"><span style="font-size: 24.0px;">Examples</span></h1><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="xslt">foo.xslt</result></pre> -</div></div><p> </p><p> </p></div> +</result></plain-text-body><h1 id="XSLResult-Parameters">Parameters</h1><p>This result type takes the following parameters:</p><ul style="list-style-type: square;"><li><strong>stylesheetLocation</strong> (default) - the location to go to after execution.</li><li><strong>location</strong> (deprecated) - the same as <strong>stylesheetLocation</strong> but it was dropped since Struts 2.5.</li><li><strong>encoding </strong>- character encoding used in XML, default UTF-8.</li><li><strong>parse</strong> - <code>true</code> by default. If set to false, the location param will not be parsed for Ognl expressions.</li><li><strong>matchingPattern </strong>- <code>Pattern</code> that matches only desired elements, by default it matches everything.</li><li><strong>excludingPattern</strong> - <code>Pattern</code> that eliminates unwanted elements, by default it matches none.</li></ul><p><code>struts.properties</code> related configuration:</p><ul styl e="list-style-type: square;"><li><strong>struts.xslt.nocache</strong> - Defaults to false. If set to true, disables stylesheet caching. Good for development, bad for production.</li></ul><h1 id="XSLResult-Examples"><span style="font-size: 24.0px;">Examples</span></h1><parameter ac:name="">xml</parameter><plain-text-body><result name="success" type="xslt">foo.xslt</result></plain-text-body><p> </p><p> </p></div> </div>