This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-5255-script-link in repository https://gitbox.apache.org/repos/asf/struts.git
commit 5d272e513d2215dce0a5ea90894884b819d81185 Author: Lukasz Lenart <[email protected]> AuthorDate: Wed Nov 2 08:39:49 2022 +0100 WW-5255 Fixes <s:script/> and <s:link/> and uses them across tags --- .../src/main/webapp/WEB-INF/decorators/main.jsp | 19 +++++---- .../struts2/interceptor/debugging/console.ftl | 8 ++-- .../src/main/resources/template/css_xhtml/head.ftl | 2 +- .../main/resources/template/simple/combobox.ftl | 14 +++---- core/src/main/resources/template/simple/debug.ftl | 16 +++++--- .../resources/template/simple/doubleselect.ftl | 4 +- .../template/simple/form-close-tooltips.ftl | 11 +++--- .../main/resources/template/simple/form-close.ftl | 4 +- core/src/main/resources/template/simple/head.ftl | 2 +- .../template/simple/inputtransferselect.ftl | 2 +- core/src/main/resources/template/simple/link.ftl | 46 +++++++++++----------- core/src/main/resources/template/simple/nonce.ftl | 4 +- .../template/simple/optiontransferselect.ftl | 2 +- core/src/main/resources/template/simple/script.ftl | 33 ++++++---------- .../resources/template/simple/updownselect.ftl | 4 +- .../template/xhtml/form-close-validate.ftl | 8 ++-- .../main/resources/template/xhtml/form-close.ftl | 4 +- .../resources/template/xhtml/form-validate.ftl | 2 +- core/src/main/resources/template/xhtml/head.ftl | 2 +- core/src/main/resources/template/xhtml/link.ftl | 21 ---------- core/src/main/resources/template/xhtml/script.ftl | 21 ---------- .../freemarker/FreemarkerResultMockedTest.java | 3 +- .../apache/struts2/views/jsp/ui/LinkTagTest.java | 6 ++- .../views/freemarker/callActionFreeMarker.ftl | 4 +- .../views/freemarker/callActionFreeMarker2.ftl | 4 +- .../struts2/views/freemarker/customTextField.ftl | 2 - .../struts2/views/freemarker/dynaAttributes.ftl | 2 - .../views/freemarker/incompatible-improvements.ftl | 4 +- .../struts2/views/freemarker/manual-list.ftl | 2 - .../org/apache/struts2/views/freemarker/nested.ftl | 4 +- .../apache/struts2/views/freemarker/nonceTest.ftl | 2 - .../apache/struts2/views/freemarker/something.ftl | 2 - .../apache/struts2/views/jsp/ui/HeadTagTest-1.txt | 4 +- .../org/apache/struts2/views/jsp/ui/tooltip-1.txt | 2 +- .../org/apache/struts2/views/jsp/ui/tooltip-2.txt | 4 +- .../org/apache/struts2/views/jsp/ui/tooltip-3.txt | 2 +- .../resources/config-browser/showValidators.ftl | 32 +++++++++------ 37 files changed, 129 insertions(+), 179 deletions(-) diff --git a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp index ff1353032..77f387ace 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp @@ -64,14 +64,14 @@ <title><decorator:title default="Struts2 Showcase"/></title> <s:url var="bootstrapCss" value='/styles/bootstrap.css' encode='false' includeParams='none'/> - <s:link href="%{bootstrapCss}" rel="stylesheet" type="text/css" media="all"></s:link> + <s:link href="%{bootstrapCss}" rel="stylesheet" type="text/css" media="all"/> <s:url var="mainCss" value='/styles/main.css' encode='false' includeParams='none'/> - <s:link href="%{mainCss}" rel="stylesheet" type="text/css" media="all"></s:link> + <s:link href="%{mainCss}" rel="stylesheet" type="text/css" media="all"/> <s:url var="jqueryJs" value='/js/jquery-2.1.4.min.js' encode='false' includeParams='none'/> - <s:script src="%{jqueryJs}"></s:script> + <s:script src="%{jqueryJs}"/> <s:url var="bootstrapJs" value='/js/bootstrap.min.js' encode='false' includeParams='none'/> - <s:script src="%{bootstrapJs}"></s:script> + <s:script src="%{bootstrapJs}"/> <s:script type="text/javascript"> $(function () { var alerts = $('ul.alert').wrap('<div />'); @@ -82,19 +82,22 @@ <!-- Prettify --> <s:url var="prettifyCss" value='/styles/prettify.css' encode='false' includeParams='none'/> - <s:link href="%{prettifyCss}" rel="stylesheet"></s:link> + <s:link href="%{prettifyCss}" rel="stylesheet"/> <s:url var="prettifyJs" value='/js/prettify.js' encode='false' includeParams='none'/> - <s:script src="%{prettifyJs}"></s:script> + <s:script src="%{prettifyJs}"/> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> - <s:script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></s:script> + <s:script src="http://html5shim.googlecode.com/svn/trunk/html5.js"/> <![endif]--> + <s:script> + jQuery(document).ready(function() { prettyPrint(); } ); + </s:script> <decorator:head/> </head> -<body id="page-home" onload="prettyPrint();"> +<body id="page-home"> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> diff --git a/core/src/main/resources/org/apache/struts2/interceptor/debugging/console.ftl b/core/src/main/resources/org/apache/struts2/interceptor/debugging/console.ftl index daa4f6e20..eb42ba9f9 100644 --- a/core/src/main/resources/org/apache/struts2/interceptor/debugging/console.ftl +++ b/core/src/main/resources/org/apache/struts2/interceptor/debugging/console.ftl @@ -21,10 +21,10 @@ <!DOCTYPE html> <html> <head> - <script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > - var baseUrl = "<@s.url value="/struts" includeParams="none"/>"; - window.open(baseUrl+"/webconsole.html", 'OGNL Console','width=500,height=450,status=no,toolbar=no,menubar=no'); - </script> + <@s.script type="text/javascript"> + var baseUrl = "<@s.url value="/struts" includeParams="none"/>"; + window.open(baseUrl+"/webconsole.html", 'OGNL Console','width=500,height=450,status=no,toolbar=no,menubar=no'); + </@s.script> </head> <body> <pre> diff --git a/core/src/main/resources/template/css_xhtml/head.ftl b/core/src/main/resources/template/css_xhtml/head.ftl index 7d493e8ee..0c0a39791 100644 --- a/core/src/main/resources/template/css_xhtml/head.ftl +++ b/core/src/main/resources/template/css_xhtml/head.ftl @@ -18,5 +18,5 @@ * under the License. */ --> -<link <#include "/${parameters.templateDir}/simple/nonce.ftl" /> rel="stylesheet" href="<@s.url value='${parameters.staticContentPath}/css_xhtml/styles.css' includeParams='none' encode='false' />" type="text/css" /> +<@s.link rel="stylesheet" href="${base}${parameters.staticContentPath}/css_xhtml/styles.css" type="text/css" /> <#include "/${parameters.templateDir}/simple/head.ftl" /> diff --git a/core/src/main/resources/template/simple/combobox.ftl b/core/src/main/resources/template/simple/combobox.ftl index 761b57772..1cef11754 100644 --- a/core/src/main/resources/template/simple/combobox.ftl +++ b/core/src/main/resources/template/simple/combobox.ftl @@ -18,21 +18,21 @@ * under the License. */ --> -<script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > +<@s.script type="text/javascript"> function autoPopulate_${parameters.escapedId}(targetElement) { - <#if parameters.headerKey?? && parameters.headerValue??> + <#if parameters.headerKey?? && parameters.headerValue??> if (targetElement.options[targetElement.selectedIndex].value == '${parameters.headerKey?js_string}') { return; } - </#if> - <#if parameters.emptyOption?default(false)> + </#if> + <#if parameters.emptyOption!false> if (targetElement.options[targetElement.selectedIndex].value == '') { - return; + return; } - </#if> + </#if> targetElement.form.elements['${parameters.name?js_string}'].value=targetElement.options[targetElement.selectedIndex].value; } -</script> +</@s.script> <#include "/${parameters.templateDir}/simple/text.ftl" /> <br /> <#if parameters.list??> diff --git a/core/src/main/resources/template/simple/debug.ftl b/core/src/main/resources/template/simple/debug.ftl index 6a2727d0d..889702213 100644 --- a/core/src/main/resources/template/simple/debug.ftl +++ b/core/src/main/resources/template/simple/debug.ftl @@ -18,8 +18,7 @@ * under the License. */ --> -<script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > -<!-- +<@s.script> function toggleDebug(debugId) { var debugDiv = document.getElementById(debugId); if (debugDiv) { @@ -31,10 +30,9 @@ } } } ---> -</script> +</@s.script> -<style type="text/css"> +<style> <!-- table.debugTable {border-collapse:collapse; border-spacing:0; background-color:#DDDDDD;} table.debugTable th, table.debugTable td {padding:2px;} @@ -42,7 +40,7 @@ </style> <br> -<a href="#" onclick="toggleDebug('<#if parameters.id??>${parameters.id}<#else>debug</#if>');return false;">[Debug]</a> +<a href="#" id="toggle-button">[Debug]</a> <div style="display:none" id="<#if parameters.id??>${parameters.id}<#else>debug</#if>"> <h2>Struts ValueStack Debug</h2> <br> @@ -86,3 +84,9 @@ </#list> </table> </div> +<@s.script> + document.getElementById('toggle-button').onclick = function() { + toggleDebug('<#if parameters.id??>${parameters.id}<#else>debug</#if>'); + return false; + } +</@s.script> diff --git a/core/src/main/resources/template/simple/doubleselect.ftl b/core/src/main/resources/template/simple/doubleselect.ftl index c064f29ae..674680ef1 100644 --- a/core/src/main/resources/template/simple/doubleselect.ftl +++ b/core/src/main/resources/template/simple/doubleselect.ftl @@ -73,7 +73,7 @@ </#if> /> </#if> -<script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > +<@s.script type="text/javascript"> <#assign itemCount = startCount/> var ${parameters.escapedId}Group = new Array(${parameters.listSize?number?c} + ${startCount}); for (var i = 0; i < (${parameters.listSize?number?c} + ${startCount}); i++) { @@ -193,4 +193,4 @@ ${parameters.escapedId}Temp.options[0].selected = true; } } -</script> +</@s.script> diff --git a/core/src/main/resources/template/simple/form-close-tooltips.ftl b/core/src/main/resources/template/simple/form-close-tooltips.ftl index 21e25a4fe..1a418b985 100644 --- a/core/src/main/resources/template/simple/form-close-tooltips.ftl +++ b/core/src/main/resources/template/simple/form-close-tooltips.ftl @@ -19,12 +19,11 @@ */ --> -<#-- +<#-- Code that will add javascript needed for tooltips --><#t/> <#if (parameters.hasTooltip!false)><#t/> - <#lt/><!-- javascript that is needed for tooltips --> - <#lt/><script type="text/javascript" src='<@s.url value="${parameters.staticContentPath}/domTT.js" includeParams="none" encode="false" />' <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > </script> - <#lt/><link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/domTT.css" includeParams="none" encode="false" />" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> /> - -</#if><#t/> \ No newline at end of file + <#lt/><!-- javascript that is needed for tooltips --> + <#lt/><@s.script type="text/javascript" src="${base}${parameters.staticContentPath}/domTT.js" /> + <#lt/><@s.link rel="stylesheet" type="text/css" href="${base}${parameters.staticContentPath}/domTT.css" /> +</#if><#t/> diff --git a/core/src/main/resources/template/simple/form-close.ftl b/core/src/main/resources/template/simple/form-close.ftl index c2285b2e6..ce2b91259 100644 --- a/core/src/main/resources/template/simple/form-close.ftl +++ b/core/src/main/resources/template/simple/form-close.ftl @@ -21,7 +21,7 @@ </form> <#if (parameters.customOnsubmitEnabled??)> -<script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > +<@s.script type="text/javascript"> <#-- Enable auto-select of optiontransferselect tag's entries upon containing form's submission. @@ -96,7 +96,7 @@ }, true); </#list> </#if> -</script> +</@s.script> </#if> <#include "/${parameters.templateDir}/${parameters.expandTheme}/form-close-tooltips.ftl" /> diff --git a/core/src/main/resources/template/simple/head.ftl b/core/src/main/resources/template/simple/head.ftl index 359d7bf71..82fe8db20 100644 --- a/core/src/main/resources/template/simple/head.ftl +++ b/core/src/main/resources/template/simple/head.ftl @@ -18,4 +18,4 @@ * under the License. */ --> -<script src="${base}${parameters.staticContentPath}/utils.js" type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script> \ No newline at end of file +<@s.script src="${base}${parameters.staticContentPath}/utils.js" type="text/javascript" /> diff --git a/core/src/main/resources/template/simple/inputtransferselect.ftl b/core/src/main/resources/template/simple/inputtransferselect.ftl index 7684a097d..9b28a02ce 100644 --- a/core/src/main/resources/template/simple/inputtransferselect.ftl +++ b/core/src/main/resources/template/simple/inputtransferselect.ftl @@ -19,7 +19,7 @@ */ --> <#if !stack.findValue("#inputtransferselect_js_included")??><#t/> - <script type="text/javascript" src="<@s.url value="${parameters.staticContentPath}/inputtransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script> + <@s.script type="text/javascript" src="${base}${parameters.staticContentPath}/inputtransferselect.js"/> <#assign temporaryVariable = stack.setValue("#inputtransferselect_js_included", "true") /><#t/> </#if><#t/> <table> diff --git a/core/src/main/resources/template/simple/link.ftl b/core/src/main/resources/template/simple/link.ftl index b4af7f302..13d7b4b00 100644 --- a/core/src/main/resources/template/simple/link.ftl +++ b/core/src/main/resources/template/simple/link.ftl @@ -18,48 +18,46 @@ * under the License. */ --> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/common-attributes.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/dynamic-attributes.ftl" /> -<link <#include "/${parameters.templateDir}/simple/nonce.ftl" /> +<link<#rt/> +<#if parameters.rel?has_content> + rel="${parameters.rel}"<#rt/> +</#if> +<#if parameters.type?has_content> + type="${parameters.type}"<#rt/> +</#if> <#if parameters.href?has_content> - href="${parameters.href}"<#rt/> + href="${parameters.href}"<#rt/> </#if> <#if parameters.hreflang?has_content> - hreflang="${parameters.hreflang}"<#rt/> + hreflang="${parameters.hreflang}"<#rt/> </#if> -<#if parameters.rel?has_content> - rel="${parameters.rel}"<#rt/> -</#if> -<#if parameters.disabled?has_content> - <#if parameters.disabled=="true"> - disabled<#rt/> - </#if> +<#if parameters.disabled?has_content && parameters.disabled == "true"> + disabled<#rt/> </#if> <#if parameters.media?has_content> - media="${parameters.media}"<#rt/> -</#if> -<#if parameters.type?has_content> - type="${parameters.type}"<#rt/> + media="${parameters.media}"<#rt/> </#if> <#if parameters.title?has_content> - title="${parameters.title}"<#rt/> + title="${parameters.title}"<#rt/> </#if> <#if parameters.as?has_content> - as="${parameters.as}"<#rt/> + as="${parameters.as}"<#rt/> </#if> <#if parameters.referrerpolicy?has_content> - referrerpolicy="${parameters.referrerpolicy}"<#rt/> + referrerpolicy="${parameters.referrerpolicy}"<#rt/> </#if> <#if parameters.sizes?has_content> - sizes="${parameters.sizes}"<#rt/> + sizes="${parameters.sizes}"<#rt/> </#if> <#if parameters.crossorigin?has_content> - crossorigin="${parameters.crossorigin}"<#rt/> + crossorigin="${parameters.crossorigin}"<#rt/> </#if> <#if parameters.integrity?has_content> - integrity="${parameters.integrity}"<#rt/> + integrity="${parameters.integrity}"<#rt/> </#if> <#if parameters.importance?has_content> - importance="${parameters.importance}"<#rt/> + importance="${parameters.importance}"<#rt/> </#if> -> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/common-attributes.ftl" /><#rt/> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/dynamic-attributes.ftl" /><#rt/> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/nonce.ftl" /><#rt/>/> diff --git a/core/src/main/resources/template/simple/nonce.ftl b/core/src/main/resources/template/simple/nonce.ftl index 795d82a2e..507802a45 100644 --- a/core/src/main/resources/template/simple/nonce.ftl +++ b/core/src/main/resources/template/simple/nonce.ftl @@ -18,4 +18,6 @@ * under the License. */ --> -<#if parameters.nonce?has_content>nonce="${parameters.nonce}"<#rt/></#if> \ No newline at end of file +<#if parameters.nonce?has_content><#rt/> + nonce="${parameters.nonce}"<#rt/> +</#if><#rt/> diff --git a/core/src/main/resources/template/simple/optiontransferselect.ftl b/core/src/main/resources/template/simple/optiontransferselect.ftl index 36d4ca302..adf770499 100644 --- a/core/src/main/resources/template/simple/optiontransferselect.ftl +++ b/core/src/main/resources/template/simple/optiontransferselect.ftl @@ -19,7 +19,7 @@ */ --> <#if !stack.findValue("#optiontransferselect_js_included")??><#t/> - <script type="text/javascript" src="<@s.url value="${parameters.staticContentPath}/optiontransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script> + <@s.script type="text/javascript" src="${base}${parameters.staticContentPath}/optiontransferselect.js" /> <#assign temporaryVariable = stack.setValue("#optiontransferselect_js_included", "true") /><#t/> </#if><#t/> <table> diff --git a/core/src/main/resources/template/simple/script.ftl b/core/src/main/resources/template/simple/script.ftl index 5afb30dd3..11ce14827 100644 --- a/core/src/main/resources/template/simple/script.ftl +++ b/core/src/main/resources/template/simple/script.ftl @@ -18,36 +18,27 @@ * under the License. */ --> -<script <#rt/> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/common-attributes.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/dynamic-attributes.ftl" /> -<#include "/${parameters.templateDir}/simple/nonce.ftl" /> -<#if parameters.async?has_content> - <#if parameters.async=="true"> - async<#rt/> - </#if> +<script<#rt/> +<#if parameters.async?has_content && parameters.async == "true"> + async<#rt/> </#if> <#if parameters.charset?has_content> charset="${parameters.charset}"<#rt/> </#if> -<#if parameters.defer?has_content> - <#if parameters.defer=="true"> - defer<#rt/> - </#if> -</#if> -<#if parameters.src?has_content> - src="${parameters.src}"<#rt/> +<#if parameters.defer?has_content && parameters.defer=="true"> + defer<#rt/> </#if> <#if parameters.type?has_content> type="${parameters.type}"<#rt/> </#if> +<#if parameters.src?has_content> + src="${parameters.src}"<#rt/> +</#if> <#if parameters.referrerpolicy?has_content> referrerpolicy="${parameters.referrerpolicy}"<#rt/> </#if> -<#if parameters.nomodule?has_content> - <#if parameters.nomodule=="true"> - nomodule<#rt/> - </#if> +<#if parameters.nomodule?has_content && parameters.nomodule=="true"> + nomodule<#rt/> </#if> <#if parameters.integrity?has_content> integrity="${parameters.integrity}"<#rt/> @@ -55,4 +46,6 @@ <#if parameters.crossorigin?has_content> crossorigin="${parameters.crossorigin}"<#rt/> </#if> -> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/common-attributes.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/dynamic-attributes.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/nonce.ftl" />> diff --git a/core/src/main/resources/template/simple/updownselect.ftl b/core/src/main/resources/template/simple/updownselect.ftl index f1185d3a5..7491f9a08 100644 --- a/core/src/main/resources/template/simple/updownselect.ftl +++ b/core/src/main/resources/template/simple/updownselect.ftl @@ -19,7 +19,7 @@ */ --> <#if !stack.findValue("#optiontransferselect_js_included")??><#t/> - <script type="text/javascript" src="<@s.url value="${parameters.staticContentPath}/optiontransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script> + <@s.script type="text/javascript" src="${base}${parameters.staticContentPath}/optiontransferselect.js" /><#t/> <#assign temporaryVariable = stack.setValue("#optiontransferselect_js_included", "true") /><#t/> </#if><#t/> <table> @@ -52,4 +52,4 @@ </#if><#t/> </#if><#t/> </td></tr> -</table> \ No newline at end of file +</table> diff --git a/core/src/main/resources/template/xhtml/form-close-validate.ftl b/core/src/main/resources/template/xhtml/form-close-validate.ftl index afa1c50ae..dfc338cbc 100644 --- a/core/src/main/resources/template/xhtml/form-close-validate.ftl +++ b/core/src/main/resources/template/xhtml/form-close-validate.ftl @@ -32,7 +32,7 @@ Only the following validators are supported: END SNIPPET: supported-validators --> <#if ((parameters.validate!false == true) && (parameters.performValidation!false == true))> -<script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > +<@s.script type="text/javascript"> function validateForm_${parameters.escapedId}() { <#-- In case of multiselect fields return only the first value. @@ -75,7 +75,7 @@ END SNIPPET: supported-validators var error = "${validator.getMessage(action)?js_string}"; var fieldValue = getFieldValue(field); - + <#if validator.validatorType = "required"> if (fieldValue === "") { addError(field, error); @@ -152,5 +152,5 @@ END SNIPPET: supported-validators return !errors; } -</script> -</#if> \ No newline at end of file +</@s.script> +</#if> diff --git a/core/src/main/resources/template/xhtml/form-close.ftl b/core/src/main/resources/template/xhtml/form-close.ftl index b8a90fc79..300de7a04 100644 --- a/core/src/main/resources/template/xhtml/form-close.ftl +++ b/core/src/main/resources/template/xhtml/form-close.ftl @@ -22,12 +22,12 @@ <#include "/${parameters.templateDir}/simple/form-close.ftl" /> <#include "/${parameters.templateDir}/${parameters.expandTheme}/form-close-validate.ftl" /> <#if parameters.focusElement??> -<script type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > +<@s.script type="text/javascript"> StrutsUtils.addOnLoad(function() { var element = document.getElementById("${parameters.focusElement?js_string}"); if(element) { element.focus(); } }); -</script> +</@s.script> </#if> diff --git a/core/src/main/resources/template/xhtml/form-validate.ftl b/core/src/main/resources/template/xhtml/form-validate.ftl index 2880ffbf1..028c5d9ec 100644 --- a/core/src/main/resources/template/xhtml/form-validate.ftl +++ b/core/src/main/resources/template/xhtml/form-validate.ftl @@ -19,7 +19,7 @@ */ --> <#if parameters.validate!false == true> - <script type="text/javascript" src="${base}${parameters.staticContentPath}/xhtml/validation.js" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script> + <@s.script type="text/javascript" src="${base}${parameters.staticContentPath}/xhtml/validation.js" /> <#if parameters.onsubmit??> ${tag.addParameter('onsubmit', "${parameters.onsubmit}; return validateForm_${parameters.escapedId}();")} <#else> diff --git a/core/src/main/resources/template/xhtml/head.ftl b/core/src/main/resources/template/xhtml/head.ftl index 7b5bfe08d..f72d220d6 100644 --- a/core/src/main/resources/template/xhtml/head.ftl +++ b/core/src/main/resources/template/xhtml/head.ftl @@ -18,5 +18,5 @@ * under the License. */ --> -<link rel="stylesheet" href="<@s.url value='${parameters.staticContentPath}/xhtml/styles.css' includeParams='none' encode='false'/>" type="text/css" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> /> +<@s.link rel="stylesheet" href="${base}${parameters.staticContentPath}/xhtml/styles.css" type="text/css" /> <#include "/${parameters.templateDir}/simple/head.ftl" /> diff --git a/core/src/main/resources/template/xhtml/link.ftl b/core/src/main/resources/template/xhtml/link.ftl deleted file mode 100644 index 5261e7b19..000000000 --- a/core/src/main/resources/template/xhtml/link.ftl +++ /dev/null @@ -1,21 +0,0 @@ -<#-- -/* - * 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}/simple/link.ftl" /> diff --git a/core/src/main/resources/template/xhtml/script.ftl b/core/src/main/resources/template/xhtml/script.ftl deleted file mode 100644 index 2dc7d3fd8..000000000 --- a/core/src/main/resources/template/xhtml/script.ftl +++ /dev/null @@ -1,21 +0,0 @@ -<#-- -/* - * 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}/simple/script.ftl" /> diff --git a/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerResultMockedTest.java b/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerResultMockedTest.java index f0fa5d3ba..3a7c4b863 100644 --- a/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerResultMockedTest.java +++ b/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerResultMockedTest.java @@ -243,7 +243,8 @@ public class FreemarkerResultMockedTest extends StrutsInternalTestCase { EasyMock.expect(servletContext.getRealPath("/template/~~~xhtml/dynamic-attributes.ftl")).andReturn(file.getAbsolutePath()); file = new File(ClassLoaderUtil.getResource("template/simple/nonce.ftl", getClass()).toURI()); - EasyMock.expect(servletContext.getRealPath("/template/simple/nonce.ftl")).andReturn(file.getAbsolutePath()); + EasyMock.expect(servletContext.getRealPath("/template/xhtml/nonce.ftl")).andReturn(file.getAbsolutePath()); + EasyMock.expect(servletContext.getRealPath("/template/~~~xhtml/nonce.ftl")).andReturn(file.getAbsolutePath()); file = new File(ClassLoaderUtil.getResource("template/simple/script.ftl", getClass()).toURI()); EasyMock.expect(servletContext.getRealPath("/template/simple/script.ftl")).andReturn(file.getAbsolutePath()); diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/LinkTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/LinkTagTest.java index ecba64c56..ad5fca107 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/LinkTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/LinkTagTest.java @@ -26,7 +26,7 @@ public class LinkTagTest extends AbstractUITagTest { private static final String NONCE_VAL = "r4andom"; - public void testLinkTagAttributes() { + public void testLinkTagAttributes() throws JspException { LinkTag tag = new LinkTag(); tag.setHref("mysrc.js"); @@ -40,6 +40,7 @@ public class LinkTagTest extends AbstractUITagTest { tag.setAs("test"); tag.setDisabled("false"); tag.setTitle("test"); + tag.setDynamicAttribute(null, "data-id", "id4test"); doLinkTest(tag); String s = writer.toString(); @@ -55,7 +56,8 @@ public class LinkTagTest extends AbstractUITagTest { assertTrue("Incorrect as attribute for link tag", s.contains("as=\"test\"")); assertFalse("Non-existent disabled attribute for link tag", s.contains("disabled")); assertTrue("Incorrect title attribute for link tag", s.contains("title=\"test\"")); - assertTrue("Incorrect nonce attribute for link tag", s.contains("nonce=\"" + NONCE_VAL+"\"")); + assertTrue("Incorrect nonce attribute for link tag", s.contains("nonce=\"" + NONCE_VAL + "\"")); + assertTrue("Incorrect data-id dynamic attribute for link tag", s.contains("data-id=\"id4test\"")); } private void doLinkTest(LinkTag tag) { diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker.ftl index a36b3bd79..e095244a6 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 @@ -20,4 +18,4 @@ * under the License. */ --> -before<@s.action namespace="/tutorial" name="test4" executeResult="true" rethrowException="true"/>after \ No newline at end of file +before<@s.action namespace="/tutorial" name="test4" executeResult="true" rethrowException="true"/>after diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker2.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker2.ftl index de83b535f..84fe86826 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker2.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/callActionFreeMarker2.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 @@ -20,4 +18,4 @@ * under the License. */ --> -before<@s.action namespace="/tutorial" name="test3" executeResult="true" rethrowException="true"/>after \ No newline at end of file +before<@s.action namespace="/tutorial" name="test3" executeResult="true" rethrowException="true"/>after<#rt/> diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl index 4409d2951..87fb04ddd 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/customTextField.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl index 68a7f70a6..f4fdb9961 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl index 99d929d68..01b251f6f 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 @@ -20,4 +18,4 @@ * under the License. */ --> -<input type="text" onclick="this.alert('${error}')"/> \ No newline at end of file +<input type="text" onclick="this.alert('${error}')"/><#rt /> diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl index d00a85b39..96258154a 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/nested.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/nested.ftl index f8fc66dcf..c7535301e 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/nested.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/nested.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 @@ -20,4 +18,4 @@ * under the License. */ --> -nested \ No newline at end of file +nested<#rt/> diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/nonceTest.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/nonceTest.ftl index a69bd3d6d..7e1a37871 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/nonceTest.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/nonceTest.ftl @@ -1,7 +1,5 @@ <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/something.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/something.ftl index 2ca0b5c50..8a21f62c5 100644 --- a/core/src/test/resources/org/apache/struts2/views/freemarker/something.ftl +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/something.ftl @@ -1,8 +1,6 @@ <#ftl attributes={"content_type": "text/xml"} /> <#-- /* - * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ - * * 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 diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/HeadTagTest-1.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/HeadTagTest-1.txt index 00dd01f26..cf6ed8e56 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/HeadTagTest-1.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/HeadTagTest-1.txt @@ -1,2 +1,2 @@ -<link rel="stylesheet" href="/static/xhtml/styles.css" type="text/css" nonce="r4nd0m"/> -<script src="/static/utils.js" type="text/javascript" nonce="r4nd0m"></script> \ No newline at end of file +<link rel="stylesheet" type="text/css" href="/static/xhtml/styles.css" nonce="r4nd0m"/> +<script type="text/javascript" src="/static/utils.js" nonce="r4nd0m"></script> diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-1.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-1.txt index 80b16d008..d34b31d2d 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-1.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-1.txt @@ -15,7 +15,7 @@ </table> </form> <!--javascript that is needed for tooltips--> -<script type="text/javascript" src='/static/domTT.js'></script> +<script type="text/javascript" src="/static/domTT.js"></script> <link rel="stylesheet" type="text/css" href="/static/domTT.css"/> diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-2.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-2.txt index 88a298fa9..e04c68858 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-2.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-2.txt @@ -15,5 +15,5 @@ </table> </form> <!--javascript that is needed for tooltips--> -<script type="text/javascript" src='/static/domTT.js'></script> -<link rel="stylesheet" type="text/css" href="/static/domTT.css"/> \ No newline at end of file +<script type="text/javascript" src="/static/domTT.js"></script> +<link rel="stylesheet" type="text/css" href="/static/domTT.css"/> diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-3.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-3.txt index 2c1e49b45..a70521455 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-3.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/tooltip-3.txt @@ -16,6 +16,6 @@ </form> <!--javascript that is needed for tooltips--> -<script type="text/javascript" src='/static/domTT.js'></script> +<script type="text/javascript" src="/static/domTT.js"></script> <link rel="stylesheet" type="text/css" href="/static/domTT.css"/> diff --git a/plugins/config-browser/src/main/resources/config-browser/showValidators.ftl b/plugins/config-browser/src/main/resources/config-browser/showValidators.ftl index ad98169f2..068198180 100644 --- a/plugins/config-browser/src/main/resources/config-browser/showValidators.ftl +++ b/plugins/config-browser/src/main/resources/config-browser/showValidators.ftl @@ -20,18 +20,26 @@ --> <!-- Validators --> <table width="100%"> - <tr><th>Field</th><th>Type</th><th> </th></tr> + <tr> + <th>Field</th> + <th>Type</th> + <th> </th> + </tr> <#assign row = 0> - <#if validators??> - <#foreach i in validators> - <tr <#if i_index%2 gt 0>class="b"<#else>class="a"</#if>> - <td>${i.fieldName!"(see expression)"}</td> - <td>${action.stripPackage(i.class)}</td> - <td> - <a href="#" onClick="window.open('validatorDetails.${extension}?clazz=${clazz}&context=${context}&selected=${row}', 'Validator Details', 'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=640,height=480');">details</a> - </td> - </tr> - <#assign row = row + 1> + <#if validators??> + <#foreach i in validators> + <tr <#if i_index%2 gt 0>class="b" <#else>class="a"</#if>> + <td>${i.fieldName!"(see expression)"}</td> + <td>${action.stripPackage(i.class)}</td> + <td><a href="#" id="show-validators">details</a></td> + </tr> + <#assign row = row + 1> </#foreach> - </#if> + </#if> </table> +<@s.script> + document.getElementById('show-validators').onclick = function() { + window.open('validatorDetails.${extension}?clazz=${clazz}&context=${context}&selected=${row}', 'Validator Details', 'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=640,height=480'); + return false; + } +</@s.script>
