Hi,
I am pretty new to tomcat/struts but nevertheless trying to create a
simple application using the two (; I have troubles getting my design
right, maybe some people on this list could give me some hints, they
would be greatly appreciated.
The idea is that I have a DB backend that stores a bunch of documents
identified by an integer. Now the user can click on a link and view the
document (that's the first step). Now the link looks like this:
<html:link page="/viewDocument.do?documentId=33>view doc with id
33</html:link>
Now, what I want to happen when the user clicks this link is:
Run a controller that checks if the documentId is valid, and if so,
retrieve the document from the DB and store it somewhere in the request
scope, then forward to the actual viewer, otherwise forward to an error
page. The forwards will be done using local forward mappings in the
config file, in order to seperate buisness logic from presentation code.
What I don't understand is: Do I have to create a Form class for this
action? The documentId comes as an Parameter in the request scope and
struts won't fill out the Form anyway (cause there is not form). The
example that came with struts did create a form class in this case,
that's why I am confused. My thinking was that I could just simply add a
custom Document class to the request scope, which the actual viewer
would then read.
Another issue: Can I unify access to Forms fields and Parameters? For my
example it would probably not make a lot of sense, but it would be neat
(from a theoretical POV) if it would not matter if the user just clicked
on a link with parameters or he submitted a form. As long as the both
contain the same fields/parameters, struts could always fill out a Form
class. Or am I missing something?
Regards,
Andreas