Dear Lucas,

Sorry if i am wrong about that. let me clarify in here.

let say i have pojo :

public class FormColumnKey {
    private Integer formcolumnFormId;

    private String formcolumnName;
//sette-getter
}
in action class, i have list of clolumn:

private List<FormColumn> displayColumnList;


and then, i put all my column from table into the list, next i’ll iterate that 
list in JSP. so this is what i’ve done in JSP:

<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


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.


Regards



> On 20 Feb 2020, at 16.16, Lukasz Lenart <lukaszlen...@apache.org> wrote:
> 
> wt., 18 lut 2020 o 17:04 M Huzaifah <mhuzaifah.i...@gmail.com> napisał(a):
>> Thank you Lucas, my goal is render the struts tag based on list of column
>> name that i've set before. So i have to iterate the list of column using
>> jstl than put the "name" on attribut name in struts tag. From here,  i
>> think i miss understanding about struts tag. I use struts 2.5x that not
>> support for expressions anymore.
> 
> Wait, what? Struts tags do not support expressions? Where did you find
> such information? Did you read that?
> https://struts.apache.org/tag-developers/tag-syntax.html (improved
> version I'm working on right now
> https://struts.staged.apache.org/tag-developers/tag-syntax.html)
> 
> Also Struts tags are using our internal mechanism which prevents
> evaluating malicious expressions, in case of using JSTL you don't have
> such control and as those tags are out of Struts control you can
> mistakenly inject a malicious code
> https://struts.apache.org/security/#internal-security-mechanism
> 
> Also using JSTL and Struts tags in the same JSP is like using Java and
> Kotlin to write the same code. Anyway, Bad Idea.
> 
> 
> Regards
> 
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

Reply via email to