×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

can you have a composition in an ActionForm ?

can you have a composition in an ActionForm ?

can you have a composition in an ActionForm ?

(OP)
Hi there,

I wonder if it's to create a form bean with composition. I mean, assuming I have the following 2 classes:
AccountInformation ( fname, lname...)
CreditCard (number, type...)

I would like to know if I can create a form, registration, that is composed from AccountInformation and CreditCard???

it will look like this:
class Regitration
AccountInfomration accountInfo;
CreditCard creditCard;

So...
1. is it possible to do that?
2. if yes, how would the registration.jsp page will look like?

If it was a regular form, it would have been:

                 <td>
                        <fmt:message key="register.creditcard.number"/>
                </td>
                
                <td>
                        <html:text property="ccNumber"
                                                size="30"
                                                maxlength="30" />
                                                <html:errors property="ccNumber" />
                </td>

what comes in the property (i tought creditCard.number but that doesn't work)

thanks for any advise.

RE: can you have a composition in an ActionForm ?

The "property" attribute in your <html:text... tag will try to map to a getter method within your form called getCcNumber().

The following should get you what you're looking for:

CODE

...
<td>
    <html:text property="ccNumber"
...

in the form class...

public String getCcNumber() {
     return creditCard.number;
}

public void setCcNumber(String ccNumber) {
      this.creditCard.number = ccNumber;
}


As long as your getter and setter methods are named correctly, you should be able to use any type of composite class for your form.

-G

p.s. If getCcNumber() doesn't work, try getccNumber().  There is a definite syntax for getter/setter capitalization.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close