-1

While migrating from Struts1 to Struts2, I have encountered DynaActionForm. Please provide code snippet as example which will help convert to Struts2. Tried lot of google search but no luck!

Roman C
  • 49,761
  • 33
  • 66
  • 176
Test
  • 91
  • 11

1 Answers1

0

There's no such DynaActionForm in Struts2. If you want to set properties dynamically then use a Map.

Map<String, Object> dynaActionForm;
//getter and setter here

...

dynaActionForm.put("property1", object1.getProperty1());
dynaActionForm.put("property2", object2.getProperty1());

In the JSP you can access this properies

<s:property value="dynaActionForm.property1"/>
<s:property value="dynaActionForm.property2"/>
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Appreciate your prompt reply. I am new to struts. In my case, DynaAction form is in Filter. Then, Please let me know 1> If the entries in the struts_config.xml needs to be removed. 2> how to replace the code String password = (String)form.get("password"); in the filter. – Test Sep 01 '15 at 15:20
  • Can you help me with the answer to the above question. – Test Sep 08 '15 at 17:51
  • Before you `get` you should `put` properties to the form, whatever form definition you use you can always have variable number of properties. Make sure you bind them on the page. – Roman C Sep 09 '15 at 13:54