RuntimeException is thrown
* constructed with a messaged based on the given field and errorMsg parameter.
*
- * @param expr OGNL expression.
- * @param field field name used when throwing RuntimeException.
- * @param errorMsg error message used when throwing RuntimeException.
- * @return the String value found.
+ * @param expr OGNL expression.
+ * @param field field name used when throwing RuntimeException.
+ * @param errorMsg error message used when throwing RuntimeException.
+ * @return the String value found.
* @throws StrutsException is thrown in case of expression is null.
*/
protected String findString(String expr, String field, String errorMsg) {
@@ -245,15 +256,16 @@ public class Component {
* RuntimeException.
- * @param field field name used when throwing RuntimeException.
- * @param errorMsg error message used when throwing RuntimeException.
- * @param e the caused exception, can be null.
- * @return the constructed StrutsException.
+ *
+ * @param field field name used when throwing RuntimeException.
+ * @param errorMsg error message used when throwing RuntimeException.
+ * @param e the caused exception, can be null.
+ * @return the constructed StrutsException.
*/
protected StrutsException fieldError(String field, String errorMsg, Exception e) {
String msg = "tag '" + getComponentName() + "', field '" + field +
- ( parameters != null && parameters.containsKey("name")?"', name '" + parameters.get("name"):"") +
- "': " + errorMsg;
+ (parameters != null && parameters.containsKey("name") ? "', name '" + parameters.get("name") : "") +
+ "': " + errorMsg;
throw new StrutsException(msg, e);
}
@@ -262,7 +274,7 @@ public class Component {
* Will always evaluate expr against stack except when expr
* is null. If altsyntax (%{...}) is applied, simply strip it off.
*
- * @param expr the expression. Returns null if expr is null.
+ * @param expr the expression. Returns null if expr is null.
* @return the value, null if not found.
*/
protected Object findValue(String expr) {
@@ -270,54 +282,39 @@ public class Component {
return null;
}
- expr = stripExpressionIfAltSyntax(expr);
+ expr = stripExpression(expr);
return getStack().findValue(expr, throwExceptionOnELFailure);
}
/**
- * If altsyntax (%{...}) is applied, simply strip the "%{" and "}" off.
+ * If altsyntax (%{...}) is applied, simply strip the "%{" and "}" off.
+ *
* @param expr the expression (must be not null)
* @return the stripped expression if altSyntax is enabled. Otherwise
* the parameter expression is returned as is.
*/
- protected String stripExpressionIfAltSyntax(String expr) {
- return ComponentUtils.stripExpressionIfAltSyntax(stack, expr);
- }
-
- /**
- * See struts.properties where the altSyntax flag is defined.
- * @return if the altSyntax enabled? [TRUE]
- */
- public boolean altSyntax() {
- return ComponentUtils.altSyntax(stack);
+ protected String stripExpression(String expr) {
+ return ComponentUtils.stripExpression(expr);
}
/**
* Adds the surrounding %{ } to the expression for proper processing.
+ *
* @param expr the expression.
- * @return the modified expression if altSyntax is enabled, or the parameter
+ * @return the modified expression if altSyntax is enabled, or the parameter
* expression otherwise.
*/
- protected String completeExpressionIfAltSyntax(String expr) {
- if (altSyntax() && !ComponentUtils.containsExpression(expr)) {
- return "%{" + expr + "}";
- }
- return expr;
- }
-
- /**
- * This check is needed for backwards compatibility with 2.1.x
- * @param expr the expression.
- * @return the found string if altSyntax is enabled. The parameter
- * expression otherwise.
- */
- protected String findStringIfAltSyntax(String expr) {
- if (altSyntax()) {
- return findString(expr);
- }
- return expr;
- }
+ protected String completeExpression(String expr) {
+ if (expr == null) {
+ return null;
+ }
+ if (ComponentUtils.isExpression(expr)) {
+ LOG.warn("Expression {} is already an expression!", expr);
+ return expr;
+ }
+ return "%{" + expr + "}";
+ }
/**
* @@ -331,10 +328,10 @@ public class Component { * messaged based on the given field and errorMsg parameter. *
* - * @param expr OGNL expression. - * @param field field name used when throwingRuntimeException.
- * @param errorMsg error message used when throwing RuntimeException.
- * @return the Object found, is never null.
+ * @param expr OGNL expression.
+ * @param field field name used when throwing RuntimeException.
+ * @param errorMsg error message used when throwing RuntimeException.
+ * @return the Object found, is never null.
* @throws StrutsException is thrown in case of not found in the OGNL stack, or expression is null.
*/
protected Object findValue(String expr, String field, String errorMsg) {
@@ -364,19 +361,20 @@ public class Component {
* is evaluated against the stack.
* * DoubleListUIBean is the standard superclass of all Struts double list handling components. *
- * + ** *
* Note that the doublelistkey and doublelistvalue attribute will default to "key" and "value" * respectively only when the doublelist attribute is evaluated to a Map or its descendant. * Other thing else, will result in doublelistkey and doublelistvalue to be null and not used. *
- * + *
*
- *
*/
public abstract class DoubleListUIBean extends ListUIBean {
@@ -137,21 +136,21 @@ public abstract class DoubleListUIBean extends ListUIBean {
Object tmpDoubleList = findValue(doubleList);
if (doubleListKey != null) {
addParameter("doubleListKey", doubleListKey);
- }else if (tmpDoubleList instanceof Map) {
+ } else if (tmpDoubleList instanceof Map) {
addParameter("doubleListKey", "key");
}
if (doubleListValue != null) {
- doubleListValue = stripExpressionIfAltSyntax(doubleListValue);
+ doubleListValue = stripExpression(doubleListValue);
addParameter("doubleListValue", doubleListValue);
- }else if (tmpDoubleList instanceof Map) {
+ } else if (tmpDoubleList instanceof Map) {
addParameter("doubleListValue", "value");
}
if (doubleListCssClass != null) {
addParameter("doubleListCssClass", findString(doubleListCssClass));
}
- if (doubleListCssStyle!= null) {
+ if (doubleListCssStyle != null) {
addParameter("doubleListCssStyle", findString(doubleListCssStyle));
}
if (doubleListTitle != null) {
@@ -169,7 +168,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
}
}
- Class valueClazz = getValueClassType();
+ Class> valueClazz = getValueClassType();
if (valueClazz != null) {
if (doubleValue != null) {
@@ -187,10 +186,9 @@ public abstract class DoubleListUIBean extends ListUIBean {
Form form = (Form) findAncestor(Form.class);
if (doubleId != null) {
- // this check is needed for backwards compatibility with 2.1.x
- addParameter("doubleId", findStringIfAltSyntax(doubleId));
+ addParameter("doubleId", findString(doubleId));
} else if (form != null) {
- addParameter("doubleId", form.getParameters().get("id") + "_" +escape(doubleName !=null ? findString(doubleName) : null));
+ addParameter("doubleId", form.getParameters().get("id") + "_" + escape(doubleName != null ? findString(doubleName) : null));
} else {
addParameter("doubleId", escape(doubleName != null ? findString(doubleName) : null));
}
@@ -269,23 +267,23 @@ public abstract class DoubleListUIBean extends ListUIBean {
}
}
- @StrutsTagAttribute(description="The second iterable source to populate from.", required=true)
+ @StrutsTagAttribute(description = "The second iterable source to populate from.", required = true)
public void setDoubleList(String doubleList) {
this.doubleList = doubleList;
}
- @StrutsTagAttribute(description="The key expression to use for second list")
+ @StrutsTagAttribute(description = "The key expression to use for second list")
public void setDoubleListKey(String doubleListKey) {
this.doubleListKey = doubleListKey;
}
- @StrutsTagAttribute(description="The value expression to use for second list")
+ @StrutsTagAttribute(description = "The value expression to use for second list")
public void setDoubleListValue(String doubleListValue) {
this.doubleListValue = doubleListValue;
}
@StrutsTagAttribute(description = "Property of second list objects to get css class from")
- public void setDoubleListCssClass(String doubleListCssClass) {
+ public void setDoubleListCssClass(String doubleListCssClass) {
this.doubleListCssClass = doubleListCssClass;
}
@@ -299,17 +297,17 @@ public abstract class DoubleListUIBean extends ListUIBean {
this.doubleListTitle = doubleListTitle;
}
- @StrutsTagAttribute(description="The name for complete component", required=true)
+ @StrutsTagAttribute(description = "The name for complete component", required = true)
public void setDoubleName(String doubleName) {
this.doubleName = doubleName;
}
- @StrutsTagAttribute(description="The value expression for complete component")
+ @StrutsTagAttribute(description = "The value expression for complete component")
public void setDoubleValue(String doubleValue) {
this.doubleValue = doubleValue;
}
- @StrutsTagAttribute(description="The form name this component resides in and populates to")
+ @StrutsTagAttribute(description = "The form name this component resides in and populates to")
public void setFormName(String formName) {
this.formName = formName;
}
@@ -318,7 +316,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return formName;
}
- @StrutsTagAttribute(description="The css class for the second list")
+ @StrutsTagAttribute(description = "The css class for the second list")
public void setDoubleCssClass(String doubleCssClass) {
this.doubleCssClass = doubleCssClass;
}
@@ -327,7 +325,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleCssClass;
}
- @StrutsTagAttribute(description="The css style for the second list")
+ @StrutsTagAttribute(description = "The css style for the second list")
public void setDoubleCssStyle(String doubleCssStyle) {
this.doubleCssStyle = doubleCssStyle;
}
@@ -336,7 +334,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleCssStyle;
}
- @StrutsTagAttribute(description="The header key for the second list")
+ @StrutsTagAttribute(description = "The header key for the second list")
public void setDoubleHeaderKey(String doubleHeaderKey) {
this.doubleHeaderKey = doubleHeaderKey;
}
@@ -345,7 +343,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleHeaderKey;
}
- @StrutsTagAttribute(description="The header value for the second list")
+ @StrutsTagAttribute(description = "The header value for the second list")
public void setDoubleHeaderValue(String doubleHeaderValue) {
this.doubleHeaderValue = doubleHeaderValue;
}
@@ -354,7 +352,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleHeaderValue;
}
- @StrutsTagAttribute(description="Decides if the second list will add an empty option")
+ @StrutsTagAttribute(description = "Decides if the second list will add an empty option")
public void setDoubleEmptyOption(String doubleEmptyOption) {
this.doubleEmptyOption = doubleEmptyOption;
}
@@ -368,7 +366,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleDisabled;
}
- @StrutsTagAttribute(description="Decides if a disable attribute should be added to the second list")
+ @StrutsTagAttribute(description = "Decides if a disable attribute should be added to the second list")
public void setDoubleDisabled(String doubleDisabled) {
this.doubleDisabled = doubleDisabled;
}
@@ -377,7 +375,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleId;
}
- @StrutsTagAttribute(description="The id of the second list")
+ @StrutsTagAttribute(description = "The id of the second list")
public void setDoubleId(String doubleId) {
this.doubleId = doubleId;
}
@@ -386,7 +384,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleMultiple;
}
- @StrutsTagAttribute(description=" Decides if multiple attribute should be set on the second list")
+ @StrutsTagAttribute(description = " Decides if multiple attribute should be set on the second list")
public void setDoubleMultiple(String doubleMultiple) {
this.doubleMultiple = doubleMultiple;
}
@@ -395,7 +393,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnblur;
}
- @StrutsTagAttribute(description="Set the onblur attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onblur attribute of the second list")
public void setDoubleOnblur(String doubleOnblur) {
this.doubleOnblur = doubleOnblur;
}
@@ -404,7 +402,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnchange;
}
- @StrutsTagAttribute(description="Set the onchange attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onchange attribute of the second list")
public void setDoubleOnchange(String doubleOnchange) {
this.doubleOnchange = doubleOnchange;
}
@@ -413,7 +411,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnclick;
}
- @StrutsTagAttribute(description="Set the onclick attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onclick attribute of the second list")
public void setDoubleOnclick(String doubleOnclick) {
this.doubleOnclick = doubleOnclick;
}
@@ -422,7 +420,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOndblclick;
}
- @StrutsTagAttribute(description="Set the ondbclick attribute of the second list")
+ @StrutsTagAttribute(description = "Set the ondbclick attribute of the second list")
public void setDoubleOndblclick(String doubleOndblclick) {
this.doubleOndblclick = doubleOndblclick;
}
@@ -431,7 +429,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnfocus;
}
- @StrutsTagAttribute(description="Set the onfocus attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onfocus attribute of the second list")
public void setDoubleOnfocus(String doubleOnfocus) {
this.doubleOnfocus = doubleOnfocus;
}
@@ -440,7 +438,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnkeydown;
}
- @StrutsTagAttribute(description="Set the onkeydown attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onkeydown attribute of the second list")
public void setDoubleOnkeydown(String doubleOnkeydown) {
this.doubleOnkeydown = doubleOnkeydown;
}
@@ -449,7 +447,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnkeypress;
}
- @StrutsTagAttribute(description="Set the onkeypress attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onkeypress attribute of the second list")
public void setDoubleOnkeypress(String doubleOnkeypress) {
this.doubleOnkeypress = doubleOnkeypress;
}
@@ -458,7 +456,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnkeyup;
}
- @StrutsTagAttribute(description="Set the onkeyup attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onkeyup attribute of the second list")
public void setDoubleOnkeyup(String doubleOnkeyup) {
this.doubleOnkeyup = doubleOnkeyup;
}
@@ -467,7 +465,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnmousedown;
}
- @StrutsTagAttribute(description="Set the onmousedown attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onmousedown attribute of the second list")
public void setDoubleOnmousedown(String doubleOnmousedown) {
this.doubleOnmousedown = doubleOnmousedown;
}
@@ -476,7 +474,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnmousemove;
}
- @StrutsTagAttribute(description="Set the onmousemove attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onmousemove attribute of the second list")
public void setDoubleOnmousemove(String doubleOnmousemove) {
this.doubleOnmousemove = doubleOnmousemove;
}
@@ -485,7 +483,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnmouseout;
}
- @StrutsTagAttribute(description="Set the onmouseout attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onmouseout attribute of the second list")
public void setDoubleOnmouseout(String doubleOnmouseout) {
this.doubleOnmouseout = doubleOnmouseout;
}
@@ -494,7 +492,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnmouseover;
}
- @StrutsTagAttribute(description="Set the onmouseover attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onmouseover attribute of the second list")
public void setDoubleOnmouseover(String doubleOnmouseover) {
this.doubleOnmouseover = doubleOnmouseover;
}
@@ -503,7 +501,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnmouseup;
}
- @StrutsTagAttribute(description="Set the onmouseup attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onmouseup attribute of the second list")
public void setDoubleOnmouseup(String doubleOnmouseup) {
this.doubleOnmouseup = doubleOnmouseup;
}
@@ -512,7 +510,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleOnselect;
}
- @StrutsTagAttribute(description="Set the onselect attribute of the second list")
+ @StrutsTagAttribute(description = "Set the onselect attribute of the second list")
public void setDoubleOnselect(String doubleOnselect) {
this.doubleOnselect = doubleOnselect;
}
@@ -521,7 +519,7 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleSize;
}
- @StrutsTagAttribute(description="Set the size attribute of the second list")
+ @StrutsTagAttribute(description = "Set the size attribute of the second list")
public void setDoubleSize(String doubleSize) {
this.doubleSize = doubleSize;
}
@@ -546,36 +544,36 @@ public abstract class DoubleListUIBean extends ListUIBean {
return doubleValue;
}
- @StrutsTagAttribute(description="Decides of an empty option is to be inserted in the second list", type="Boolean", defaultValue="false")
+ @StrutsTagAttribute(description = "Decides of an empty option is to be inserted in the second list", type = "Boolean", defaultValue = "false")
public void setEmptyOption(String emptyOption) {
this.emptyOption = emptyOption;
}
- @StrutsTagAttribute(description="Set the header key of the second list. Must not be empty! " +
- "'-1' and '' is correct, '' is bad.")
+ @StrutsTagAttribute(description = "Set the header key of the second list. Must not be empty! " +
+ "'-1' and '' is correct, '' is bad.")
public void setHeaderKey(String headerKey) {
this.headerKey = headerKey;
}
- @StrutsTagAttribute(description=" Set the header value of the second list")
+ @StrutsTagAttribute(description = " Set the header value of the second list")
public void setHeaderValue(String headerValue) {
this.headerValue = headerValue;
}
- @StrutsTagAttribute(description="Creates a multiple select. " +
- "The tag will pre-select multiple values if the values are passed as an Array " +
- "(of appropriate types) via the value attribute.")
+ @StrutsTagAttribute(description = "Creates a multiple select. " +
+ "The tag will pre-select multiple values if the values are passed as an Array " +
+ "(of appropriate types) via the value attribute.")
public void setMultiple(String multiple) {
// TODO: Passing a Collection may work too?
this.multiple = multiple;
}
- @StrutsTagAttribute(description="Size of the element box (# of elements to show)", type="Integer")
+ @StrutsTagAttribute(description = "Size of the element box (# of elements to show)", type = "Integer")
public void setSize(String size) {
this.size = size;
}
- @StrutsTagAttribute(description="Set the html accesskey attribute.")
+ @StrutsTagAttribute(description = "Set the html accesskey attribute.")
public void setDoubleAccesskey(String doubleAccesskey) {
this.doubleAccesskey = doubleAccesskey;
}
diff --git a/core/src/main/java/org/apache/struts2/components/FormButton.java b/core/src/main/java/org/apache/struts2/components/FormButton.java
index 7dcc7ae68..5cf88bc42 100644
--- a/core/src/main/java/org/apache/struts2/components/FormButton.java
+++ b/core/src/main/java/org/apache/struts2/components/FormButton.java
@@ -18,24 +18,23 @@
*/
package org.apache.struts2.components;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.views.annotations.StrutsTagAttribute;
+import com.opensymphony.xwork2.inject.Inject;
+import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.views.annotations.StrutsTagAttribute;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* FormButton.
*/
public abstract class FormButton extends ClosingUIBean {
- static final String BUTTONTYPE_INPUT = "input";
- static final String BUTTONTYPE_BUTTON = "button";
- static final String BUTTONTYPE_IMAGE = "image";
+ private static final String BUTTON_TYPE_INPUT = "input";
+ private static final String BUTTON_TYPE_BUTTON = "button";
+ private static final String BUTTON_TYPE_IMAGE = "image";
protected String action;
protected String method;
@@ -49,9 +48,8 @@ public abstract class FormButton extends ClosingUIBean {
public void evaluateExtraParams() {
super.evaluateExtraParams();
- String submitType = BUTTONTYPE_INPUT;
- if (type != null && (BUTTONTYPE_BUTTON.equalsIgnoreCase(type) || (supportsImageType() && BUTTONTYPE_IMAGE.equalsIgnoreCase(type))))
- {
+ String submitType = BUTTON_TYPE_INPUT;
+ if (type != null && (BUTTON_TYPE_BUTTON.equalsIgnoreCase(type) || (supportsImageType() && BUTTON_TYPE_IMAGE.equalsIgnoreCase(type)))) {
submitType = type;
}
@@ -59,7 +57,7 @@ public abstract class FormButton extends ClosingUIBean {
addParameter("type", submitType);
- if (!BUTTONTYPE_INPUT.equals(submitType) && (label == null)) {
+ if (!BUTTON_TYPE_INPUT.equals(submitType) && (label == null)) {
addParameter("label", getParameters().get("nameValue"));
}
@@ -101,15 +99,14 @@ public abstract class FormButton extends ClosingUIBean {
String _tmp_id = "";
if (id != null) {
// this check is needed for backwards compatibility with 2.1.x
- _tmp_id = findStringIfAltSyntax(id);
- }
- else {
+ _tmp_id = findString(id);
+ } else {
if (form != null && form.getParameters().get("id") != null) {
_tmp_id = _tmp_id + form.getParameters().get("id").toString() + "_";
}
if (name != null) {
_tmp_id = _tmp_id + escape(name);
- } else if (action != null || method != null){
+ } else if (action != null || method != null) {
if (action != null) {
_tmp_id = _tmp_id + escape(action);
}
@@ -139,19 +136,19 @@ public abstract class FormButton extends ClosingUIBean {
this.actionMapper = mapper;
}
- @StrutsTagAttribute(description="Set action attribute.")
+ @StrutsTagAttribute(description = "Set action attribute.")
public void setAction(String action) {
this.action = action;
}
- @StrutsTagAttribute(description="Set method attribute.")
+ @StrutsTagAttribute(description = "Set method attribute.")
public void setMethod(String method) {
this.method = method;
}
- @StrutsTagAttribute(description="The type of submit to use. Valid values are input, " +
- "button and image.", defaultValue="input")
+ @StrutsTagAttribute(description = "The type of submit to use. Valid values are input, " +
+ "button and image.", defaultValue = "input")
public void setType(String type) {
this.type = type;
}
diff --git a/core/src/main/java/org/apache/struts2/components/Label.java b/core/src/main/java/org/apache/struts2/components/Label.java
index f81d36a77..c09b88c80 100644
--- a/core/src/main/java/org/apache/struts2/components/Label.java
+++ b/core/src/main/java/org/apache/struts2/components/Label.java
@@ -88,7 +88,7 @@ public class Label extends UIBean {
addParameter("nameValue", providedLabel);
}
} else if (name != null) {
- String expr = completeExpressionIfAltSyntax(name);
+ String expr = completeExpression(name);
addParameter("nameValue", findString(expr));
}
}
diff --git a/core/src/main/java/org/apache/struts2/components/ListUIBean.java b/core/src/main/java/org/apache/struts2/components/ListUIBean.java
index ed5094198..14cf74ace 100644
--- a/core/src/main/java/org/apache/struts2/components/ListUIBean.java
+++ b/core/src/main/java/org/apache/struts2/components/ListUIBean.java
@@ -104,7 +104,7 @@ public abstract class ListUIBean extends UIBean {
}
if (listKey != null) {
- listKey = stripExpressionIfAltSyntax(listKey);
+ listKey = stripExpression(listKey);
addParameter("listKey", listKey);
} else if (value instanceof Map) {
addParameter("listKey", "key");
@@ -113,12 +113,12 @@ public abstract class ListUIBean extends UIBean {
}
if (listValueKey != null) {
- listValueKey = stripExpressionIfAltSyntax(listValueKey);
+ listValueKey = stripExpression(listValueKey);
addParameter("listValueKey", listValueKey);
}
if (listValue != null) {
- listValue = stripExpressionIfAltSyntax(listValue);
+ listValue = stripExpression(listValue);
addParameter("listValue", listValue);
} else if (value instanceof Map) {
addParameter("listValue", "value");
@@ -127,7 +127,7 @@ public abstract class ListUIBean extends UIBean {
}
if (listLabelKey != null) {
- listLabelKey = stripExpressionIfAltSyntax(listLabelKey);
+ listLabelKey = stripExpression(listLabelKey);
addParameter("listLabelKey", listLabelKey);
}
diff --git a/core/src/main/java/org/apache/struts2/components/Property.java b/core/src/main/java/org/apache/struts2/components/Property.java
index 4be202551..29aebe9fd 100644
--- a/core/src/main/java/org/apache/struts2/components/Property.java
+++ b/core/src/main/java/org/apache/struts2/components/Property.java
@@ -140,7 +140,7 @@ public class Property extends Component {
value = "top";
}
else {
- value = stripExpressionIfAltSyntax(value);
+ value = stripExpression(value);
}
// exception: don't call findString(), since we don't want the
diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java
index 8c29beb4b..68fff203a 100644
--- a/core/src/main/java/org/apache/struts2/components/UIBean.java
+++ b/core/src/main/java/org/apache/struts2/components/UIBean.java
@@ -788,13 +788,13 @@ public abstract class UIBean extends Component {
parameters.put("nameValue", parameters.get("value"));
} else {
if (evaluateNameValue()) {
- final Class valueClazz = getValueClassType();
+ final Class> valueClazz = getValueClassType();
if (valueClazz != null) {
if (value != null) {
addParameter("nameValue", findValue(value, valueClazz));
} else if (name != null) {
- String expr = completeExpressionIfAltSyntax(name);
+ String expr = completeExpression(name);
if (recursion(name)) {
addParameter("nameValue", expr);
} else {
@@ -834,19 +834,18 @@ public abstract class UIBean extends Component {
if (tooltip != null) {
addParameter("tooltip", findString(tooltip));
- Map tooltipConfigMap = getTooltipConfig(this);
+ Mapstruts.properties where the altSyntax flag is defined.
- */
- public static boolean altSyntax(ValueStack stack) {
- return ContextUtil.isUseAltSyntax(stack.getContext());
- }
-
/**
* Check if object is expression base on altSyntax
*
diff --git a/core/src/main/java/org/apache/struts2/views/jsp/StrutsBodyTagSupport.java b/core/src/main/java/org/apache/struts2/views/jsp/StrutsBodyTagSupport.java
index 01921aab0..2a89b0e11 100644
--- a/core/src/main/java/org/apache/struts2/views/jsp/StrutsBodyTagSupport.java
+++ b/core/src/main/java/org/apache/struts2/views/jsp/StrutsBodyTagSupport.java
@@ -18,19 +18,16 @@
*/
package org.apache.struts2.views.jsp;
-import java.io.PrintWriter;
-
-import javax.servlet.jsp.tagext.BodyTagSupport;
-
+import com.opensymphony.xwork2.util.TextParseUtil;
+import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.util.ComponentUtils;
import org.apache.struts2.util.FastByteArrayOutputStream;
-import com.opensymphony.xwork2.util.TextParseUtil;
-import com.opensymphony.xwork2.util.ValueStack;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.PrintWriter;
/**
* Contains common functonalities for Struts JSP Tags.
- *
*/
public class StrutsBodyTagSupport extends BodyTagSupport {
@@ -45,25 +42,23 @@ public class StrutsBodyTagSupport extends BodyTagSupport {
}
protected Object findValue(String expr) {
- expr = ComponentUtils.stripExpressionIfAltSyntax(getStack(), expr);
+ expr = ComponentUtils.stripExpression(expr);
return getStack().findValue(expr);
}
- protected Object findValue(String expr, Class toType) {
- if (ComponentUtils.altSyntax(getStack()) && toType == String.class) {
- return TextParseUtil.translateVariables('%', expr, getStack());
- //return translateVariables(expr, getStack());
+ protected Object findValue(String expr, Class> toType) {
+ if (toType == String.class) {
+ return TextParseUtil.translateVariables('%', expr, getStack());
} else {
- expr = ComponentUtils.stripExpressionIfAltSyntax(getStack(), expr);
-
+ expr = ComponentUtils.stripExpression(expr);
return getStack().findValue(expr, toType);
}
}
protected String toString(Throwable t) {
try (FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
- PrintWriter wrt = new PrintWriter(bout)) {
+ PrintWriter wrt = new PrintWriter(bout)) {
t.printStackTrace(wrt);
return bout.toString();
diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
index 7cc1aab24..f021845d5 100644
--- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
+++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
@@ -60,25 +60,6 @@ public class ContextUtil {
return map;
}
- /**
- * Return true if either Configuration's altSyntax is on or the stack context's useAltSyntax is on
- *
- * @param context stack's context
- * @return boolean
- */
- public static boolean isUseAltSyntax(Map