I understand the don't mix EL and Struts tags - and the use of 'top' in
the valueStack.
I don't understand why the following first two don't provide like
displaying HTML input tags.
Also why doesn't OGNL treat the third as a property of "a" and call the
getter for formcolumnName.
Code
<s:iterator value="displayColumnList" var="a">
<s:textfield name="%{formcolumnName}" />
<s:textfield name="formcolumnName" />
<s:textfield name="%{a.formcolumnName}" />
</s:iterator>
Result
<input type="text" name="John" value="" id="John"/>
<input type="text" name="formcolumnName" value="John" id="formcolumnName"/>
<input type="text" name="" value=""/>
Thanks - John Bush
On 2/23/2020 5:57 AM, Lukasz Lenart wrote:
pt., 21 lut 2020 o 04:05 M Huzaifah <mhuzaifah.i...@gmail.com> napisał(a):
<s:iterator value="displayColumnList" var="a">
<s:textfield name="${a.formcolumnName}" cssClass="form-control form-control-md text-md"
style="simple" placeholder="Value 1" />
</s:iterator>
the jsp has error:
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
/pages/common/genericform/genericMain.jsp (line: 165, column: 24) According to
TLD or attribute directive in tag file, attribute name does not accept any
expressions
File: org/apache/jasper/compiler/DefaultErrorHandler.java
Line number: 41
Yes, this is by design, we didn't want to base on ${} which is out of
Struts control and evaluated by a servlet container (Tag support
layer). That's why we used %{} instead, but ...
cause the error above, then i state attribute name on struts tag does not
accept any expressions. if i test to just print like code bellow thats no
problem:
<s:iterator value="displayColumnList" var="a">
${a.formcolumnName}
</s:iterator>
so, i read your documentation about the expression, then i change my code
bellow:
<s:iterator value="displayColumnList" var="a">
<s:textfield name="%{formcolumnName}" cssClass="form-control form-control-md text-md"
style="simple" placeholder="Value 1" />
</s:iterator>
it works perfectly, thank you Lucas.
... in such a case you don't have to use %{} at all, the "name"
attribute will be evaluated against ValueStack as an expression.
<s:iterator/> tag pushes value into ValueStack (named "a" in your
case, but this is not required if not used), all the object's
properties are available in scope (inside) of the iterator by their
names, so this can be reduced to
<s:iterator value="displayColumnList">
<s:textfield name="formcolumnName" ... />
</s:iterator>
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org