Hi,
I have books.jsp with its ActionForm called BookForm, which links to an Action called BookAction.
I want the BookForm class to have a property called 'books' which returns a Collection of 'Book' objects.
When my books.jsp FIRST loads I want to have an iterator like this:
<table border="1">
<logic:iterate collection="books" >
<member>
<tr>
<td>col one</td>
<td>col two</td>
</tr>
</member>
</logic:iterate>
</table>
I want the Struts engine to automatically get the property 'books' from my BookForm class and carry out the iteration. However, the problem is that the logic:iterate tag expects you to have stored a bean in a scope and wishes to use this. I DO NOT want to store a bean in a scope. What I want is when the page first loads, that Struts should use the <formbean> mapping in struts-config.xml (which i've done ok) and realise that BookForm is the form-bean for Book.jsp. Then I want it to instantiate an instance of BookForm and call getBooks() to get the collection, all automatically. getBooks() will be a static method which will contact a database and create a Collection of Books.
I know struts can do something similar, because my page also has a tag like this:
Title:<html:text property="title" />
and when the page first loads the Struts framework recognizes my BookForm class is connected to books.jsp and calls getTitle() obtaining the title.
I'm hoping i'm missing something here. I will be very dissapointed with struts if it can match properties to bean properties one way but not the other....
thanks in advance,
john
I have books.jsp with its ActionForm called BookForm, which links to an Action called BookAction.
I want the BookForm class to have a property called 'books' which returns a Collection of 'Book' objects.
When my books.jsp FIRST loads I want to have an iterator like this:
<table border="1">
<logic:iterate collection="books" >
<member>
<tr>
<td>col one</td>
<td>col two</td>
</tr>
</member>
</logic:iterate>
</table>
I want the Struts engine to automatically get the property 'books' from my BookForm class and carry out the iteration. However, the problem is that the logic:iterate tag expects you to have stored a bean in a scope and wishes to use this. I DO NOT want to store a bean in a scope. What I want is when the page first loads, that Struts should use the <formbean> mapping in struts-config.xml (which i've done ok) and realise that BookForm is the form-bean for Book.jsp. Then I want it to instantiate an instance of BookForm and call getBooks() to get the collection, all automatically. getBooks() will be a static method which will contact a database and create a Collection of Books.
I know struts can do something similar, because my page also has a tag like this:
Title:<html:text property="title" />
and when the page first loads the Struts framework recognizes my BookForm class is connected to books.jsp and calls getTitle() obtaining the title.
I'm hoping i'm missing something here. I will be very dissapointed with struts if it can match properties to bean properties one way but not the other....
thanks in advance,
john