webwork About
WebWork developed by the OpenSymphony organization dedicated to components and code reuse J2EE Web framework. WebWork latest version is 2.2.2, and now the WebWork2.x formerly developed by Rickard Oberg WebWork, but now has been split into Xwork1 WebWork and WebWork2 two projects.
directory
WebWork WebWork started to install the core concepts of WebWork ValueStack and ELInterceptor (interceptor) WebWork interceptors provided by the principle described WebWork WebWork WebWork real prospect of the future and skills as shown in the illustration summary WebWork entry:
work simple, flexible and powerful, it is a standard framework for achieving Command mode, and spun off completely from the web tier. Xwork offers many core features: front-end interceptor (interceptor), runtime form attribute validation, type conversion, a powerful expression language (OGNL the Object Graph Notation Language), IoC (Inversion of Control dependent reverse control) containers . WebWork2 built Xwork above, processing HTTP requests and responses. All requests will be its front controller (ServletDispatcher, the latest version is FilterDispatcher) intercepted. Front controller requests data on the packaging, initialize context data, according to the configuration file to find the corresponding request URL Action class, the implementation of Action, the implementation of the results will be forwarded to the appropriate display page. WebWork2 support for multi-view that some of view can be used JSP, Velocity, FreeMarker,
air force one low, JasperReports, XML and so on. WebWork we mentioned below will WebWork2, using the version is WebWork2.2.2. WebWork WebWork install If you just build a development environment, it will be very simple: one, to download the latest WebWork2.2.2 project. 2, build a Web application (this is not difficult, right); and copy all the WebWork framework needed to run Jar files to the Web application WEB-INF lib in. These Jar files, you can WebWork project lib default directory to find that all the files inside that directory. Of course, do not forget today's 3, in the configuration file, WebWork Web.xml front controller FilterDispatcher, that is a normal Servlet Filter (filter) only. But if it is used in actual projects,
nike air force one, the installation process there are some issues that need attention: 1, on the front controller. 2, on the Action requested URL suffix. 3, Jsp page, WebWork tag libraries do not need to define in web.xml. 4, Jsp page, the default 5, if the presentation layer technology uses Freemarker (WebWork official recommendation, is my personal recommendation), if the page requires the use of tag library must be configured in the web.xml JspSupportServlet. 6, there are other custom, such as: coding, labeling the template file, etc., can be webwork.properties file configuration. If the file is not in ClassPath, WebWork WebWork will automatically read the package inside the default.properties Jar file. The three core concepts WebWork WebWork key part of 1, Actions. Action on behalf of a general request or a call. In WebWork, in general, need to implement the Action Class Action interface, or directly inherit the base class ActionSupport. That is, it is to achieve the default execute method and return a defined in the configuration file Result (that is, a custom string only). Of course, Action can also be just a POJO (ordinary Java objects), do not inherit any class need not implement any interface. Action is a request of the controller, as well as the role of the data model, we strongly recommend not to put business logic in the Action. 2, Results. It is the definition of a results page. It is used to indicate the Action implementation, how to display the results of execution. Result Type that how and technology with which view to show results. By Result Type, WebWork can easily support multiple view technologies; and each of these technologies can change the view, Action parts without any changes. 3, Interceptors. WebWork interceptors, WebWork Action intercepted request, before or after the implementation of the Action call interceptor method. This approach can plug into the Action of the functional. WebWork framework, many features are provided in the form to the interceptor out. For example: Parameter assembly, validation, internationalization, file upload and so on. ValueStack and EL on the description of ValueStack: 1, ValueStack is actually a Java object placed on the stack it, the only special is that you can use EL to get the value of the object properties of the data stack, and can stack the object properties for the value of the assignment. 2, EL, full name of the Express Language, the expression language. Do not be intimidated by the language, it is a simple object navigation language. A string (for example: the method name) and special characters (such use. That call the corresponding property method). By EL, we can deposit, withdraw object data, but also can directly access the class static data, call the static method. 3, WebWork's ValueStack bottom of a third party open source projects OGNL implementation. So OGNL EL also follow the norms. We are in development, almost without knowing the details of OGNL. 4, WebWork to every request to build a ValueStack, and all relevant data objects (for example: Action object, Model objects, etc.) into ValueStack in. ValueStack then exposed to the view page so that you can directly access the page background processing generated data. Here we use an employee class, for example, using Junit framework (unit testing framework) to show ValueStack function. We have an Employee class, which has two attributes: name, address. Name is a string, the address is an object, the address class has state, city, street three properties. Interceptor (Interceptor) on the blocker: 1, an interceptor is defined in the xwork.xml file a stateless Java class, it at least to achieve the com.opensymphony.xwork.interceptor.Interceptor XWork interfaces. 2, implement Interceptor interceptor interface code to implement some of the intercept method. In the intercept method, can return a Result string, so that the entire implementation of a direct Therefore, the general parameters of this method to call the invoke method of an object invocation, and returns the result of the implementation of this method. This will continue the implementation of the interceptor after the Action's execute method and methods. 3, most of the time, the direct successor to WebWork interceptor abstract class com.opensymphony.xwork.interceptor.AroundIntercept or on it. At this time, the need to achieve it before and after methods. Before method call in the Action prior to execution, after the Action execution method after the call. 4, the execution order of interceptors. We can put together multiple interceptors assembled into an interceptor stack. This interceptor will follow the order of the stack before top-down method of implementation, all before the end of method execution, then the implementation of Action of the method, the implementation of Result of the method, and then returns the execution results, and finally from the bottom after the implementation interceptor method . 5, the interceptor filtering. We usually applied a common definition of the use of multiple interceptors interceptor stack. However, some Action method invoked, which does not need to be part of the interceptor. At this time, we can use interceptors filtering. If the interceptor to have a filter feature, you must implement the abstract class com.opensymphony.xwork.interceptor.MethodFilterInt erceptor. Thus, when defining the interceptor or the interceptor stack referenced in Action, we can specify which Action is to be filtered, which Action is not filtered. WebWork interceptor introduced a provision to automatically request data for the Action setting Http interceptor (Parameters Interceptor). This interceptor is very convenient and practical, but the fully automatic assembly object data, it may be a security problem. If the Action does not need to set the data, then the Action can be as long as the interface to achieve com.opensymphony.xwork.interceptor.NoParameters. Action in the part of the data if it is to be automatically set, part of the data set is not allowed, so you can implement the interface com.opensymphony.xwork.interceptor.ParameterNameAw are, can this interface acceptableParameterName (String parameterName) method, the definition of what methods we can accept, If allowed as long as this method returns True on it. 2, filter parameter function interceptor (Parameter Filter Interceptor). It can be a global Action to prevent illegal or not allowed access to the parameters. Can be very good and the assembly of the above parameters used in conjunction with the interceptor. 3, static data set for the Action interceptors (Static Parameters Interceptor). It can be defined in static
Action parameters set in the Action. 4, data validation interceptor (Validation Interceptor). Defined, will be called the verification file or implement the interface com.opensymphony.xwork.Validateable verify all the validation. 5,
air force one high, the verification process dealing with the interceptor (Workflow Interceptor). It used in conjunction with the above interceptor to handle verification process. If verification is to move forward and if there are validation error message, go directly to the results of Action defined in the input (input) page. 6, type conversion error handling interceptor (). It first went to get type conversion error messages (mainly from the Http request parameters to set the interceptor produced), if taken to the error message, it sends an error message passed to implement the interface com.opensymphony.xwork.ValidationAware of Action,
air force one low nike, so we These error messages can be exposed to the page. 7, Action chain of interceptors (Chaining Interceptor). It is used to copy data in the previous Action's properties in the current Action. It requires the previous Action must be chain Result (<result type=8, to prevent repeated submission page (or refresh the page repeatedly) interceptors. Token Interceptor and the Token Session Interceptor is the interceptor to prevent duplicate submissions. The latter difference is stored in the Session of the latest result of the request data. 9, the file upload interceptor (File Upload Interceptor). For file upload function. If someone had hand-written file upload process, it would certainly marvel at the interceptors. We can set the interceptor size and type of the uploaded file limit. Remember the need for third-party library support file upload, as long as the configured webwork.properties, and copy the corresponding jar package on it. 10, the progress bar to wait for the interceptor (Execute and Wait Interceptor). When Action actual implementation will take a long time, we can use the progress bar to wait for the interceptor. It will put back the implementation of Action, and in front of a progress bar or waiting for news tips page. 11, there are other less common interceptors, we can find in the WebWork documentation, do not be introduced here. Principles of WebWork WebWork site provides a complete WebWork chart. It describes a request from the client server-side response to the last the whole implementation process. Chart is as follows: This chart is divided into five parts of a, respectively, the Fifth of five parts which different colors. 1, light gray box. Representing a client a Http request, and server-side operations after the end of a response. 2,
nike air force one low, light red box. Said a request to go through the Action Servlet filters (Servlet filter). We can see that the last filter that we have already described WebWork front controller. 3, the blue box. This is a core part of WebWork framework. 1) a request to the WebWork front controller, it will first parse out according to the requested URL corresponds to the action name, and then to consult ActionMapper whether this action is executed. 2) If ActionMapper decided that the action needs to be implemented, the front controller put the work assigned to ActionProxy. Then they will consult the WebWork's configuration manager, and read the definition in the web.xml file, the configuration information. Next ActionProxy ActionInvocation object is created. 3) ActionInvocation is Xwork principle (Command mode) the implementation section. It will call the Action defined interceptor (before method), Action Method, Result method. 4) Finally, look at the chart above, the direction of the process, it will further the implementation of the interceptor (after method), then back to Servlet Filter section, the final end and the results passed to the user a response. 4, indigo color box. This is part of the interceptor, the interceptor in the above section we have the detail. 5, yellow box. This is what we in the development of Web applications, you need to develop their own procedures. These include: Action class, page templates, the configuration file xwork.xml. WebWork combat and skills to space limitations, we can not give many details in this section, specific examples. In fact, the WebWork code package, there is a very good demonstration projects - showcase, it demonstrates with the example of almost all the features of WebWork. Beginner friend is worth repeated study. 1, the multi-view support. WebWork framework naturally supports multiple view technologies, including: Jsp, FreeMarker, Velocity, Jasper Reports, XSLT, there are other view technologies. This will be particularly useful in agile projects. In my consulting projects, there is a because of technical reasons, the first of Jsp view technology to Velocity, and later transformed into FreeMarker. One, Action classes, and the background of the program does not make any changes. If you need a view of the presentation layer technology, I would be hesitant to recommend no better FreeMarker. This is also the official's recommendation. The use of technology on the view, first set up the view technical operations environment. Then is to write the script page, the last is xwork.xml file configuration. Xwork configuration file, Result of the type parameter is used to indicate the view technology. In the showcase project, the use of technologies to view: Jsp, FreeMarker, Velocity, Jasper Reports. 2, Action data validation. In WebWork, you can achieve in the three data validation. First, verify the file (for example: ActionClass-validation.xml file) of the definition of data validation rules. Second, the Action interface to achieve com.opensymphony.xwork.Validateable validate method. Third, the implementation of the Action method, the hard-coded to achieve validation. Of course, in the realization of authentication, we use as much as possible in the first two methods. About validation: 1), the first authentication requires And can bind the verification file from any level, an Action class can bind a verification file, but also for a specific file in the Action xwork.xml bind a verification file defined, can be an attribute of the object bound Action a verification file, or even the parent Action class for binding verification documents. 2), WebWork documentation to verify the authentication provided some standard implementation: for example: field must be filled in, integral, E-mail addresses and more. We can also use the expression language to achieve a more complex data validation. 3, the type conversion. Outside has been mentioned earlier, WebWork will automatically string parameters from the request data needed for assembly of Action objects. Thus, there will be a type conversion problems. If the Action field is a basic type or a data object, WebWork will automatically help us deal with. If the Action field is a collection, or we need a specific type of conversion, this time, we can convert the type definition file (ClassName-conversion.properties) in the definition of transformation rules. 4, a multiple Action methods of implementation. WebWork in Action is based on the Command pattern implementation in WebWork, in addition to the interface to achieve Action execute () method in addition, Action can also define multiple execution methods. If these methods have no method parameters and return return string. So that we can use the Url in the format similar to the following access: actionName! MethodName.action, such as user! DoAdd.action, call the user Action class doAdd method. In the latest in WebWork, Action Action class does not implement the interface even. 5, Action chain (Action Chaining). In WebWork, the time a user requests shared by multiple Action completed. Each Action can only achieve their own functional unit, so that we can based on business need for the user's first request for selecting one or more functional units to achieve the Action. Action in such a multiple chain between the interceptor through the sharing of data. If a request by the Action x chains to Action y, if x then y need to get the data, we need to add Action y chain interceptors. 6, multiple module support solutions. WebWork provides a very flexible multi-module solutions, so that we can be very good organization of complex Web application projects. 1) can be xwork.xml file, use the include tag contains another one xwork configuration file. For example: <include file=We can define a business module side to a package, package to support inheritance, child package can enjoy all the definition of the parent package. 3) can define a namespace for the package. Can be defined in different namespaces the same action name. Namespace will be used to access the action of the URL, based on this namespace, we can achieve resource access control permissions. 7, doInput methods. This is our usual tips, sometimes the request is a page template, we can not write for the Action class it alone, then we can use the doInput ActionSupport method, a direct return in Actoion defined as result. 8, prepare method. If the implementation of the Action, you must be initialized with some data. We can use these parties to prepare the code initialization method. At this time, Action class to implement the interface com.opensymphony.xwork.Preparable, while the definition of the Action needed PrepareInterceptor interceptor support. 9, Action of the Model Driven. Most of the time we are all used Action's Field Driven, that directly to the Action field as the data model. Model Driven Action is designed to specify a model for this object, so what good is it? Benefit is less in the expression language in an object name prefix. 10, Quick Start. This is a very exciting feature WebWork2.2.2. It can be like perl or PHP can quickly see the result of the program. This in Web development, you can not compile the Java source code, do not do packaging and deployment, you can quickly see the latest results of the program to run and improve development efficiency. We can extract the package in the WebWork source root directory, enter the command: java-jar webwork-2.2.2.jar quickstart: showcase (requires jdk1.5 support) to Quick Start mode, run the showcase project. Looking WebWork future is of great concern to many people a problem. Particularly WebWork2.2 release, the official claim that WebWork and Struts framework will be merged. This has led some customers had concerns about WebWork after the merger, is not it means their own technology in this area WebWork and experience have been a waste? Have been used or will use the WebWork project is not to mean more risk? The answer is: nothing to worry about that. WebWork and Struts merger is different advantages, and then the birth of a more efficient Web framework. And this framework used is the excellent technology and Struts WebWork strong communities. Combined as follows: 1, resulting in a new project Struts Action 2.0 = WebWork2.2 + functionality and features some of Struts. 2, WebWork framework will stop the increase of new features, if there is a new release will be the Bug changes. 3, code, framework developers, the community will move to Struts. 4, the combined goal is to increase productivity. 5, Struts is no longer a framework, it is a community. 6, Struts community, there are two major Web framework. Action model is based on a Struts Action; another component model is based on Struts Shale. WebWork is a summary of one of my favorite toolbox J2EE Web framework. I worked on a simple project using Jsp and JavaServlet; also have their own development through the Web-based MVC framework; in 2002 and started using Struts development; later projects were also used Tapestry and Spring MVC Web Framework; also in today's AJAX trend in the drift. Some of the above techniques are also very good, unauthorized use of any one of them will bring you a lot of production efficiency. But I still prefer WebWork. WebWork's different, thanks to the OGNL is based on powerful data storage, access methods, effective in its function was decoupling of the interceptor, which was effective in the framework of non-invasive design. It is precisely because it did make Web programming more natural, simple,
air force 1 high, flexible and efficient. More Atlas Atlas entry Open Category: computer languages, computer technology, programming, programming languages, the program I came to improve the