• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is the actionform the controller?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm trying to get a better understanding of the Model 2 framework, looking at this diagram
http://www.mydeveloperconnection.com/html/strutstut_files/image005.gif

In my work, I have the client submitting some information via web browser. The struts-config.xml tells where to send that information. The data goes to the actionform, and then used by the action class. After hte actionclass is finished it forwards to a jsp page.

How does that fit into the diagram above? Can someone clarify what the diagram is showing in terms of how it fits into what I am doing? Maybe that image isn't a good example, but it is similar to a lot of other diagrams on the internet.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The controller servlet is the controller, as its name implies. ActionForms are one way to get information to the view--it's sort of a bridge (or was originally intended to be) between the model and the view.
 
protik ahmed
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So it's sort of like this?

http://bayimg.com/PaldjAaCl

Where would the JSP page go in this diagram, I am guessing it's between the controller and the client.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the JSP would be between the controller and the client, but the diagram isn't very clear in terms of what's happening when, and the action class doesn't return to the controller.
 
protik ahmed
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

So, by what you are saying, When sending something to the action class, say data in a form. The steps would be like this (in terms of the diagram)

A. Client will point to the controller
B. Controller would point to action form
C. Actionform would point to action class
D. Action class would point to JSP?
E. JSP would point to client

I thought the controller would be the struts-config file, when the action class uses something like forward.findmapping("PageX"), it will check the struts config file for the forward mapping, and forward to the relevant page.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The struts-config file is just that, it's a file--it doesn't do anything. The controller servlet is the controller (hence the name). It *uses* the config file.
 
protik ahmed
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ahh ok. So I've edited the image to look like this.
http://bayimg.com/malHGaACL

It is supposed to illustrate when a client does something like submit a form. The action class uses that information and forwards the user to another page, or updates the current JSP. I'm sure there is a hell of a lot more going on under the belt than that, but at it's most basic, is that image accurate?
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

All of the Struts classes that have the term "Action" in front of them are part of the Controller. The Struts Controller is not implemented by a single class. It is implemented by a set of classes. At runtime, the Controller objects are all working together, e.g. ActionForm, ActionConfig, Action, ActionForward, ActionMapping, ActionServlet, etc.

Some of these Controller objects are part of the Struts code base. Some of the Controller objects are derived from data specified in the struts-config.xml files. And, finally, some of the Controller objects are written by application developers. This is how application developers build upon the framework to create their specific applications.

When the application is deployed, it reads the config file and creates the corresponding Controller objects in the JRE. Once this happens, the config file is never read again until the application is shut-down and restarted.

The ActionForm classes are written by the application developer and are for capturing HTML form data from the View and moving it into the Controller. Contrary to common misunderstandings, the ActionForm is not a Model object and should never touch Model code. Controller code extracts data from ActionForm, populates a Model data object and passes this to Model code.

So, the ActionForm is not the Controller, it is a small part of the Controller.

The application developer extends the Struts framework by writting custom ActionForm and Action classes. The application developer connects his custom classes with the core Struts code by creating the configuration XML file.
 
protik ahmed
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, it's just an image hosting website, I've uploaded the image to another well known host.

http://i871.photobucket.com/albums/ab272/s360fw/examplestruts.png

 
machines help you to do more, but experience less. Experience this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic