Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/apache/struts into fix/do…
Browse files Browse the repository at this point in the history
…uble_evaluations

� Conflicts:
�	core/src/main/java/org/apache/struts2/components/UIBean.java
  • Loading branch information
yasserzamani committed Jul 4, 2021
2 parents 3a62e32 + dd807e7 commit 56836c4
Show file tree
Hide file tree
Showing 84 changed files with 13,347 additions and 150 deletions.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
@@ -1,2 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Expand Up @@ -22,12 +22,12 @@ ${parameters.after!}<#t/>
</td><#lt/>
</tr>
<#if (parameters.errorposition!"top") == 'bottom'>
<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/>
<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors.get(parameters.name)??/>
<#if hasFieldErrors>
<tr errorFor="${parameters.id}">
<td class="tdErrorMessage" colspan="2"><#rt/>
<#if hasFieldErrors>
<#list fieldErrors[parameters.name] as error>
<#list fieldErrors.get(parameters.name) as error>
<div class="errorMessage">${error}</div><#t/>
</#list>
</#if>
Expand Down
Expand Up @@ -21,29 +21,29 @@
<#--
Always include elements to show errors. They may be filled later via AJAX.
-->
<#assign hasFieldErrors = parameters.name?? && fieldErrors?? && fieldErrors[parameters.name]??/>
<#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/>
<#if hasFieldErrors>
<#list fieldErrors[parameters.name] as error>
<#list fieldErrors.get(parameters.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 !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'>
<#if (labelPos!"") == 'top'>
<td class="tdLabelTop" colspan="2"><#rt/>
<#else>
<td class="tdLabel"><#rt/>
Expand Down Expand Up @@ -72,7 +72,7 @@ ${parameters.labelseparator!":"}<#t/>
</#if>
</td><#lt/>
<#-- add the extra row -->
<#if (labelpos!"") == 'top'>
<#if (labelPos!"") == 'top'>
</tr>
<tr>
</#if>
Expand Up @@ -1076,8 +1076,12 @@ private List<Document> loadConfigurationFiles(String fileName, Element includeEl
InputSource in = new InputSource(is);

in.setSystemId(url.toString());

docs.add(DomHelper.parse(in, dtdMappings));

Document helperDoc = DomHelper.parse(in, dtdMappings);
if (helperDoc != null) {
docs.add(helperDoc);
}

loadedFileUrls.add(url.toString());
} catch (StrutsException e) {
if (includeElement != null) {
Expand Down
Expand Up @@ -105,7 +105,7 @@ public String intercept(ActionInvocation invocation) throws Exception {
* Refreshes the model instance on the value stack, if it has changed
*/
protected static class RefreshModelBeforeResult implements PreResultListener {
private Object originalModel = null;
private Object originalModel;
protected ModelDriven action;


Expand All @@ -122,10 +122,12 @@ public void beforeResult(ActionInvocation invocation, String resultCode) {
Object newModel = action.getModel();

// Check to see if the new model instance is already on the stack
for (Object item : root) {
if (item.equals(newModel)) {
needsRefresh = false;
break;
if (newModel != null) {
for (Object item : root) {
if (item == newModel) {
needsRefresh = false;
break;
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions core/src/main/java/org/apache/struts2/components/Checkbox.java
Expand Up @@ -94,4 +94,22 @@ public void setFieldValue(String fieldValue) {
public void setSubmitUnchecked(String submitUnchecked) {
this.submitUnchecked = submitUnchecked;
}

/**
* Deprecated since 2.5.27
* @deprecated use {@link #setLabelPosition(String)} instead
*/
@Deprecated
@Override
@StrutsTagAttribute(description="(Deprecated) Define label position of form element (top/left), also 'right' is supported when using 'xhtml' theme")
public void setLabelposition(String labelPosition) {
super.setLabelPosition(labelPosition);
}

@Override
@StrutsTagAttribute(description="Define label position of form element (top/left), also 'right' is supported when using 'xhtml' theme")
public void setLabelPosition(String labelPosition) {
super.setLabelPosition(labelPosition);
}

}
25 changes: 19 additions & 6 deletions core/src/main/java/org/apache/struts2/components/UIBean.java
Expand Up @@ -641,7 +641,7 @@ public String getTheme() {

public void evaluateParams() {
String gotTheme = getTheme();

addParameter("templateDir", getTemplateDir());
addParameter("theme", gotTheme);
addParameter("template", template != null ? findString(template) : getDefaultTemplate());
Expand Down Expand Up @@ -685,7 +685,9 @@ public void evaluateParams() {
}

if (labelPosition != null) {
addParameter("labelposition", findString(labelPosition));
String labelPosition = findString(this.labelPosition);
addParameter("labelposition", labelPosition);
addParameter("labelPosition", labelPosition);
}

if (requiredPosition != null) {
Expand All @@ -695,7 +697,7 @@ public void evaluateParams() {
if (errorPosition != null) {
addParameter("errorposition", findString(errorPosition));
}

if (requiredLabel != null) {
addParameter("required", findValue(requiredLabel, Boolean.class));
}
Expand Down Expand Up @@ -1066,7 +1068,8 @@ public void setCssClass(String cssClass) {
this.cssClass = cssClass;
}

@StrutsTagAttribute(description="The css class to use for element - it's an alias of cssClass attribute.")
@Deprecated
@StrutsTagAttribute(description="(Deprecated) The css class to use for element - it's an alias of cssClass attribute.")
public void setClass(String cssClass) {
this.cssClass = cssClass;
}
Expand Down Expand Up @@ -1111,11 +1114,21 @@ public void setLabelSeparator(String labelseparator) {
this.labelSeparator = labelseparator;
}

@StrutsTagAttribute(description="Define label position of form element (top/left)")
/**
* Deprecated since 2.5.27
* @deprecated use {@link #setLabelPosition(String)} instead
*/
@StrutsTagAttribute(description="(Deprecated) Define label position of form element (top/left)")
@Deprecated
public void setLabelposition(String labelPosition) {
this.labelPosition = labelPosition;
}

@StrutsTagAttribute(description="Define label position of form element (top/left)")
public void setLabelPosition(String labelPosition) {
this.labelPosition = labelPosition;
}

@StrutsTagAttribute(description="Define required position of required form element (left|right)")
public void setRequiredPosition(String requiredPosition) {
this.requiredPosition = requiredPosition;
Expand All @@ -1125,7 +1138,7 @@ public void setRequiredPosition(String requiredPosition) {
public void setErrorPosition(String errorPosition) {
this.errorPosition = errorPosition;
}

@StrutsTagAttribute(description="The name to set for element")
public void setName(String name) {
this.name = name;
Expand Down
Expand Up @@ -18,9 +18,7 @@
*/
package org.apache.struts2.views.jsp.ui;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.struts2.components.UIBean;
import org.apache.struts2.util.ComponentUtils;
import org.apache.struts2.views.jsp.ComponentTagSupport;

import javax.servlet.jsp.JspException;
Expand All @@ -40,7 +38,7 @@ public abstract class AbstractUITag extends ComponentTagSupport implements Dynam
protected String disabled;
protected String label;
protected String labelSeparator;
protected String labelposition;
protected String labelPosition;
protected String requiredPosition;
protected String errorPosition;
protected String name;
Expand Down Expand Up @@ -92,7 +90,7 @@ protected void populateParams() {
uiBean.setDisabled(disabled);
uiBean.setLabel(label);
uiBean.setLabelSeparator(labelSeparator);
uiBean.setLabelposition(labelposition);
uiBean.setLabelPosition(labelPosition);
uiBean.setRequiredPosition(requiredPosition);
uiBean.setErrorPosition(errorPosition);
uiBean.setName(name);
Expand Down Expand Up @@ -137,6 +135,10 @@ public void setCssClass(String cssClass) {
this.cssClass = cssClass;
}

/**
* @deprecated Use {@link #setCssClass(String)} instead
*/
@Deprecated
public void setClass(String cssClass) {
this.cssClass = cssClass;
}
Expand Down Expand Up @@ -169,8 +171,17 @@ public void setLabel(String label) {
this.label = label;
}

/**
* Deprecated since 2.5.27
* @deprecated use {@link #setLabelPosition(String)} instead
*/
@Deprecated
public void setLabelposition(String labelPosition) {
this.labelposition = labelPosition;
this.labelPosition = labelPosition;
}

public void setLabelPosition(String labelPosition) {
this.labelPosition = labelPosition;
}

public void setRequiredPosition(String requiredPosition) {
Expand Down
Expand Up @@ -18,13 +18,12 @@
*/
package org.apache.struts2.views.jsp.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.components.Checkbox;
import org.apache.struts2.components.Component;

import com.opensymphony.xwork2.util.ValueStack;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @see Checkbox
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/struts-default.xml
Expand Up @@ -45,6 +45,7 @@
java.lang.ClassLoader,
java.lang.Shutdown,
java.lang.ProcessBuilder,
java.lang.Thread,
sun.misc.Unsafe,
com.opensymphony.xwork2.ActionContext" />

Expand Down
47 changes: 47 additions & 0 deletions core/src/main/resources/template/archive/xhtml/controlheader.vm
@@ -0,0 +1,47 @@
#*
* $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.
#if( $fieldErrors.get($parameters.name) )
#set ($hasFieldErrors = $fieldErrors.get($parameters.name))
#foreach ($error in $fieldErrors.get($parameters.name))
<tr errorFor="$parameters.id">
#if ($parameters.labelPosition == 'top')<td align="left" valign="top" colspan="2">#else<td align="center" valign="top" colspan="2">#end<span class="errorMessage">$!struts.htmlEncode($error)</span></td>
</tr>
#end
#end
## if the label position is top,
## then give the label it's own row in the table
<tr>
#if ($parameters.labelPosition && $parameters.labelPosition == 'top')<td align="left" valign="top" colspan="2">#else<td align="right" valign="top">#end#if ($parameters.label)<label #if ($parameters.id) for="$!struts.htmlEncode($parameters.id)"#end#if ($hasFieldErrors) class="errorLabel"#else class="label"#end>#if ($parameters.required)<span class="required">*</span>#end$!struts.htmlEncode($parameters.label):</label>#end</td>
## add the extra row
#if ($parameters.labelPosition && $parameters.labelPosition == 'top')
</tr>
<tr>
#end
#if ($parameters.form.validate && $parameters.form.validate == true)
#if ($parameters.onblur)
#set ($parameters.onblur = "validate(this);${parameters.onblur}")
#else
#set ($parameters.onblur = "validate(this)")
#end
#end
<td>
24 changes: 12 additions & 12 deletions core/src/main/resources/template/css_xhtml/checkbox.ftl
Expand Up @@ -23,12 +23,12 @@ NOTE: The 'header' stuff that follows is in this one file for checkbox due to th
that for checkboxes we do not want the label field to show up as checkboxes handle their own
lables
-->
<#assign hasFieldErrors = fieldErrors?? && fieldErrors[parameters.name]??/>
<#assign hasFieldErrors = fieldErrors?? && fieldErrors.get(parameters.name)??/>
<div <#rt/><#if parameters.id??>id="wwgrp_${parameters.id}"<#rt/></#if> class="wwgrp">

<#if hasFieldErrors>
<div <#rt/><#if parameters.id??>id="wwerr_${parameters.id}"<#rt/></#if> class="wwerr">
<#list fieldErrors[parameters.name] as error>
<#list fieldErrors.get(parameters.name) as error>
<div<#rt/>
<#if parameters.id??>
errorFor="${parameters.id}"<#rt/>
Expand All @@ -39,12 +39,12 @@ lables
</#list>
</div><#t/>
</#if>
<#if !parameters.labelposition?? && (parameters.form.labelposition)??>
<#assign labelpos = parameters.form.labelposition/>
<#elseif parameters.labelposition??>
<#assign labelpos = parameters.labelposition/>
<#if !parameters.labelPosition?? && (parameters.form.labelPosition)??>
<#assign labelPos = parameters.form.labelPosition/>
<#elseif parameters.labelPosition??>
<#assign labelPos = parameters.labelPosition/>
</#if>
<#if (labelpos!"") == 'left'>
<#if (labelPos!"") == 'left'>
<span <#rt/>
<#if parameters.id??>id="wwlbl_${parameters.id}"<#rt/></#if> class="wwlbl">
<label<#t/>
Expand All @@ -60,7 +60,7 @@ lables
</span>
</#if>

<#if (labelpos!"top") == 'top'>
<#if (labelPos!"top") == 'top'>
<div <#rt/>
<#else>
<span <#rt/>
Expand All @@ -72,14 +72,14 @@ lables
</#if>

<#include "/${parameters.templateDir}/simple/checkbox.ftl" />
<#if (labelpos!"") != 'left'>
<#if (labelpos!"top") == 'top'>
<#if (labelPos!"") != 'left'>
<#if (labelPos!"top") == 'top'>
</div> <#rt/>
<#else>
</span> <#rt/>
</#if>
<#if parameters.label??>
<#if (labelpos!"top") == 'top'>
<#if (labelPos!"top") == 'top'>
<div <#rt/>
<#else>
<span <#rt/>
Expand All @@ -98,7 +98,7 @@ lables
</#if>
</#if>
<#if parameters.label??>
<#if (labelpos!"top") == 'top'>
<#if (labelPos!"top") == 'top'>
</div> <#rt/>
<#else>
</span> <#rt/>
Expand Down

0 comments on commit 56836c4

Please sign in to comment.