RE: Putting it all together, help???
Hi Mike, I hope the following isn't too basic for you! With the Struts implementation of the MVC pattern (really Model-2) the View (JSP) gets access to all the data it needs by accessing objects stored in the session context. So, if the Action class wants to make data available to the JSP, it needs to first store that data in the session context. Now, for the JSP to access it (or a custom tag) all you need to know is the key under which the data was stored. It is possible to store EJB references directly in the session context however this would mean that the JSP/Tag would be using remote calls to get the data. This is not really the best use of network resources so it is better for the Action class to put simple JavaBean value classes into the session context. This might mean some amount of copying data, but that should be minimal. If you follow this approach it might be best if the SessionBean that the Action is using (you're not talking to EntityBeans directly are you?) only return simple JavaBeans (as opposed to EJB's) to represent the data. Make sense? --Steve -Original Message- From: Mike Thompson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 12, 2001 1:20 PM To: [EMAIL PROTECTED] Subject: Re: Putting it all together, help??? / 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. // Yes, I've already got a fairly extensive EJB backend, my only question was that I won't be populating a form and since Struts is not a servlet engine, how does the HTML get generated for my example. In my actions perform method, I query some session EJBs for some data and would like to display it in a table. Supposing I can get an iterator or collection of some sort, how could I forward that to a jsp page so It could use the Struts tag lib tags for iteration and display? --m P.S. Thanks.
Re: Putting it all together, help???
Title: RE: Putting it all together, help??? / 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. // Yes, I've already got a fairly extensive EJB backend, my only question was that I won't be populating a form and since Struts is not a servlet engine, how does the HTML get generated for my example. In my actions perform method, I query some session EJBs for some data and would like to display it in a table. Supposing I can get an iterator or collection of some sort, how could I forward that to a jsp page so It could use the Struts tag lib tags for iteration and display? --m P.S. Thanks.
RE: Putting it all together, help???
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-