Inconsistency on field value evaluation through field name between
datetimepicker tag and other tags such as select and textfield
----------------------------------------------------------------------------------------------------------------------------------
Key: WW-3004
URL: https://issues.apache.org/struts/browse/WW-3004
Project: Struts 2
Issue Type: Bug
Components: Core Actions
Affects Versions: 2.0.14
Reporter: Qiang Zheng
The way evaluate field value through field name is different between
datetimepicker tag and other tags such as select and textfield.
In UIBean.java,
--------------- it evaluate name first and assign the name value to local
vairable String name defined in evaluateParams()--------------
if (this.name != null) {
name = findString(this.name);
addParameter("name", name);
}
--------------------------Then it will look for value from stack based on that
name variable which was evaluated from this.name---------
-------------------------- So nameValue will hold the field value by evaluate
object path generated above --------------------------
String expr = name;
if (altSyntax()) {
expr = "%{" + expr + "}";
}
addParameter("nameValue", findValue(expr, valueClazz));
--------------------------------------------------------------------------------------------------------------
But in DateTimePicker.java,
------------------ The name assigned to expr is actually proptected property
"name" from UIBean which holds raw string literal of expression ---------------
------------------ In this case, the nameValue doesn't hold value of field but
the value of name expression------------------------------------
if(parameters.containsKey("value")) {
parameters.put("nameValue", format(parameters.get("value")));
} else {
if(name != null) {
String expr = name;
if(altSyntax()) {
expr = "%{" + expr + "}";
}
addParameter("nameValue", format(findValue(expr)));
}
}
-------------------------------------------------------------------------------------------------------
So in our case, when we pass in "%{#attr.name}" to name attribute of
datetimepicker struts tag, the nameValue of that field becomes object path
"aaa.bbb.ccc" which is wrong . But if we pass "%{#attr.name}" to strusts
select tag or textfield tag, the nameValue is the value of "aaa.bbb.ccc" which
is correct.
nameValue will get assigned to value attribute eventually in freemarker script.
Please fix that in DateTimePicker.java and other similar places if any.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.