|
There are a lot of Struts books on the market now, most show you how to build a complete application. Part of the point of Struts is that it is a framework, so you do not exactly "write code". Struts implements MVC (Model View Controller). The Model is your business logic. It should just be Java code that has no dependencies on Struts, or where it is used. It could be using JDBC, or calling RPG, or EJB's or Web Services. This is all obviously code that you write, but you do it in a way that doesn't really matter how you implement it in terms of a web browser or fat client. It doesn't need to know about it. Struts acts as the Controller and allows you to glue together your View with your Model. It is mostly controlled via XML configuration files. The XML tells it which of your Java classes to call in certain situations. These classes are small Java classes you write that inherit from Struts. These classes are typically pretty easy to write. They are where you make use of your Model layer. For example, perhaps you construct your Customer object and tell it to return all Customers in Ohio. You take the results and store them in the Request object and return a value that is usually just a success/failure value but can be more complicated. Struts then looks at this value and routes onward to the appropriate View component which is usually a JSP. The JSP is then just configured to pull the data out of the request object and display it to the user.
It is actually a lot of work up front because there are all of these little pieces to put together. But once you get about 50-60% into the project it starts to really pay off. The Struts controller can be easily reconfigured by changing the XML file. So in the above example if you decide you now want to route the user to a different JSP, you just create the JSP and change the XML to point to the new file. Your Java code doesn't change. Likewise, you could enhance your Java to return multiple values that determine which JSP it routes to and maybe you return a different value based on the type of user.
The beauty of Struts is that once you learn it you see that it is very simple. The entire project only consists of a small amount of classes. What they have done is taken a very commonly used design pattern known as the "Front Controller" and implemented it in a way that lets you "configure" it with XML files. A lot of people that do not use Struts wind up writing a front controller anyway, because it is a powerful and useful pattern. What they do not do is write all of the code to configure it via XML. That is the advantage to going with Struts. Of course other benefits are all of the graphical toolings that have been created which are essentially just graphical ways to represent the XML configuration file.
Mark
_______________________________________________ This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l. _______________________________________________ This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.