Integrate stecks with Struts (2)

Source: Internet
Author: User
Integrate stecks with Struts (2)

I wanted to write down the learning process myself, but the result was translated, and it was not complete.
Well, it's just a translation.

Http://strecks.sourceforge.net/doc-actions.php

1. Actions
In stecks, the traditional strtus action is separated into two objects.
One is controller action and the other is an action bean.

 

1.1 controller actions
The idea behind controller action (also called Action Controller) is:
The general request processing logic can be abstract and reused by many actions.

For example, a simple crud web application usually uses three types of request processing logic:
@ Actioninterface (name = basicsubmitaction. Class)
Public class basicsubmitcontroller extends basebasiccontroller
{

@ Override
Protected viewadapter executeaction (Object actionbean, actioncontext context)
{

Basicsubmitaction action = (basicsubmitaction) actionbean;
Actionform form = context. getform ();

Httpservletrequest request = context. getrequest ();

Boolean canceled = false;
If (request. getattribute (globals. cancel_key )! = NULL)
{
Canceled = true;
}

If (Form instanceof bindingform &&! Canceled)
{
Action. prebind ();
Bindingform = (bindingform) form;
Bindingform. bindinwards ();
}

String result = canceled? Action. Cancel (): action.exe cute ();
Return getactionforward (context, result );

}

}
Stecks already has many built-in controllers that mimic dispatchaction, mappingdispatchaction, and lookupdispatchaction.

 

1.2 Action beans
After the request processing logic is extracted to the Controller action, the action bean only needs to process the specific business logic.

In stecks, Action bean will be configured into the struts-config.xml, just like the original strtus action.
When called for the first time, the annotation of this action bean is used to determine the controller, and the Controller instance will be created.
The controller integrates action and will be stored in the Action cache to process subsequent/concurrent requests.
After each request is received, the Controller will create a new action bean instance. The action controller is stateless and shared by multiple requests.

By default, Action bean and action controller correspond to the following:
Org. strecks. Action. basicaction org. strecks. Action. Basic. basiccontroller
Org. strecks. Action. basicformaction org. strecks. Action. Basic. basicformcontroller
Org. strecks. Action. basicsubmitaction org. strecks. Action. Basic. basicsubmitcontroller
Org. strecks. Action. basicdispatchaction org. strecks. Action. Basic. basicdispatchcontroller
Org. strecks. Action. navigableaction org. strecks. Action. navigable. navigablecontroller
Org. strecks. Action. navigableformaction org. strecks. Action. navigable. navigableformcontroller
Org. strecks. Action. navigablesubmitaction org. strecks. Action. navigable. navigablesubmitcontroller
Org. strecks. Action. navigabledispatchaction org. strecks. Action. navigable. navigabledispatchcontroller

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.