(Description: Since the level is limited, the translation error is inevitable. In order not to cause the reader to cause the wrong concept, here is used in Chinese and English comparison)
Joachim Peer is an independent J2EE developer. He holds a masters degree in Management Information Systems of Johannes Kepler University, Linz, Austria, with a focus in the fields of software engineering, multimedia application development and knowledge and process management. He is a Sun certified Programmer for the Java 2 Platform. Joachim Peer is an independent J2EE developer. He has MIS mastering at the University of Johannes, Johannes, Austria, mainly attacking Software Engineering, MultiMedia Application Developments and Knowledge and Process Management. He is still a SUN certified programmer based on Java 2 platform.
Many developers find themselves writing similar JSP and servlet code again and again when creating Web-based database applications. The open source project DbForms provides a solution that reduces the amount of coding to an absolute minimum. Many developers have found that when creating a Web-based Database applications are repeatedly written over again and again. Open source project DBForms provides solutions to the number of code to the lowest. This Article Gives An Overview of DBForms and ITS Concepts and Features, And Shows Some Code Examples. This article briefly introduces DBFORMS and its concept and characteristics, and give some sample code.
Introduction introduction
DbForms is a Java-based Rapid Application Development (RAD) environment which enables developers to build Web-based database applications in a very short time and with very little effort. DbForms applications are built in a conceptually very similar manner to RAD database-building tools like Microsoft Access (for Windows-based applications) or Sybase PowerSite (for Web-based applications). The basic principle of these RAD-Tools could be described as "placing database-aware components and action elements on templates (forms) which get executed At runtime. "DBForms is a Java-based fast application development environment that enables developers to create a web-based database application with the least workload in the shortest time. The DBForms application is very similar to developing tools such as Microsoft ACCESS (Based on Windows Applications) or Sybase PowerSite (web-based applications). The basic principle of these rapid development tools is to "put the Database-Aware Components and Action Elements in the template, execute in runtime." DbForms builds on top of Java Servlets 2.2 and Java Server Pages 1.1 technologies by Sun Microsystems. It makes extensive use of the JSP Tag Library extension introduced in the JSP 1.1 specification.DbForms is built on Sun Microsystems Inc.'s Java Servlets 2.2 and JSP1.1 Technical. It uses a JSP tag library to see the JSP1.1 documentation.
The project's homepage is located at http://www.dbforms.org and contains a complete user manual, several technical articles, source and binary distributions, online examples, a CVS, mailing lists, and lots of other information related to DbForms. This The home page of the project is http://www.dbforms.org, which contains a complete user manual, many technical articles, source code, and binary package, online example, a CVS, mailing list, and many other information about DBFORMS.
The MVC Paradigm Incorporated by DBFormsmvc Example, Combination by DBFORMS
DbForms implements the concepts of the Model-View-Controller (MVC) design pattern. (See Design Patterns: Elements of Reusable Object-Oriented Software, Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, Addison Wesley, October 1994.) You do not need to provide any controller-related code; just focus on defining the model and creating the JSP view components of the application (mainly using DbForms custom tags) .DbForms implemented model - view - controller design pattern spirit. (See "Design Mode: Foundation for object-oriented software" Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, Addison Wesley, October 1994) You don't have to write the controller related code, you can make energy Place the model definition and JSP view component establishment (mainly with a DBFORMS tab). The Following Discusses How Model, View and Controller Interact in dbforms. Discuss the template, indicating how the controller interacts in DBFORMS.
The model: Database Objects Described by Database Metadata Model: Database objects described with data
The use of DbForms is to perform operations on databases. The database tables accessed by a DbForms application must be declared in a XML configuration file (usually stored as WEB-INF / dbforms-config.xml), which is parsed and evaluated at Web- The use of Application Startup Time.dbForms is to complete the operation of the database. DBFORMS Applications can be accessed to describe in an XML profile (usually saved as Web-Inf / DBFORMS-Config.xml).
Listing 1. Defining the model1 definition model
table>
table> dbforms-config>
As shown in Listing 1, every table (or view) to be accessed by DbForms has to be declared inside of a
element. All relevant table fields need to be declared inside of a element nested within its respective
ELEMENT. It can be seen from Listing 1 that each data table (or view) that DBForms can access must be declared in the
element. All related table fields are also declared in the element between
elements.
There EXISTS A TOOL for Generating this XML Data AutomaticL. The Tool Reads DataBase Metadata of a Specified Database and Constructs A Configuration File, AS SHOWN IN LISTING 1. A tool that automatically generates this XML data. This tool reads the data element of a specific database, establishes a profile, such as the Listing 1.
The Controller: Parsing, Dispatching, And Executing Events Controller: Resolution, Dispatch, Execute Events
As pointed out above, you do not need to provide any Controller-related code when the Controller is a true infrastructural component. However, it's useful if you have an idea of what's going on inside the Controller. The following lines provide that information. As The controller is not required to write any controller-related code when the controller is an underlying component. However, it is also useful to understand the operating mechanism inside the controller.
The Controller includes several components: a component controller comprising: ControllerServlet: this servlet is the single point of entry for all incoming HTTP requests from clients ControllerServlet:. This is the entry point for all servlet from the client to the HTTP request.
EVENTENGINE: An Assistant to The ControllerServlet, IT Focuses on Filtering Http Requests for WebEvents and Instantiates Them. EventEngine: ControllerServlet Assistant, mainly filtered HTTP requests for WebEvents, and illustrated.
WebEvent Objects: all Objects derived from the abstract super-class WebEvent have the ability to initialize themselves by reading a given HTTP request These events get executed, either directly by the Controller or by the View WebEvent objects: all the abstract superclass WebEvent Delicious objects, they can read a given HTTP request to initialize yourself. These events are directly executed by the controller or view.
The Following Description of the Execution of a Typical User Action Should Give You a Typical User Action Should Give You A Better Picture Of What THE OTHER COMPONENTS: The following typical user action execution description, better depictting the controller? And how to do with other components:
1.User presses The Button "Delete Row" on his / her dbforms application. Users click the "Delete Row" button for the DBFORMS application.
2.Client Browser Submits Data Via http-post to the controller-servlet. The client browser submits the data to the controller-servlet via HTTP-POST.
3.The ControllerServlet delegates the incoming request to the EventEngine, which determines the main event (the user explicitly triggered the event by clicking a button) However, there may occur implicit events, too -. Ie, automatic updating of all changed input fields Of all data rows. ControllerServlet puts the request to EVENTENGINE, which determines the main EVENT (the user explicitly triggered Event by clicking the button). However, there will be implicit Events, for example, automatically update the changed input fields of all data Rows.
4.The EventEngine Component Parses That Request and Dermines The Kind of Action The User Wants To Be Executed. EventEngine component resolve request and determines the type of action to be performed. 5.It then creates the appropriate WebEvent (in our case, a DeleteEvent) and delegates the request Object to this newly-created WebEvent, which finalizes its own initialization. After that, the EventEngine returns the recently-created and -initialized event back to The ControllerServlet. Then, create the appropriate WebEvent (in our case, it is a deleteEvent), and assists the request object to this new WebEvent to complete your initialization. After that, EventEngine returned the original and initialized Event to the ControllerServlet.
6.The ControllerServlet tells the event to execute its built-in operation, if it is a DatabaseEvent. Other events (NavigationEvent, etc.) are delegated to the appropriate View component. If it is a DatabaseEvent, ControllerSErvlet make this event to perform its internal operating. Other Events (NavigationEvent, etc.) will be delegated to the appropriate view components.
7.The ControllerServlet invokes EventEngine again to check if there are additional (implicit) events to be executed. If so, the appropriated WebEvent Objects are created and executed in the same manner as the main event described above. ControllerServlet call again to check whether EventEngine An additional (implicit) events are executed. If there is, the appropriate WebEvent object in the same way as the main EVENT mentioned above will be established and executed.
8.The ControllerServlet determines the View component to which the request should be forwarded. If found, the ControllerServlet invokes the component and forwards the request. ControllerServlet which view the assembly to be transmitted to a given request. If it is found (this component), the controllerServlet calls the component and then transmits the request.
9.If the View component is a JSP page containing DbForms tags, those tags will search for navigation events to be executed, and will finally generate the response for the user. JSP pages if the view is a component containing DbForms tag, and the tag Will find the Navigation Events to be executed, then eventually will eventually be generated for the user. 10.The response is renedred by the user's web browser. This fair is expressed by the user's web browser.
The View: JSP Templates Provided by the Application Developer View: JSP Template for Application Developers
The View portion of a DbForms application is generally constructed using JSP technology. JSP files may contain static HTML elements, as well as dynamic elements containing Java code (definitions, statements, expressions). For more information about JSP, please see Sun's JSP page. The view part of the DBFORMS application is usually built using JSP technology. The JSP file will contain HTML elements, as well as dynamic Java code (definition, declaration, expression). For more information on JSP, browse Sun's JSP homepage.
With release 1.1 of the JSP API, a powerful facility called JSP tag libraries was added. With these custom tags, you can encapsulate even most sophisticated Java code into lightweight JSP tags. With the birth of JSP API 1.1 adds a powerful tool Cye JSP tag library. With these tags, you can package most of the complex Java code into a lightweight JSP tag.
DBFORMS Makes Use of the Great Potential of JSP Tag Libraries. It Contains An Extensive Custom Tags Library for Rendering and Manipulating Database Data.dbforms utilizes the huge potential of the JSP tag library. It contains an extended user-defined label library to display and operate database data.
The structure of a dbforms view A DBFORMS view structure
Figure 1 Gives A Conceptual Overview of the Main Components of a typepical dbforms view. Figure 1 shows an initial overview of the main components of a typical DBFORMS view.
Basic Concept of The Basic Concepts of Formsforms
Each DbForms-view JSP may have one or more root tags of the type form. Every form tag has to contain exactly one header tag, exactly one body tag, and exactly one footer tag, in exactly that order. Each Dbforms view all JSP There may be one or more types of tables single labels. Each form label must correctly contain a Header tag, a body tag, and a FOOTER tab, and have the correct order. Each of Those Tags May Contain Sub-Elements Like Data Fields, Input Fields, Action Buttons, And - of Course - Plain Html Text and JSP Code. Each tab may contain child elements, such as data fields, input fields, action buttons , Of course, there is a pure HTML text and JSP code.
header and footer tags are commonly used for titles of pages, labelling tables, placing action and navigation buttons, input fields to enter new data, etc. header and footer tags get evaluated only once.header and footer tags are usually heading for the page , Labeling table, placement action, and navigation buttons, input domains are used to enter new data, and so on. Header and Footer tags are only once.
The body tag is used for showing data rows coming from the database, and for providing the user with the functionality to edit that data. How many times the body tag and its sub-elements get rendered depends on the value of the maxRows attribute of the Form Element (AND of Course, on the number of datastes acts) .Body tab is a function of displaying data in the database and provides user editing data. How many times to display the Body tag and its sub-elements depends on the body element (of course, this depends on the number of data sets retrieved from the database) maxRows attribute value.
MaxRows = n - body gets executed n Times at maximum (with n in n) maxRows = N - body maximum execution N times (n
Nested Forms Nested Forms
Every Form May Contain One or More Nested Sub-Forms Inside ITS Body Element. The body of each form contains one or more nesting sub-table.
The "orders" form is nested within the body element of the "customer" form, as shown in Figure 2. The user will see one customer per page (because maxRows is set to "1") and all the orders (because maxRows = "*") The Customer Has Taken. The User May Navigate. The list of customs BY CLICKING The Navigation Buttons. The "Order" form is nestled in the "Customer" form, shown in Figure 2. Each page will see a customer (because maxRows is set to "1") and all customers all orders (because maxrows are set to "*"). Users are viewed by clicking the navigation button in the customer list. OK, Let's See some code! Ok, let us see some sample code!
As stated before, JSP views are the only parts of a DbForms application a developer usually needs to put his / her hands on. DbForms provides an extensive custom tag library which makes this an easy task, so that it can be performed even by non- Programmers. As mentioned above, the JSP view is the only part of the developer's DBFORMS application. DBFORMS has an extended user-defined tag library that can be easily (handling JSP view), so even non-programmers can do.
As we will see later, much of this code can be generated automatically by tools included in DbForms. However, it is useful to understand the basics of DbForms views, even if much of the work can be done automatically. Later we will see, Many of the code can be generated by tools within DBFORMS. However, it is necessary to understand the basic elements of the DBFORMS view, even a lot of work can be automatically completed.
The following two sections will show a simple and a more advanced example of a DbForms view. Both examples can be thought as being parts of a little CRM application of a (virtual) agency. The following two chapters shows a simple view and a DbForms Complex example. These examples can be seen as part of a (imaginary) part of the simple customer resource management application.