Hi, Stephen:

No, you do not need to write more than one getter/setter. Using your
example, the only getter/setter you would write is to access the book. Using
the dot-delimted notation in your JSP, you can access the Book and use its
getters/setters to access properties. For example:

  public class BookForm extends ActionForm
  {
     private Book book;

     public Book getBook() {...}
     public void setBook(Book book) {...}
  }

Now, in your JSP, you make calls to the Book properties via the getBook()
method. Again, using your example, if you wanted to have an input field for
the Book title, it would look like the following:

  <html:text name="BookForm" property="book.title" size="20" />

This tag directs Struts to call getBook().getTitle() to populate the page
when the JSP is being prepared for the browser, and Struts uses
getBook().setTitle() to populate your bean with values written to the input
field when the user submits the form.

BTW, you might want to post these type of questions to the
[EMAIL PROTECTED] lists instead of the dev list. 

Chris


-----Original Message-----
From: Stephan Wiesner [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 1:41 AM
To: [EMAIL PROTECTED]
Subject: Betreff: RE: Use of ActionForm:


Hmh, I just tried that out.
I have a Book.java Bean with title, author, etc.
Than I have a BookForm.java ActionForm that has a Book. 
Now to use a form to set the title of the book my BookForm still needs to
have a setTitle() method. So, I still end writing (and maintaining) all
those getters and setters twice?

Stephan


-------Original-Nachricht-------

Von: Struts Developers List
Datum: Mittwoch, 3. April 2002 14:54:41
An: 'Struts Developers List'
Betreff: RE: Use of ActionForm:

Hi, Stephan:

We typically keep an instance of our bean in the ActionForm and provide an
accessor method for the bean. In our JSPs, we simply reference the bean
properties via the accessor method:

fooBean.date
fooBean.name




Chris

-----Original Message-----
From: Stephan Wiesner [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 03, 2002 6:12 AM
To: [EMAIL PROTECTED]
Subject: Use of ActionForm:


If I got it right I normally define an ActionFormBean for every Bean of mine
But it is basically just the same, just without logic. I don't want my
Model Beans to extend a Strut class, though. So I end coding the same getter
and setter methods in two classes.
If ActionForm were an Interface I could define a class extending my normal
Bean and implementing it.

I suppose I don't see something here, so can anybody enlighten me?

Stephan

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to