I have an iterator which requires to use mapped properties or indexed properties but my getter-setter are not getting those values.
For Ex: (This is just an example. Ultimately the idea is whether I can use mapped property in struts 2 or not. If yes, then how.)
index.jsp:
<s:form action="hello" namespace="foo">
<s:textfield name="arp(0)" /> <br/>
<s:textfield name="prp(0)" /> <br/>
<s:textfield name="arp(1)" /> <br/>
<s:textfield name="prp(1)" /> <br/>
<s:submit value="Say Hello" />
</s:form>
helloWorld.action:
class PRLists {
String arp;
String prp;
public String getArp() {
return Arp;
}
public void setArp(String aRP) {
arp = aRP;
}
public String getPrp() {
return prp;
}
public void setPrp(String pRP) {
prp = pRP;
}
}
public class HelloWorldAction {
ArrayList<PRLists> prlist = new ArrayList<PRLists>();
public String execute() throws Exception {
System.out.println("ruuning execute");
return "success";
}
public ArrayList<PRLists> getPrlist() {
return prlist;
}
public void setPrlist(ArrayList<PRLists> prlist) {
this.prlist = prlist;
}
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();
}
public String getPrp(String key) {
int index = Integer.parseInt(key);
return prlist[index].prp;
}
public void setPrp(String key, Object value) {
System.out.println("set PRP, Key:" + key + ", value:" + value);
int index = Integer.parseInt(key);
prlist[index].prp = value.toString();
}
}
Earlier I was having this kind of working functions in struts 1 but now I am trying to move it to struts 2. Now my setter functions in HelloWorldAction.java for arp and prp are not getting called upon form submit.
public void setArp(String key, Object value);
public void setPrp(String key, Object value);
<s:textfield name="prlist[0].arp" />
can work but we have some dependent code which requires to use fields with name such as <s:textfield name="arp(0)" />
.
I do not know whether struts 2 supports mapped properties or not. If it supports, then how can I use it.
I also found a related issue: https://issues.liferay.com/browse/LPS-14128
Note: I have made some modifications in question description
Thanks in advance.