• 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

Properly Using ActionForms for Sets

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic