• 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

Question regarding one-to-one mapping

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you need to have one-to-one mapping between fields on the jsp page which contains the form, and the fields in the ActionForm subclass ? Or is it just one-to-one mapping between the fields on the jsp page and the getter and setter methods in the ActionForm subclass?

Example : Can I do this?

public class AddPayeeForm extends ActionForm
{
private Payee p;

public void setName (String name)
{
p.setName (name);
}

String getName ()
{
return p.getName ();
}


public void setAddressLine1 (String addressLine1)
{
p.setAddressLine1 (addressLine1);
}

public String getAddressLine1 ()
{
return p.getAddressLine1 ();
}

and so on ..


I have to create a Payee object since I have to show all the payees in ShowPayees.jsp and I will be repeating the same methods in my Payee class and AddPayeeForm class (ActionForm subclass) , so this will avoid duplication of code to a certain extent.

Or is there any other better way to do this?

Any help will be greatly appreciated!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happened when you tried it?

As far as I know there's no reason you can't do this, although you could also just change the form to use the payee object.
 
Meg Jolie
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.. I will try it then.
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic