This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/main by this push: new 695a69479 Replaces parameters with attributes (#270) 695a69479 is described below commit 695a69479bae851bfc541458fb50ab7f84112d86 Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Thu May 29 07:59:17 2025 +0200 Replaces parameters with attributes (#270) --- .../core-developers/ajax-client-side-validation.md | 58 +++++++++++----------- source/getting-started/themes.md | 6 +-- source/plugins/json/json-ajax-validation.md | 58 +++++++++++----------- source/tag-developers/ajax-theme.md | 10 ++-- source/tag-developers/extending-themes.md | 14 +++--- source/tag-developers/form-tags.md | 8 +-- source/tag-developers/freemarker-tags.md | 14 +++--- source/tag-developers/freemarker.md | 6 +-- source/tag-developers/xhtml-theme.md | 2 +- 9 files changed, 90 insertions(+), 86 deletions(-) diff --git a/source/core-developers/ajax-client-side-validation.md b/source/core-developers/ajax-client-side-validation.md index 139013aa3..b9e47ed69 100644 --- a/source/core-developers/ajax-client-side-validation.md +++ b/source/core-developers/ajax-client-side-validation.md @@ -224,22 +224,22 @@ parent = xhtml Make sure element is always present. To be filled later via JS. --> <ul<#rt/> -<#if parameters.id??> - id="${parameters.id?html}"<#rt/> +<#if attributes.id??> + id="${attributes.id?html}"<#rt/> </#if> -<#if parameters.cssClass??> - class="${parameters.cssClass?html}"<#rt/> +<#if attributes.cssClass??> + class="${attributes.cssClass?html}"<#rt/> <#else> class="errorMessage"<#rt/> </#if> -<#if parameters.cssStyle??> - style="${parameters.cssStyle?html}"<#rt/> +<#if attributes.cssStyle??> + style="${attributes.cssStyle?html}"<#rt/> </#if> > <#if (actionErrors?? && actionErrors?size > 0)> <#list actionErrors as error> <#if error??> - <li><span><#if parameters.escape>${error!?html}<#else>${error!}</#if></span><#rt/></li><#rt/> + <li><span><#if attributes.escape>${error!?html}<#else>${error!}</#if></span><#rt/></li><#rt/> </#if> </#list> </#if> @@ -249,16 +249,16 @@ parent = xhtml **controlfooter.ftl** ```ftl -${parameters.after!}<#t/> +${attributes.after!}<#t/> </td><#lt/> </tr> -<#if (parameters.errorposition!"top") == 'bottom'> -<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> +<#if (attributes.errorposition!"top") == 'bottom'> +<#assign hasFieldErrors = attributes.name?? && fieldErrors?? && fieldErrors[attributes.name]??/> <#if hasFieldErrors> -<tr errorFor="${parameters.id}"> +<tr errorFor="${attributes.id}"> <td class="tdErrorMessage" colspan="2"><#rt/> <#if hasFieldErrors> - <#list fieldErrors[parameters.name] as error> + <#list fieldErrors[attributes.name] as error> <div class="errorMessage">${error?html}</div><#t/> </#list> </#if> @@ -274,22 +274,22 @@ ${parameters.after!}<#t/> <#-- Always include elements to show errors. They may be filled later via AJAX. --> -<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> -<#if (parameters.errorposition!"top") == 'top'> -<tr errorFor="${parameters.id}"> - <td class="tdErrorMessage" colspan="2" data-error-for-fieldname="${parameters.name}"><#rt/> +<#assign hasFieldErrors = attributes.name?? && fieldErrors?? && fieldErrors[attributes.name]??/> +<#if (attributes.errorposition!"top") == 'top'> +<tr errorFor="${attributes.id}"> + <td class="tdErrorMessage" colspan="2" data-error-for-fieldname="${attributes.name}"><#rt/> <#if hasFieldErrors> - <#list fieldErrors[parameters.name] as error> + <#list fieldErrors[attributes.name] as error> <div class="errorMessage">${error?html}</div><#t/> </#list> </#if> </td><#lt/> </tr> </#if> -<#if !parameters.labelposition?? && (parameters.form.labelposition)??> -<#assign labelpos = parameters.form.labelposition/> -<#elseif parameters.labelposition??> -<#assign labelpos = parameters.labelposition/> +<#if !attributes.labelposition?? && (attributes.form.labelposition)??> +<#assign labelpos = attributes.form.labelposition/> +<#elseif attributes.labelposition??> +<#assign labelpos = attributes.labelposition/> </#if> <#-- if the label position is top, @@ -301,10 +301,10 @@ ${parameters.after!}<#t/> <#else> <td class="tdLabel"><#rt/> </#if> -<#if parameters.label??> +<#if attributes.label??> <label <#t/> -<#if parameters.id??> - for="${parameters.id?html}" <#t/> +<#if attributes.id??> + for="${attributes.id?html}" <#t/> </#if> <#if hasFieldErrors> class="errorLabel"<#t/> @@ -312,15 +312,15 @@ ${parameters.after!}<#t/> class="label"<#t/> </#if> ><#t/> -<#if parameters.required!false && parameters.requiredPosition!"right" != 'right'> +<#if attributes.required!false && attributes.requiredPosition!"right" != 'right'> <span class="required">*</span><#t/> </#if> -${parameters.label?html}<#t/> -<#if parameters.required!false && parameters.requiredPosition!"right" == 'right'> +${attributes.label?html}<#t/> +<#if attributes.required!false && attributes.requiredPosition!"right" == 'right'> <span class="required">*</span><#t/> </#if> -${parameters.labelseparator!":"?html}<#t/> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/tooltip.ftl" /> +${attributes.labelseparator!":"?html}<#t/> +<#include "/${attributes.templateDir}/${attributes.expandTheme}/tooltip.ftl" /> </label><#t/> </#if> </td><#lt/> diff --git a/source/getting-started/themes.md b/source/getting-started/themes.md index cb8279465..67b34e19a 100644 --- a/source/getting-started/themes.md +++ b/source/getting-started/themes.md @@ -157,11 +157,11 @@ I then modified the `checkboxlist.ftl` in the KUTheme folder to be: **Modified checkboxlist.ftl** ```ftl -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${attributes.templateDir}/${attributes.expandTheme}/controlheader.ftl" /> -<#include "/${parameters.templateDir}/KUTheme_simple/checkboxlist.ftl" /> +<#include "/${attributes.templateDir}/KUTheme_simple/checkboxlist.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /><#nt/> +<#include "/${attributes.templateDir}/${attributes.expandTheme}/controlfooter.ftl" /><#nt/> ``` Be sure to note the change to the second line—using KUTheme_simple in the path. diff --git a/source/plugins/json/json-ajax-validation.md b/source/plugins/json/json-ajax-validation.md index b2c73bb9d..77de4947e 100644 --- a/source/plugins/json/json-ajax-validation.md +++ b/source/plugins/json/json-ajax-validation.md @@ -211,22 +211,22 @@ parent = xhtml Make sure element is always present. To be filled later via JS. --> <ul<#rt/> -<#if parameters.id??> - id="${parameters.id?html}"<#rt/> +<#if attributes.id??> + id="${attributes.id?html}"<#rt/> </#if> -<#if parameters.cssClass??> - class="${parameters.cssClass?html}"<#rt/> +<#if attributes.cssClass??> + class="${attributes.cssClass?html}"<#rt/> <#else> class="errorMessage"<#rt/> </#if> -<#if parameters.cssStyle??> - style="${parameters.cssStyle?html}"<#rt/> +<#if attributes.cssStyle??> + style="${attributes.cssStyle?html}"<#rt/> </#if> > <#if (actionErrors?? && actionErrors?size > 0)> <#list actionErrors as error> <#if error??> - <li><span><#if parameters.escape>${error!?html}<#else>${error!}</#if></span><#rt/></li><#rt/> + <li><span><#if attributes.escape>${error!?html}<#else>${error!}</#if></span><#rt/></li><#rt/> </#if> </#list> </#if> @@ -236,16 +236,16 @@ parent = xhtml #### controlfooter.ftl ```html -${parameters.after!}<#t/> +${attributes.after!}<#t/> </td><#lt/> </tr> -<#if (parameters.errorposition!"top") == 'bottom'> -<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> +<#if (attributes.errorposition!"top") == 'bottom'> +<#assign hasFieldErrors = attributes.name?? && fieldErrors?? && fieldErrors[attributes.name]??/> <#if hasFieldErrors> -<tr errorFor="${parameters.id}"> +<tr errorFor="${attributes.id}"> <td class="tdErrorMessage" colspan="2"><#rt/> <#if hasFieldErrors> - <#list fieldErrors[parameters.name] as error> + <#list fieldErrors[attributes.name] as error> <div class="errorMessage">${error?html}</div><#t/> </#list> </#if> @@ -261,22 +261,22 @@ ${parameters.after!}<#t/> <#-- Always include elements to show errors. They may be filled later via AJAX. --> -<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/> -<#if (parameters.errorposition!"top") == 'top'> -<tr errorFor="${parameters.id}"> - <td class="tdErrorMessage" colspan="2" data-error-for-fieldname="${parameters.name}"><#rt/> +<#assign hasFieldErrors = attributes.name?? && fieldErrors?? && fieldErrors[attributes.name]??/> +<#if (attributes.errorposition!"top") == 'top'> +<tr errorFor="${attributes.id}"> + <td class="tdErrorMessage" colspan="2" data-error-for-fieldname="${attributes.name}"><#rt/> <#if hasFieldErrors> - <#list fieldErrors[parameters.name] as error> + <#list fieldErrors[attributes.name] as error> <div class="errorMessage">${error?html}</div><#t/> </#list> </#if> </td><#lt/> </tr> </#if> -<#if !parameters.labelposition?? && (parameters.form.labelposition)??> -<#assign labelpos = parameters.form.labelposition/> -<#elseif parameters.labelposition??> -<#assign labelpos = parameters.labelposition/> +<#if !attributes.labelposition?? && (attributes.form.labelposition)??> +<#assign labelpos = attributes.form.labelposition/> +<#elseif attributes.labelposition??> +<#assign labelpos = attributes.labelposition/> </#if> <#-- if the label position is top, @@ -288,10 +288,10 @@ ${parameters.after!}<#t/> <#else> <td class="tdLabel"><#rt/> </#if> -<#if parameters.label??> +<#if attributes.label??> <label <#t/> -<#if parameters.id??> - for="${parameters.id?html}" <#t/> +<#if attributes.id??> + for="${attributes.id?html}" <#t/> </#if> <#if hasFieldErrors> class="errorLabel"<#t/> @@ -299,15 +299,15 @@ ${parameters.after!}<#t/> class="label"<#t/> </#if> ><#t/> -<#if parameters.required!false && parameters.requiredPosition!"right" != 'right'> +<#if attributes.required!false && attributes.requiredPosition!"right" != 'right'> <span class="required">*</span><#t/> </#if> -${parameters.label?html}<#t/> -<#if parameters.required!false && parameters.requiredPosition!"right" == 'right'> +${attributes.label?html}<#t/> +<#if attributes.required!false && attributes.requiredPosition!"right" == 'right'> <span class="required">*</span><#t/> </#if> -${parameters.labelseparator!":"?html}<#t/> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/tooltip.ftl" /> +${attributes.labelseparator!":"?html}<#t/> +<#include "/${attributes.templateDir}/${attributes.expandTheme}/tooltip.ftl" /> </label><#t/> </#if> </td><#lt/> diff --git a/source/tag-developers/ajax-theme.md b/source/tag-developers/ajax-theme.md index 9a52a0dff..287508bde 100644 --- a/source/tag-developers/ajax-theme.md +++ b/source/tag-developers/ajax-theme.md @@ -42,13 +42,13 @@ The wrapping technique utilized by the ajax theme is much like [xhtml theme](xht is a wee bit different. ```ftl -<#if parameters.label?if_exists != ""> - <#include "/${parameters.templateDir}/xhtml/controlheader.ftl" /> +<#if attributes.label?if_exists != ""> + <#include "/${attributes.templateDir}/xhtml/controlheader.ftl" /> </#if> -<#if parameters.form?exists && parameters.form.validate?default(false) == true> +<#if attributes.form?exists && attributes.form.validate?default(false) == true> <#-- can't mutate the data model in freemarker --> - <#if parameters.onblur?exists> - ${tag.addParameter('onblur', "validate(this);${parameters.onblur}")} + <#if attributes.onblur?exists> + ${tag.addParameter('onblur', "validate(this);${attributes.onblur}")} <#else> ${tag.addParameter('onblur', "validate(this);")} </#if> diff --git a/source/tag-developers/extending-themes.md b/source/tag-developers/extending-themes.md index c57cb9406..4bd29f017 100644 --- a/source/tag-developers/extending-themes.md +++ b/source/tag-developers/extending-themes.md @@ -35,10 +35,12 @@ by adding a header and footer. ### Wrapping a control +> NOTE: Since Struts 7.x the `parameters` have been replaced with `attributes` + ```ftl -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> -<#include "/${parameters.templateDir}/simple/xxx.ftl" /> -<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> +<#include "/${attributes.templateDir}/${attributes.expandTheme}/controlheader.ftl" /> +<#include "/${attributes.templateDir}/simple/xxx.ftl" /> +<#include "/${attributes.templateDir}/${attributes.expandTheme}/controlfooter.ftl" /> ``` Wrapping is a great way to augment the basic HTML elements provided by the simple theme. @@ -59,7 +61,7 @@ parent = xhtml An extended theme does not need to implement every single template that the [Struts Tags](struts-tags) expect. It only needs to implement the templates that change. The other templates are loaded from the parent template. -## Special parameters +## Special attributes [UIBean](http://struts.apache.org/maven/struts2-core/apidocs/org/apache/struts2/components/UIBean) provides few special parameters which can be used to build a new template (they are already used in `xhtml` and `css_xhtml` theme): @@ -75,11 +77,11 @@ special parameters which can be used to build a new template (they are already u Using `expandTheme` parameter allows to override only some parts of the theme's templates, e.g. `css.ftl`. You can define a new theme (set `theme.properties`) and override just single file. -`${parameters.expandTheme}` is a recurrence which tells `ThemeManager` to load template from current theme and then +`${attributes.expandTheme}` is a recurrence which tells `ThemeManager` to load template from current theme and then from parent theme (defined in `theme.properties`) and so on. Please also notice that the `ThemeManager` builds list of possible templates based on current theme and inherited themes (`/template/custom/textarea.ftl`, `/template/xhtml/textarea.ftl`, `/template/simple/textarea.ftl`). This is also -true for templates which are loaded via `${parameters.expandTheme}`. +true for templates which are loaded via `${attributes.expandTheme}`. > See also example [Struts 2 Themes]() or [Creating a Theme in Struts > 2](http://www.vitarara.org/cms/struts_2_cookbook/creating_a_theme) (Mark > Menard) diff --git a/source/tag-developers/form-tags.md b/source/tag-developers/form-tags.md index 643560973..6d2b5814d 100644 --- a/source/tag-developers/form-tags.md +++ b/source/tag-developers/form-tags.md @@ -42,9 +42,9 @@ All the form tags extend the UIBean class. This base class provides a set of com in to three categories: _templated-related_, _javascript-related_, and _general_ attributes. The individual attributes are documented on each tag's reference page. -In addition to the common attributes, a special attribute exists for all form element tags: `form` (`${parameters.form}`). +In addition to the common attributes, a special attribute exists for all form element tags: `form` (`${attributes.form}`). The `form` 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}`. +the form's ID can be found by calling `${attributes.form.id}`. ## Template-Related Attributes @@ -134,8 +134,8 @@ If a `value` is not specified, by default, the JavaBean accessor is used instead </@s.form> ``` -While most attributes are exposed to the underlying templates as the same key as the attribute (`${parameters.label}`), -the `value` attribute is not. Instead, it can be accessed via the `nameValue` key (`${parameters.nameValue}`). +While most attributes are exposed to the underlying templates as the same key as the attribute (`${attributes.label}`), +the `value` attribute is not. Instead, it can be accessed via the `nameValue` key (`${attributes.nameValue}`). The `nameValue` key indicates that the value may have been generated from the `name` attribute rather than explicitly defined in the `value` attribute. diff --git a/source/tag-developers/freemarker-tags.md b/source/tag-developers/freemarker-tags.md index 72041dd31..497807f9b 100644 --- a/source/tag-developers/freemarker-tags.md +++ b/source/tag-developers/freemarker-tags.md @@ -50,12 +50,14 @@ pages even easier to code. You can even invoke third-party JSP taglibs as if the ## Attributes and Parameters +> NOTE: Since Struts 7.x the `parameters` have been replaced with `attributes` + Unlike older versions of JSP (in which the [JSP Tags](jsp-tags) are based), FreeMarker allows for _dynamic attributes_, -much like JSP 2.0. You can supply attributes to the tags that the tag doesn't explicitedly support. Those attributes -that cannot be applied directly to the tag object will be set to the tag's general-purpose `parameters` Map. +much like JSP 2.0. You can supply attributes to the tags that the tag doesn't explicitly support. Those attributes +that cannot be applied directly to the tag object will be set to the tag's general-purpose `attributes` Map. -Suppose we wanted to build an URL in a JSP. The URL needs to take an arbitary parameter to the query string, -that (being arbitary) isn't specified on the URL tag. In a JSP, we'd have to use the `url` and `param` tags together. +Suppose we wanted to build an URL in a JSP. The URL needs to take an arbitrary parameter to the query string, +that (being arbitrary) isn't specified on the URL tag. In a JSP, we'd have to use the `url` and `param` tags together. **Creating a URL with a query string (JSP)** @@ -88,9 +90,9 @@ attribute into the textfield tag, no fuss, no muss. </@s.form> ``` -In the new template, the description is referenced via the parameters Map: `${parameters.description}`. +In the new template, the description is referenced via the attributes Map: `${attributes.description}`. -> For simple cases, inline attributes are much easier to use than the param} tag. But, the `param` tag is more flexible +> For simple cases, inline attributes are much easier to use than the param tag. But, the `param` tag is more flexible > than inline attributes for advanced use cases. For example, `param` can take > the entire body of the tag and apply > that as the `value` attribute. diff --git a/source/tag-developers/freemarker.md b/source/tag-developers/freemarker.md index 6a5d73c11..99719521f 100644 --- a/source/tag-developers/freemarker.md +++ b/source/tag-developers/freemarker.md @@ -113,15 +113,15 @@ or Assuming there's a request parameter `myParameter` (eg. [http://host/myApp/myAction.action?myParameter=one]). ```ftl -<#if Parameters.myParameter?exists> - ${Parameters.myParameter} +<#if attributes.myParameter?exists> + ${attributes.myParameter} </#if> ``` or ```ftl -<@s.property value="%{#parameters.myParameter}" /> +<@s.property value="%{#attributes.myParameter}" /> ``` ### Context parameter diff --git a/source/tag-developers/xhtml-theme.md b/source/tag-developers/xhtml-theme.md index d75dc826d..feb021489 100644 --- a/source/tag-developers/xhtml-theme.md +++ b/source/tag-developers/xhtml-theme.md @@ -32,7 +32,7 @@ and `controlfooter.ftl` templates are wrapped around the simple template. {% remote_file_content https://raw.githubusercontent.com/apache/struts/main/core/src/main/resources/template/xhtml/text.ftl %} {% endhighlight %} -> The `controlheader.ftl` is referenced using `${parameters.theme}` so that the code can be reused +> The `controlheader.ftl` is referenced using `${attributes.theme}` so that the code can be reused > by the [ajax theme](ajax-theme). ## XHTML Theme Header