Skip to content

Commit

Permalink
WW-5465 Renames tag parameters to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Oct 6, 2024
1 parent ddc2944 commit d403f1b
Show file tree
Hide file tree
Showing 143 changed files with 1,483 additions and 1,496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<div style="background-color:yellow;">
<p>
Freemarker Custom Template -
parameter 'paramName' - ${parameters.paramName}
parameter 'paramName' - ${attributes.paramName}
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
Make sure element is always present. To be filled later via JS.
-->
<ul<#rt/>
<#if parameters.id??>
id="${parameters.id}"<#rt/>
</#if>
<#if parameters.cssClass??>
class="${parameters.cssClass}"<#rt/>
<#if attributes.id??>
id="${attributes.id}"<#rt/>
</#if>
<#if attributes.cssClass??>
class="${attributes.cssClass}"<#rt/>
<#else>
class="errorMessage"<#rt/>
</#if>
<#if parameters.cssStyle??>
style="${parameters.cssStyle}"<#rt/>
<#if attributes.cssStyle??>
style="${attributes.cssStyle}"<#rt/>
</#if>
>
<#if (actionErrors?? && actionErrors?size > 0)>
<#list actionErrors as error>
<#if error??>
<li><span><#if parameters.escape>${error!}<#else>${error!}</#if></span><#rt/></li><#rt/>
<li><span><#if attributes.escape>${error!}<#else>${error!}</#if></span><#rt/></li><#rt/>
</#if>
</#list>
</#if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
* under the License.
*/
-->
${parameters.after!}<#t/>
${attributes.after!}<#t/>
</td><#lt/>
</tr>
<#if (parameters.errorposition!"top") == 'bottom'>
<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors.get(parameters.name)??/>
<#if (attributes.errorposition!"top") == 'bottom'>
<#assign hasFieldErrors = attributes.name?? && fieldErrors?? && fieldErrors.get(attributes.name)??/>
<#if hasFieldErrors>
<tr errorFor="${parameters.id}">
<tr errorFor="${attributes.id}">
<td class="tdErrorMessage" colspan="2"><#rt/>
<#if hasFieldErrors>
<#list fieldErrors.get(parameters.name) as error>
<#list fieldErrors.get(attributes.name) as error>
<div class="errorMessage">${error}</div><#t/>
</#list>
</#if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
<#--
Always include elements to show errors. They may be filled later via AJAX.
-->
<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors.get(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.get(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.get(parameters.name) as error>
<#list fieldErrors.get(attributes.name) as error>
<div class="errorMessage">${error}</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,
Expand All @@ -48,26 +48,26 @@
<#else>
<td class="tdLabel"><#rt/>
</#if>
<#if parameters.label??>
<#if attributes.label??>
<label <#t/>
<#if parameters.id??>
for="${parameters.id}" <#t/>
<#if attributes.id??>
for="${attributes.id}" <#t/>
</#if>
<#if hasFieldErrors>
class="errorLabel"<#t/>
<#else>
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}<#t/>
<#if parameters.required!false && parameters.requiredPosition!"right" == 'right'>
${attributes.label}<#t/>
<#if attributes.required!false && attributes.requiredPosition!"right" == 'right'>
<span class="required">*</span><#t/>
</#if>
${parameters.labelseparator!":"}<#t/>
<#include "/${parameters.templateDir}/${parameters.expandTheme}/tooltip.ftl" />
${attributes.labelseparator!":"}<#t/>
<#include "/${attributes.templateDir}/${attributes.expandTheme}/tooltip.ftl" />
</label><#t/>
</#if>
</td><#lt/>
Expand Down
110 changes: 55 additions & 55 deletions apps/showcase/src/main/webapp/WEB-INF/tags/ui/componentTagExample.jsp
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - UI Tags - Component Tag</title>
<s:head/>
<title>Struts2 Showcase - UI Tags - Component Tag</title>
<s:head/>
</head>
<body>
<div class="page-header">
<h1>UI Tags - Component Tag</h1>
<h1>UI Tags - Component Tag</h1>
</div>

<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<p>This example tries to demonstrates the usage of &lt;s:component ... &gt; tag.<p/>
<div class="row">
<div class="col-md-12">
<p>This example tries to demonstrate the usage of &lt;s:component ... &gt; tag.</p>

<p>To have a look at the source of this jsp page click
<s:url var="url" action="showComponentTagExampleCode" namespace="/tags/ui"/>
<s:a href="%{#url}">here</s:a>
<p/>
<p>To have a look at the source of this jsp page click
<s:url var="url" action="showComponentTagExampleCode" namespace="/tags/ui"/>
<s:a href="%{#url}">here</s:a>
</p>

<b>Example 1:</b>
<p>This example load the template from the webapp context path using
the default (ftl) as its template.
<s:component
theme="customTheme"
templateDir="customTemplateDir"
template="ftlCustomTemplate">
<s:param name="paramName" value="%{'paramValue1'}" />
</s:component>
<p/>
<b>Example 1:</b>
<p>This example load the template from the webapp context path using
the default (ftl) as its template.
<s:component
theme="customTheme"
templateDir="customTemplateDir"
template="ftlCustomTemplate">
<s:param name="paramName" value="%{'paramValue1'}"/>
</s:component>
</p>

<b>Example 2:</b>
<p>This example load the template from the webapp context path using
jsp as its template (notice the *.jsp extension to the template).
<s:component
theme="customTheme"
templateDir="customTemplateDir"
template="jspCustomTemplate.jsp">
<s:param name="paramName" value="%{'paramValue2'}" />
</s:component>
<p/>
<b>Example 2:</b>
<p>This example load the template from the webapp context path using
jsp as its template (notice the *.jsp extension to the template).
<s:component
theme="customTheme"
templateDir="customTemplateDir"
template="jspCustomTemplate.jsp">
<s:param name="paramName" value="%{'paramValue2'}"/>
</s:component>
</p>

<b>Example 3</b>
<p>This example load the template from the webapp context path,
using the default template directory and theme (default to
'template' and 'xhtml' respectively)
<s:component template="mytemplate.jsp">
<s:param name="paramName" value="%{'paramValue3'}" />
</s:component>
<p/>
<b>Example 3</b>
<p>This example load the template from the webapp context path,
using the default template directory and theme (default to
'template' and 'xhtml' respectively)
<s:component template="mytemplate.jsp">
<s:param name="paramName" value="%{'paramValue3'}"/>
</s:component>
</p>


<b>Example 4</b>
<p>This example load the template from the webapp classpath using
a custom themplate directory and theme.
<s:component
theme="myTheme"
templateDir="myTemplateDir"
template="myAnotherTemplate">
<s:param name="paramName" value="%{'paramValue4'}" />
</s:component>
<p/>
</div>
</div>
<b>Example 4</b>
<p>This example load the template from the webapp classpath using
a custom themplate directory and theme.
<s:component
theme="myTheme"
templateDir="myTemplateDir"
template="myAnotherTemplate">
<s:param name="paramName" value="%{'paramValue4'}"/>
</s:component>
</p>
</div>
</div>
</div>
</body>
</html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div style="background-color:yellow;">
<p>
Freemarker Custom Template -
parameter 'paramName' - ${parameters.paramName}
parameter 'paramName' - ${attributes.paramName}
</p>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<div style="background-color:yellow;">
<p>
JSP Custom Template -
parameter 'paramName' - <s:property value="%{top.parameters.paramName}" />
JSP Custom Template -
parameter 'paramName' - <s:property value="%{attributes.paramName}" />
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<div style="background-color:yellow;">
<p>
JSP Custom Template -
parameter 'paramName' - <s:property value="%{parameters.paramName}" />
parameter 'paramName' - <s:property value="%{attributes.paramName}" />
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ protected Map<String, Object> createExtraContext() {
}

/**
* Creates parameters map using parameters from the value stack and component parameters. Any non-String array
* values will be converted into a single-value String array.
* Creates {@link HttpParameters} using parameters from the value stack and component attributes.
* Any non-String array values will be converted into a single-value String array.
*
* @return A map of String[] parameters
* @return Instance of {@link HttpParameters}
*/
protected HttpParameters createParametersForContext() {
HttpParameters parentParams = null;
Expand All @@ -208,8 +208,8 @@ protected HttpParameters createParametersForContext() {

HttpParameters.Builder builder = HttpParameters.create().withParent(parentParams);

if (parameters != null) {
builder = builder.withExtraParams(parameters);
if (attributes != null) {
builder = builder.withExtraParams(attributes);
}
return builder.build();
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/apache/struts2/components/Anchor.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class Anchor extends ClosingUIBean {
protected boolean processingTagBody = false;

//these params are passed by the Param tag
protected Map urlParameters = new LinkedHashMap();
protected Map<String, Object> urlParameters = new LinkedHashMap<>();

public Anchor(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
Expand Down Expand Up @@ -172,16 +172,16 @@ public void addParameter(String key, Object value) {
}

@Override
public void addAllParameters(Map params) {
public void addAllAttributes(Map<String, Object> additionalAttributes) {
/*
the parameters added by this method are used in the template. this method is also
called by Param to add params into ancestestor. This tag needs to keep both set of parameters
The attributes added by this method are used in the template. This method is also
called by Param to add attributes into an ancestor. This tag needs to keep both set of parameters
separated (You gotta keep 'em separated!)
*/
if (processingTagBody) {
this.urlParameters.putAll(params);
this.urlParameters.putAll(additionalAttributes);
} else {
super.addAllParameters(params);
super.addAllAttributes(additionalAttributes);
}
}

Expand Down
Loading

0 comments on commit d403f1b

Please sign in to comment.