aspose file tools*
The moose likes Struts and the fly likes Defining characteristics of the DispatchAction class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Defining characteristics of the DispatchAction class" Watch "Defining characteristics of the DispatchAction class" New topic
Author

Defining characteristics of the DispatchAction class

Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
I am currently learning ASP.NET, in part, by comparing it to Struts. One area of comparison that I find interesting are the respective ways in which they organize action methods.
In Struts, classes can be coded into individual action classes, although I find myself more and more subclassing the DispatchAction class and organizing their methods according to the object of one or more actions. For instance, if I perform create, read, update, and delete operations on a Security Account object, I will more likely than note create a subclass of the DispatchAction class called SecurityAccountActions and populate it with CRUD methods.
In ASP.NET, a technology that is built around an HTTP-based client/server event-driven model, each Web Form or control has an associated "code-behind" page which defines methods for each of the events that can be raised in the Web Form or control. If my Web Form displays tabular list of addresses that I can work with my clicking on hyperlinks, buttons, etc., then its associated code-behind page will will consist of one method for each event caused by modifying a text field, modifying a radio button, clicking on a hyperlink, etc.
Although the two technologies are different in a number of respects, they both separate presentation from application code by (i) confining presentation code to the presentation page (JSP or Web Form), (ii) confining application code to a programming class (DispatchAction class or code-behind class), and (iii) using the application code to populate the information in the presentation code.
What I find interesting is the criteria that each use to locate action methods in their appropriate application classes. My personal approach in Struts is to identify actions logically along business lines (ex: create account, delete account, etc.) and then group these actions into DispatchAction classes according to the object that actions can be performed on. ASP.NET's approach is to identify actions as mandated by its event model and then group these actions according to the Web Forms or controls containing used to raise the events.
I have to admit that I MUCH prefer the Struts organizational scheme to ASP.NET's -- with the exception that the latter's technologies lead to VERY fast development time. What do others in this group have to say about the two approaches. What is the preferred way of organizing action methods into classes? And, in asking this, I want to express right from the start that I hope this thread does not turn into a flame war :-)
Oh! And in anticipation of the potential rebuttal that the Struts organizational schema is superior to that ASP.NET because methods in the code-behind classes would have to be moved from Web Form to Web Form as changes are made to the content and organization of a given Web Form, I rebut that Web Forms can be hierarchically decomposed into atomic elements called 'controls' which in turn have their own code-behind pages and can be situated in any other Web Form and some controls -- much like Struts Tiles and JSF technologies offer us today.
Cheers,
Darryl
[ July 27, 2003: Message edited by: Darryl A. J. Staflund ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

All I have to say is that if given a choice, I would use ASP.NET over J2EE/STRUTS any day. It took my 2 days to "get" ASP.NET. I am still struggling with J2EE/STRUTS to this day after several months of books and online tutorials and Javaranch.
I don't know if this goes along with your questions, but one of my favorite things about ASP.NET is in the CodeBehind, if I need to change a Label object on the aspx page, it is all programmtic and a simple .reference to the object on the aspx page.
And when I say "given a choice" I mean the client doesn't care what OS the Web App sits on. Anyway, that's just my opinion. To be honest, if someone would come up with a Java IDE Solution as good as VS.NET, it might help Java.
I still love JAVA, but sometimes it's just too much work for something simple.


GenRocket - Experts at Building Test Data
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303

All I have to say is that if given a choice, I would use ASP.NET over J2EE/STRUTS any day.

True true! I hardly know ASP.NET at all but I am continually floored at the ease of development in .NET. There are so many things it does for you. The code that showed me the true speed of development is the sample ASP.NET application code that comes with .NET 2003. It has you create a web service that connects to a back-end database as well as HTML- and Windows-based client applications that interact with the web service in order to populate its controls. This took me an hour to code and get up and running. This would be a good demonstration for anyone I think. But given I'm working on the SCEA assignment forever now which has you draft plans for a similar application (HTML- and Windows-based applications interacting with a common business that uses HTTP and web-service-type technologies to interact with third-party code and services) -- well, that just spoke volumes to me.

> It took my 2 days to "get" ASP.NET. I am still struggling with J2EE/STRUTS to
> this day after several months of books and online tutorials and Javaranch.
Did you ever get your book? :-) Maybe that's the missing key!

> And when I say "given a choice" I mean the client doesn't care what OS the
> Web App sits on. Anyway, that's just my opinion. To be honest, if someone
> would come up with a Java IDE Solution as good as VS.NET, it might help Java.
Agreed. I have a very real aesthetic appreciate for Java but -- grrrrr!!! -- it takes such a long time to do anything with it.
Darryl

