[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Steve Leach:
I haven't actually used struts, but I looked at it and decided it was not right for my project.
While it would take months (years?) to write the equivalent code, you are probably looking at less than a week to write just the bits you need, and the result will be something specific to your requirements that is easier to use (probably).
My app uses...
* Controller servlet (very simple)
* Action classes (called from the controller servlet to handle form posts)
* Data beans (also quite simple, one for each data type)
* Update managers (hold business logic, manage data updates)
* Data store (manages access to the database)
* Data sets (used by the data store to deal with data access for each type)
* Custom tags (I wrote a lot more than I needed)
Most of the code is fairly generic, and driven from config files. For example, I have a generic "UpdateManager" class that is config file driven and can handle simple "read from db to bean, edit the bean, write changes back" situations. I then have an "OrderUpdateManager" subclass that overrides a few of the methods to deal with multiple items per order.
I have tags like "UseData" which has a "datatype" attribute. The data type is used to select a data set from the data store which builds a data bean and adds it to the page context. All totally generic and data driven.
The one area where I think Struts might provide real advantage is form validation. I have used custom UpdateManager classes for this, but I haven't explored the Struts approach.
Of course, Struts advocates will probably point out a lot of stuff that it does that I am ignoring; if you need a lot of it then it might be worth it. For me, I'm just not happy working they way Struts wants me to.
James Carman, President<br />Carman Consulting, Inc.
To simplify your life, why don't you try using Struts along with XDoclet, and you wouldn't have to write the "bits you need" as Struts probably already has them built in? XDoclet just makes using Struts (and many other technologies like EJBs) MUCH easier. I'm not saying that Struts is the "be-all end-all" solution to everything. But, it does make applications structured the way you just mentioned easy to develop. I like it, but I don't use all aspects of it. I use JSTL for most of my non-form custom tags.
Originally posted by Steve Leach:
I found that spending a week or so building my own framework (that works the way I want it to) did simplify my life.
And because my framework does just what I want, the way I want, I don't need XDoclet or EJB to make it easier.
The problem with any development framework, including struts or a home-grown one, is that they force (or at least strongly encourage) a particular way of working. If you don't want to work that way you can end up spending more time fighting the framework than it saves you, and you will end up with an application that is a nightmare to support.
The original poster implied that he is willing to build his own framework, and I wouldn't want him to think that is necessarily a bad idea.
James Carman, President<br />Carman Consulting, Inc.
Originally posted by Steve Leach:
* Update managers (hold business logic, manage data updates)
* Data store (manages access to the database)
* Data sets (used by the data store to deal with data access for each type)
Consider Paul's rocket mass heater. |