File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes ActionForm composition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForm composition" Watch "ActionForm composition" New topic

ActionForm composition

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
just wonder if it's to create a form bean with a composition. Assuming I have the following classes:
AccountInformation ( fname, lname...)
CreditCard (number, type...)

I would like to know if it possible to create a form (registration) that is composed of AccountInformation and CreditCard???

I don't want to retype all properties again (doesn't sound right)

my question is this:
1. is it possible to do that?
2. if yes, how would the registration.jsp page will look like?

If it was a regular form, it would have been:

I would like too change the property to somthing like this:
<html:text property="creditCard.ccNumber"> (that of course, doesn't work)

thanks for any advise.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
<html:text property="creditCard.ccNumber"> (that of course, doesn't work)

That does work if you've set up your ActionForm bean properly. Example:

If you code your Actionform like this, the above <html:text> tag will work as long as the CreditCard class has a ccNumber property.
[ October 24, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
cool, I 'forgot' to instantiated it (my intuitive semi worked)
I agree. Here's the link:
subject: ActionForm composition
It's not a secret anymore!