wood burning stoves 2.0*
The moose likes Struts and the fly likes Question regarding one-to-one mapping 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 "Question regarding one-to-one mapping" Watch "Question regarding one-to-one mapping" New topic
Author

Question regarding one-to-one mapping

Meg Jolie
Greenhorn

Joined: Jul 03, 2009
Posts: 20
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!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 03, 2009
Posts: 20
Thanks.. I will try it then.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Question regarding one-to-one mapping
 
Similar Threads
JSF: calling a page without calling a page
org.apache.jasper.JasperException: java.lang.NullPointerException: Module 'null' not found.
Passing parmameter from jsp to action page
Struts and JSP problem :(
Error: DispatchMapping[/login] does not define a handler property