*
The moose likes Struts and the fly likes Properly Using ActionForms for Sets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Properly Using ActionForms for Sets" Watch "Properly Using ActionForms for Sets" New topic
Author

Properly Using ActionForms for Sets

Titus Barik
Greenhorn

Joined: May 15, 2005
Posts: 24
Hi all,

Suppose that Hibernate gives me the following back:

Record
String name
int year

Artist
String Name
int age
Set Records

How do I properly turn these into ActionForms? I assume that I need a:

RecordForm
String name
String year

Artist
String name
String age
Set RecordForms?

If so, how do I use BeanUtils.copyProperties to do this? The Set is the thing that is confusing me.

Thanks.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It looks to me like you have it backwards. If your page is going to show a single artist with multiple records belonging to the artist, you should have ArtistForm, and no need to do anything to Record.
So, in this scenario:

ArtistForm
String name
String age
Set records

In this case, I believe BeanUtils.copyProperties would work just fine, or with only a few properties, copying them indivicually is no big deal.


Merrill
Consultant, Sima Solutions
Titus Barik
Greenhorn

Joined: May 15, 2005
Posts: 24
Originally posted by Merrill Higginson:
It looks to me like you have it backwards. If your page is going to show a single artist with multiple records belonging to the artist, you should have ArtistForm, and no need to do anything to Record.


Hmm, I thought all the records needed to be wrapped into a RecordForm, because we didn't want any models to be returned to the view? Is this incorrect? So it is okay for a Record object to get to the view if it first goes through ArtistForm?
Titus Barik
Greenhorn

Joined: May 15, 2005
Posts: 24
Originally posted by Titus Barik:

Hmm, I thought all the records needed to be wrapped into a RecordForm, because we didn't want any models to be returned to the view? Is this incorrect? So it is okay for a Record object to get to the view if it first goes through ArtistForm?


I realize now that my source of confusion arises because I'm an idiot. An ActionForm should be used when there's a form. Otherwise, it seems perfectly reasonable to send business objects (Artist, Records) to the JSP page, as long as it is done through an Action (controller).

Correct?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Properly Using ActionForms for Sets
 
Similar Threads
Displaying things...need help badly!! Please!
explanation of getter/setter methods -- what's the difference exactly?
Regarding Objects Generated by Objects
using logic:iterate tag to access ActionForm elements
Why is my type unexpected? required variable found value