You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Goke <je...@elysiumpartners.com> on 2002/02/11 19:20:19 UTC

framework questions

I am a fairly new user to the struts project (though not to building J2EE web applications) and I had a few questions.  In the past I have been using my own MVC framework modeled after a combination of sources, including my own ideas, techniques from Advanced JavaServer Pages, recommendations from Sun, and even ideas from the source code of Struts.  After completing my first web application using Struts, I was very happy by how smoothly the build process went, but there were a few things I found missing, that maybe I just haven't figured out yet:

1.	timestamp

		One old trick to force systems like AOL to not cache your pages (since they ignore the header information) is to put a simple &timestamp=xxxx or other random parameter in the URL.  I solved this in my own framework by adding a switch that automatically adds this to the URL.  I have not figured out a good way to implement this in Struts yet because Struts owns all of the URLs (e.g. you specify the destination url in the form tag via html:form ...).  Is this implemented somewhere that I haven't found?

2.	screens (events)

		Some of the web applications I build aren't web sites, but rather full blown applications that replace client/server applications.  One of the fundamental differences that I have found is that the web applications tend to cross multiple screens almost all of the time.  I know it is possible to implement in Struts, but I found the process so valuable that I built a "screen" framework that allows you to specify an action (in my framework this is known as a handler) that reads a screen parameter and then does a switch in the perform and calls the correct method.  This is useful as a nice way to group a number of screens, but even more so it allowed me to wrap functionality around the application that allowed the user to enter into the same series of screens multiple times.  That is, say you had a "create new user" admin screen, you could have 5 of these open at once.  The way I handled this was when the form was a "multi-screen" form (identified as a parameter in the XML file) I stored the form in the system with form,event_id, where event_id was a number that I generated and controlled.  I automatically generated and attached all of the event information to the URL.  This has saved me countless hours of work - is there anything like this in Struts?

3.	preprocessor

		One thing that I added to my framework is the ability to explicitly assign a preprocessor to a page.  That is a page such as /mypage.jsp might have randomaction.do assigned to it.  To make this easier to follow, I also allowed the preprocessor to invoke the same action class as would be used to process the page, except with a flag, thus allowing me to build a switch that would jump to the preprocessor code.  (One thing I noticed about Struts is you end up with a ton of action classes, which can be difficult to manage).  Does Struts have this concept in any way (besides building individual classes and then invoking them as preprocessors that then forward to the destination?)

4.	regions

		I have no idea how the new version of this will work (Tiles), so please excuse my ignorance.  But when I implemented the version suggested by Advanced JavaServer Pages, I quickly hit a wall with the performance.  I fixed this quickly by moving the region logic from .jsp pages to an XML file that was read once by the servlet and cached.  Does tiles address this issue?

5.	cactus/unit testing

		I used cactus/Junit for all of my unit testing, but one frustration I had was that it was very difficult to deal with parameters.  You can do it, but it isn't easy.  To address this issue I created a "RequestUtil" class that I used everywhere I wanted to get request data (instead of calling request.getParameter() directly).  This had other side benefits, but what was really nice is I could set a static treemap variable on the class with parameter,value that, when active, would return the treemap variables.  This made testing much easier since in Junit I could effectively change the request parameters "on the fly".  Does Struts implement anything like this?

6.	JNDI

		There seems to have been a lot of posts concerning JNDI on the forums, and one thing that I built-in was a simple way to get cached JNDI information.  You have to really do this at the main servlet level, because it is ideal to store the connect information in WEB-INF.  It seems this would be a very valuable feature for Struts - has this been considered?

By the way, if any of these sound particularly useful, I would definitely consider implementing some of them for the project.

Thanks,
-Jeff