struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Chew" <keith.c...@jungledrum.co.nz>
Subject action forms..
Date Sun, 24 Feb 2002 20:33:33 GMT
Hi

I have a template jsp file which on the side bar displays the Latest News.
The latest news is retrieved from the database. I can do a database access
from the JSP or from a custom taglib, but this does not follow the MVC
pattern.

So, what I have done is have a BaseAction class this extends Struts' action
calss. This class performs the datbase access and fills in the data in the
BaseForm class (which extends Struts' ActionForm class).

This all sounds fine, but Struts does not allow me to access the parent
class (BaseForm) from the JSP, if it is not defined for a particular action.
Eg

		<action path="/test" type="TestAction" name="testForm" scope="request"
validate="false" >
			<forward name="success" path="/success.jsp" redirect="false"/>
		</action>

Here, TestForm extends from BaseForm, but in Struts' ActionServlet class, it
only compares the name of the form, so the news jsp cannot see BaseForm,
only TestForm.

One solution is to put the name of the form in the session so that the news
jsp knows which form to get the data from. But this gets too messy.

It would be really nice if I can declare a global form that gets tagged to
all actions. Now, the jsps in the 'side' template jsp can access this global
form, and the jsps in the 'body' templage jsp can access the actual forms.

Any other thoughts on this?

Keith


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message