struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Mapped Properties in Struts 2
Date Tue, 02 Sep 2014 10:39:40 GMT
2014-09-02 9:41 GMT+02:00 Harish Panwar <harry.iitr@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


Mime
View raw message