PS: Has JavaRanch ever considered setting up forums specifically to compare and contrast competing Java technologies with a view to learning more about each of them? I think it would be great -- you know? Some interesting forums I'd love to see would be:
1. JSP/Servlets vs. ASP.NET vs. ColdFusion vs. Perl vs. PHP vs. etc.
2. AWT/Swing vs. .NET WinForms vs. Tcl/Tk vs. etc.
3. EJB/JDO/JDBC vs. ADO.NET vs. etc.
PPS: Oops. I shouldn't have used '.vs' -- sounds like I am inviting a flamewar. I'd hope these forums could compare and contract approaches of all of them with a view to learning the strengths and weaknesses of each as well as to cross-pollinate approaches in our own apps.
[ July 27, 2003: Message edited by: Darryl A. J. Staflund ]
[ July 27, 2003: Message edited by: Darryl A. J. Staflund ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Did you ever get your book? :-) Maybe that's the missing key!
No!! I do have Struts In Action though. I have some major issues with this book, but that is a different story all together.
Has JavaRanch ever considered setting up forums specifically to compare and contrast competing Java technologies with a view to learning more about each of them? I think it would be great
This was discussed at one point and it was decided that those topics could just as easily be covered in the appropriate Forum. So if you wanted to compare SWING and Windows Forms, just post something in the SWING forum. The problem with those threads is , as you kind of stated, it has huge potential of becoming a flamewar which I hate. I was actually able to start a thread in the JSP forum comparing PHP with JSP/Servlets and it went pretty good for a while. In fact, you participated in that thread.
Maybe if you and I teamed up with some of these discussions, we could keep them under control together.
I literally converted a Java Swing application that took me about 6 months to code to ASP.NET in 2 weeks. I even have more functionallity in the ASP.NET version because it was easier to implement some features. And this was my first attempt at ASP ever in my life. So that should say something. I will concede that it has enough similarities to JSP and that contributed to my understanding of the technology. I used C# as my CodeBehind langauge which is so similar to JAVA. Plus, I already had a bit of experience with C# before hand. But still, 2 weeks vs 6 months? I contribute a lot of that to Visual Studio as well. I still stand behind my comment on JAVA needing a Visual Studio.
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
> I still stand behind my comment on JAVA needing a Visual Studio.
They did! It was called Visual Studio :-) Ah, but then Sun sued MS for it's improper use of Visual J++ and alas it is no more.
Wow. 6 months vs. 2 weeks. That's incredible. I want to try converting one of my bigger applications but I just don't have the motivation :-)
What I really like about ASP.NET is the thought they put into some of their components -- thought which saves massive amounts of coding. Some examples are:
1. Viewstate technology. By passing the view state of every control on the client side from request to request, .NET is able to restore tree-state, button selections, etc. -- all without the developer having to develop and manage the code to do so.
2. "Rich" Server Components. By developing drag and drop HTML-based GUI components like calendars, grids, etc. which can be connected to stylesheets, plugged into data sources, persisted to XML, etc. .NET takes the tasks of developing and managing these components out of our hands. VERY nice! I hate having to develop navigation trees for each app I develop :-) Hopefully JSF will live up to its promise of providing us a Java counterpart.
3. Disconnected Data Sets. ADO.NET is marvelous. Not only does it work by default in a disconnected environment and supports advanced features like optimistic locking, we can create client/server applications without having to develop or extensively modify a persistence framework.
4. Built-In Caching. Both ASP.NET and ADO.NET have built-in support for server-side caching. There is no need to implement commercial caching frameworks, etc.
5. Native XML / Web Services Support. .NET's XML offerings are incredibly easy to implement and use. I haven't used the web service features of J2EE 1.4 or WSDP but I've been reading the O'Reilly Nutshell book on the matter and it's going to be another steep learning curve.
6. XML / DataSet Interchangeability and Synchronization. Wow. I can open a data source, treat it as though it were an XML feed, and synchronize dataset and XML views of the same data. That is incredible.
Anyway. that's it for me :-)
Darryl
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
Originally posted by Gregg Bolinger:I still stand behind my comment on JAVA needing a Visual Studio.

Gregg, have you ever tried WebSphere Studio Application Developer? Disclaimer: WSAD is built on top of Eclipse, and I sell a book on Eclipse, and I also write an online column about WebSphere, so I'm a pretty biased observer, but WSAD is a very feature rich development environment. You can edit HTML, JSPs, CSS, servlets, beans, all in one environment (including WYSIWYG editors for all your UI components), then set breakpoints all throughout the stream and debug right on your PC in a special test environment, which currently supports both WebSphere and Tomcat application servers.
Once you're done testing, you can package your application up in a WAR or EAR file and deploy it on any J2EE compatible server. It's really quite an impressive environment. Now, I'm just about to embark on my first steps with .NET, starting with the free Web Matrix tool, so I'll be interested to see about some of the points you folks have made. But again I'm very biased: I am so afraid of being locked into MS proprietary software that it will take an awful lot to get me to choose MS tools, unless they also put gas in the car and cook dinner. But I'm going to try and give them a fair shot.
Joe
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Joe Pluta:

Gregg, have you ever tried WebSphere Studio Application Developer? Disclaimer: WSAD is built on top of Eclipse, and I sell a book on Eclipse, and I also write an online column about WebSphere, so I'm a pretty biased observer, but WSAD is a very feature rich development environment. You can edit HTML, JSPs, CSS, servlets, beans, all in one environment (including WYSIWYG editors for all your UI components), then set breakpoints all throughout the stream and debug right on your PC in a special test environment, which currently supports both WebSphere and Tomcat application servers.
Once you're done testing, you can package your application up in a WAR or EAR file and deploy it on any J2EE compatible server. It's really quite an impressive environment. Now, I'm just about to embark on my first steps with .NET, starting with the free Web Matrix tool, so I'll be interested to see about some of the points you folks have made. But again I'm very biased: I am so afraid of being locked into MS proprietary software that it will take an awful lot to get me to choose MS tools, unless they also put gas in the car and cook dinner. But I'm going to try and give them a fair shot.
Joe

Joe, I haven't tried WSAD yet. But after what you said about it, I would be willing to give it a shot. It sounds impressive, biased or not. Do they have a free trial download that actually has ALL the features?
Web Matrix will get your feet wet, but once you delve into Visual Studio, you will just want to uninstall Web Matrix right off your PC. Web Matrix won't do CodeBehind automatically. You will have to manually create all your codebehind files and configure the App to use CodeBehind. (CodeBehind is a VERY nice way to do things in ASP.NET). Plus, you don't get all the other kewel features that VS has to offer with Web Matrix.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ah, but then Sun sued MS for it's improper use of Visual J++ and alas it is no more
But there is still J#...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Defining characteristics of the DispatchAction class