In Strut 2, calling any method on a class is directly supported.
Essentially, "execute" is just the default. We can also specify
another mapping or method to call from a button on a form, meaning
that the same form can submit to different methods on the same class,
or a different mapping. Struts 2 also supports (but discourages)
Action chaining as a result type. One mapping can chain to another
mapping, and the framework will copy the properties forward. Features
like these might eliminate the need to use another mapping as a
switching mechanism.

Struts 2 uses a hierarchical approach to validation which could be
used to support a multi-page workflow. (Struts 1 simulates a hierarchy
by using the page property on the ActionForm.) The validation follows
the Java class, not the action mapping. If class2 extends class1, then
when class2 is validated, the validations for class1 also fire.

If you like to collect all the methods for a workflow into a single
class, then, in practice, class2 might be an empty class that only
exists to appease the XWork Validation system.

To get started with Struts 2, I still strongly recommend WebWork in
Action, since fundamental mechanisms like Validation are still all the
same. Roughley's Starting with Struts 2 is also a fine introduction to
the framework.

I'm told complete Struts 2 books are in the works, but Kurniawan's is
the only one with a release date (Oct 1), meaning others may still be
months away. In the meantime, trust me on WebWork in Action :)

-Ted.

On 8/29/07, Pavel Sapozhnikov <[EMAIL PROTECTED]> wrote:
> Hey guys I have posted before but I think I got no responses not sure what
> happened so here I go with more information this time. I have several
> questions about Struts2. Basically what I am trying to do is to learn
> Struts2 on my own by trying to migrate a small piece of our existing
> application which uses Struts1 / Tiles1 into Struts2 / Tiles2. I have
> successfully achieved in creating my Struts2 application but a little bit
> differently. So one of the questions that I have deals with mapping actions.
> I have the following action definition in struts-config.xml in S1:
>
> <action
>             path="/login"
>             type="com.xfact.swiss.actions.LoginLogoutDispatchAction"
>             name="loginForm"
>             scope="request"
>             parameter="appAction"
>             validate="false">
>             <forward name="login_entry"
> path="/WEB-INF/jsp/tiles/login/login_entry-tile.jsp" />
>
>             <forward name="agency_entry"
> path="/WEB-INF/jsp/tiles/login/agency_entry-tile.jsp" />
>
>             <forward name="temporary_password_entry"
> path="/WEB-INF/jsp/tiles/login/temporary_password_entry- tile.jsp" />
>         </action>
>
> So the way our Action classes are organized is we have many methods per
> Action class and as you can see only one action per class. What you also see
> is we have this parameter="appAction" using that we go to the actions that
> we want and we also have appContext which is essential this path attribute
> so we can go to other actions in struts-config.xml. What I have done so far
> is I have one action for each method in THAT class. What I use is
> type="redirect-action" to go to the action that I want and it works great.
> What I was wondering could I have the same concept in Struts2. I know I can
> put params in struts2 struts.xml. I also about implementing ActionMapper but
> I am not exactly sure what those methods do. So if you could help me out
> with that that would be terrific.
>
> Second question. This one deals with validation. In Struts1 we have
> validation.xml with the following example:
>
> <form name="loginForm">
>             <field property="appContext" depends="required">
>                 <arg0 key="appContext.displayname "/>
>             </field>
>
>             <field property="appAction" depends="required">
>                 <arg0 key="appAction.displayname"/>
>             </field>
>
>             <field property="page" depends="required">
>                 <arg0 key="page.displayname"/>
>             </field>
>
>             <field page="2" property="userName" depends="required">
>                 <arg0 key=" userName.displayname"/>
>             </field>
>
>             <field page="2" property="password" depends="required">
>                 <arg0 key="password.displayname "/>
>             </field>
>         </form>
>
> As you can see for userName and password we have this attribute called page.
> In Struts2 there is no such thing as far as I know. I think this kinda of
> behavior is what its called Validation chaining. I think what needs to
> happen is my Login application needs to have a prerequisite validation so
> even before it starts validating userName and password it needs to make sure
> appContext, appAction are there. I need this exact kind of behavior and I
> looked all over the place for example of validation with validation chaining
> and I haven't found any. Maybe there is a way to extend some other
> validation.xml which includes those things but I haven't seen people do
> that. So if you could help me with that, that would be terrific.
>
>
> --
> Pavel Sapozhnikov
> xFact, Inc
> [EMAIL PROTECTED]
>


-- 
HTH, Ted <http://www.husted.com/ted/blog/>

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

Reply via email to