Title: RE: Putting it all together, help???

Mike Thompson wrote:

> Ok, I'm new to this web based app thing, so any help is greatly
> appreciated.  There are a couple of things that confuse me about Struts.

> 1)  Say I've got a main page with a few links on it.  No forms
> plain vanilla.  Is it a good struts practice to create an Action
> for this page?

Yes. It would be good for the links from this page to refer to one or
more actions. These actions can perfrom the necessary calls to model-level
classes and return the data to a jsp, route errors to error pages, route
expired sessions to log-on pages, and so forth.

> 2)  Struts seems very form-centric.  What if I want a page that
> just instantiates a session ejb, pulls a list from a db, and displays
> that in an html table.  Can struts help me here?

Yes. One of the great benefits of struts is its workflow model. Of
course it wouldn't do for one of these highly-configurable state-machine
type workflows that seem to be a product of business process re-engineering,
but it is quite good for most web apps. By using the struts mechanisms you
gain the ability to encapsulate your redirection points in one configuration
file, rather than having them hardcoded all over the app.

Another point about your example above is that you are essentially going
to need some kind of object to hold your result data. Either you have all
fixed fields or some variable ones. So this is all a form requires you
to have. The struts taglibs make accessing this data in a relatively
uncluttered way very easy. They also obviate the need for you to write
your own taglib to encapsulate all the necessary java, or to have
unmaintainable scriptlets all over your jsps.

Finally, consider maintainability. Today you want an app that can display
some data. Tomorrow you want an administrative app that can also modify the
data, and having built things in a reusable way will assist you greatly.

> I've read the docs, and I can see some of the peices, I think I'm
> having a hard time putting it together as a whole.

See the discussion "A More Modular Design Using Action Objects" in Hans Bergsten's _Java Server Pages, O'Reilly, pp 295-297. This is part of his general discussion of combining servlets and jsps.

S-

Reply via email to