• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Coarse grained ActionForm in Struts 1.2

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a struts 1.2 Action Form class, currently with 27 attributes .... mapped to 27 fields in my JSP.
With its getters and setters it is now very big class (1250 LOC) and growing.

So I remodelled my JSP, into logical parts and constructed it using multiple <jsp:include>'s

Also for better reusability and maintenance, I also want to refactor the action form class, into coarser elements, than the current fine structure.

But I see an issue;

In the main JSP, I have a <html:form action="/orderEntry"> element ... mapped to the Action Form and so in the JSP I can easily write

<html:text property="firstName" .../>
<html:text property="lastName" .../>
<html:text property="orderNumber" .../>
<logic:iterate id="oItemID" property="orderItems" .... > etc as those are the attributes of the Form class

If I were to refactor my Action Form, into coarser elements; like

MyActionForm
{
PersonelDetail personelDetail;
OrderDetails orderDetail;
...
}

Accordingly my JSP is now ....

<html:text property="personelDetail.firstName" .../>
<html:text property="personelDetail.lastName" .../>
<html:text property="orderDetail.orderNumber" .../>
<logic:iterate id="oItemID" property="orderDetail.orderItems" .... >

This seems okay for populating the JSP, but when I submit it; will the screen elements be submitted correctly into the finer attributes via the coarser attributes?
Would my Action class be able to access the data on screen; via the coarse attribute?

Does struts 1.2 support this?

~g1
 
Jeevan Sunkersett
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
found the solution.

for the benifit of readers, the above is supported by Struts 1.x

quoting from struts user guide: http://struts.apache.org/1.x/userGuide/building_controller.html


You may also place a bean instance on your form, and use nested property references. For example, you might have a "customer" bean on your ActionForm, and then refer to the property "customer.name" in your presentation page. This would correspond to the methods customer.getName() and customer.setName(String Name) on your customer bean. See the Apache Struts Taglib Developer Guides for more about using the nested syntax.

reply
    Bookmark Topic Watch Topic
  • New Topic