You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Harish Panwar <ha...@gmail.com> on 2014/09/02 09:41:27 UTC
Mapped Properties in Struts 2
Hi All,
We are migrating our website from Struts 1 to Struts 2. Everything is
working fine except the mapped properties.
Lets say we have text-field in our jsp:
<s:textfield name="arp(0)" />
Getter-Setter for this field were like this in struts1:
public String getArp(String key) {
int index=Integer.parseInt(key);
return prlist[index].arp;}public void setArp(String key, Object value) {
System.out.println("set ARP: index:"+index+", value"+value);
int index=Integer.parseInt(key);
prlist[index].arp=value.toString();}
But now this is not working in struts2. On form submit method setArp() is
not executing.
For detailed description, please go to:
http://stackoverflow.com/questions/25599741/not-able-to-set-mapped-properties-in-struts2
If you want to see what are mapped properties:
http://struts.apache.org/release/1.2.x/faqs/indexedprops.html#mappedprops
I am stuck at this point. I tried to google it but could not get any
satisfactory answer. People are suggesting to use <s:textfield
name="prist[0].arp" /> , but because of dependent code and other reasons I
can not use it.
My question is whether Struts 2 supports Mapped properties or not. If yes,
then how can I use it.
Thanks,
Harish Panwar
Re: Mapped Properties in Struts 2
Posted by Lukasz Lenart <lu...@apache.org>.
2014-09-02 9:41 GMT+02:00 Harish Panwar <ha...@gmail.com>:
> Hi All,
>
> We are migrating our website from Struts 1 to Struts 2. Everything is
> working fine except the mapped properties.
>
> Lets say we have text-field in our jsp:
>
> <s:textfield name="arp(0)" />
>
> Getter-Setter for this field were like this in struts1:
>
> public String getArp(String key) {
> int index=Integer.parseInt(key);
> return prlist[index].arp;}public void setArp(String key, Object value) {
> System.out.println("set ARP: index:"+index+", value"+value);
> int index=Integer.parseInt(key);
> prlist[index].arp=value.toString();}
>
> But now this is not working in struts2. On form submit method setArp() is
> not executing.
>
> For detailed description, please go to:
> http://stackoverflow.com/questions/25599741/not-able-to-set-mapped-properties-in-struts2
>
> If you want to see what are mapped properties:
> http://struts.apache.org/release/1.2.x/faqs/indexedprops.html#mappedprops
>
> I am stuck at this point. I tried to google it but could not get any
> satisfactory answer. People are suggesting to use <s:textfield
> name="prist[0].arp" /> , but because of dependent code and other reasons I
> can not use it.
>
>
> My question is whether Struts 2 supports Mapped properties or not. If yes,
> then how can I use it.
You can use OGNL expression like this
<s:textfield name="%{getArp(0)}" />
but this is bad, very bad... design
Regards
--
Ćukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org