× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I use and enjoy struts. I REALLY like the Struts support in WSAD (and other flavors) because:

1) When creating a Web Project, I can tell it to include Struts and I don't have all the 'pieces' to put together
2) I can use the Struts design page to drop a few jsps, actions, and connections and it creates the Forms, Actions, and Struts config entries for me...
3) I can keep using the design page, or I can update the pages that were created for me and clone them going forward, putting the entries in the Strut-Config myself...


The code generated by the Struts tools is so clean and tidy. It includes a Comment that says "// Do something here" (I used to code everything by hand).

That is where you put your 'business logic'. It you have too much business logic, or if it consists of reusable concepts, split it out into other Java Classes. Yes, this is where you do your calls to your back end processes.

Struts enables your navigation and your error handling, and enables you to separate Business Logic from Presentation Layer by handling upfront validation on the Server. Then, using Struts HTML and Logic tags (etc) it handles many repetitive code tasks for you.

I did a presentation for the Central Rockies WebSphere User Group on the Struts tools in WSAD.

Kristen



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 thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.