On Fri, 2006-07-28 at 19:58 +0200, Henning Schild wrote:
> Hello,
> 
> i am currently working on my first struts application. That is why i am
> looking at the example and there are a few things i do not understand.
> 
> The tour says something about an action-mapping 
> 
> > <action path="/EditRegistration"
> > ...
> 
> indeed there is nothing like this in the struts-config.xml
> 
> How does struts know which Action to execute? It could know that from
> the name because there is an EditRegsitrationAction.class but how does
> it know which jsp to use? There is a Regsitration.jsp which handles
> EditRegsitration.do but i don't see a action-mapping for that. I also
> don't see any form-bean definitions for the whole Registration stuff.
> Are there naming conventions which handle all that? And if they exist
> where do i find documentation about that.
> I read the UserGuide but that does not tell about naming cenvetions for
> form-beans or action-mappings.
> 
> I hope you can answer my questions.
> 
> Henning

Henning,

>From the Tour:

        If you check the struts-config.xml, you'll see that the
        editRegistration action is mapped to the (surprise again!), the
        EditRegistrationAction; it uses a registrationForm bean, and
        registration.jsp for input.
        
            <!-- Registration form bean -->
            <form-bean name="registrationForm"
            type="org.apache.struts.example.RegistrationForm"/>
        
            <!-- Edit user registration -->
            <action path="/editRegistration"
            type="org.apache.struts.example.EditRegistrationAction"
            name="registrationForm"
            scope="request"
            validate="false"
            input="/registration.jsp">
            <forward name="success" path="/registration.jsp"/>
            </action>
        
The fact that the path, type, and forward values are similar is simply a
convention that makes it easier to understand without memorizing the
struts-config file.

The /editRegistration.do URL is mapped to the EditRegistrationAction
class in the <action> tag shown.  It's tied to the form-bean above
through the name attribute of the <action> tag.

The Action forwards to the JSP view via a call at the end of its execute
method:

  return mapping.findForward( "success" );

And as you see there is a local forward for this action keyed on
"success" to "/registration.jsp".  If it was absent, there would need to
be a global forward for it.

I hope this helps.

I'm a Struts newbie myself, hoping to improve my understanding through
helping others (and being corrected unmercifully).

Chris

-- 
Christopher D. Goldman
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to