Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properly Using ActionForms for Sets

 
Titus Barik
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Titus Barik
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic