• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

forms and input

Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm returning an com.test.Account object from a database and need to display it on the page. I've set up a dynaForm and given it 1 property -account - with a type of com.test.Account. The user can then edit the data and submit the form. My question is follows: Is it better to create forms to match your object(have getter and setters for each field) or can you do it like I did above and reference the field in the JSP page like - account.accountnumber??
The issue I see with doing it the second way is when the user resubmits the form, how does Struts automatically populate the form if you don't have each field listed in the form?
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a bean in a form, struts will match request names like account.accountnumber with the setAccountnumber() setter method on the 'account' bean that it gets from the formbean's getAccount() getter.
I actually did a whole project like this. Most of my formbeans contained 2 or 3 properties only, one of which was another bean, a value bean, containing the data that the user would see.
Seemed more logical and fitted the MVC design pattern better, I thought, although I never asked the big boys on the struts-user list what they thought.
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic