WEB programming with intraweb

zhaozj2021-02-17  58

WEB programming with intraweb

"Delphi from the entry to the master" Chapter 21

Overview

Since Delphi2, Chad Z. Hower has been working hard to create a Delphi architecture that simplifies web program development, this simplified core idea is to make the development web program as simple and visualized like developing a normal window program. Some programmers understand dynamic HTML, JavaScript, Cascading Style Sheets, and the latest Internet technology; other programmers want to create a web program as creating VCLs and CLX applications.

Intraweb is to have since the need for the second developer's demand, her function is powerful, even professional web programmers can benefit from it. In the case of Chad, intRAWEB is used to develop web programs instead of being used to create websites. In addition, intRAWeb components can be used for unique applications or WebBroker and WebSnap applications.

In this chapter, I cannot detail every detail of intraweb. After installation, there are more than 50 components distributed in Delphi, and it is too big. I plan to explain the basic content, you can choose from the items of your hand or some of those items.

Tip: There is an intraweb PDF version manual in the Delphi7 CD. If you can't find it, you can download it on Atozed Software. About intraweb's technical support, you can refer to Borland's newsgroup.

Introduction Intraweb

Intraweb is a component library from ATOZED SOFTWARE. There is a corresponding version of Intraweb in the Professional Edition and Enterprise Edition of Delphi7. Professional Edition intraweB can only be used for page mode, and this chapter will be mentioned later. Although Delphi7 is the integrated development environment of Borland's first included the component set, IntraweB has been developed for several years, which has received quite good evaluation and support, including many third-party component developers.

prompt:

Although you cannot get the core source code (need to purchase), the intraweb architecture is fully open. And all the source code of all components can be obtained. Although Intraweb is part of the Delphi standard installation, it is equally applicable to Kylix. As long as you write, the intraweb program can fully implement cross-platform.

Note: In addition to Delphi and Kylix, intRAweb also has C Builder and Java. The .NET version is under development, it will be released along with Delphi for .NET (Delphi 8).

If you have genuine Delphi7, you can receive a major upgrade information and can be upgraded to the intraweb5.1 enterprise version, including upgrade documents and technical support. (The current version is 7.19 - translator)

From the website to the web program

As mentioned earlier, Intraweb's thinking is to build a web program instead of a website. When you use WebBroker and WebSnap, you are thinking with Web Pages and Page Products, while your work is tightly tightened with the HTML level webmaster. When using intraweb, you think that components, properties, and events are like visible development in Delphi.

For example, create a new intraWeb application, select File ® New ® Other, move to the IntrawEB page in the New Project dialog box, then select Stand Alone Application. In the next dialog (this dialog is Delphi instead of intRAWEB) You can choose an existing folder or enter a new folder (the system will be created automatically, the reason why it mentioned here, Because the dialog is not very clear). The final program contains a project file and two different units (I will talk about it later). Now let's create a routine (called IWSIMpleApp in the book source code), steps below:

1. Move to the main form of the program, select a button from the IW Standard page in the component board, and add a text editing box and a list box to the form. Note It is not a VCL component in the STANDARD page in the component board, but the corresponding intraweB component: iWbutton, iWedit, and IWListbox.

2, adjust their properties like this:

Object IWButton1: TiwButton

CAPTION = 'add item'

end

Object iWedit1: Tiwedit

TEXT = 'FOUR'

end

Object IWListBox1: Tiwlistbox

Items.strings =

'One'

'TWO'

'Three')

end

3. Double-click the button component to write the onclick event, the code is as follows:

Procedure TFormMain.iwbutton1click (Sender: TOBJECT);

Begin

Iwlistbox1.items.add (iWedit1.text);

END;

As shown in Figure 21.1, the web program (the final version of the figure shown in the figure) can add text to the list box, create it just these steps. When you run the program, you need to pay attention to you each time you click the button, the browser sends a new request to the program, which will drive the Delphi event handle to generate a new HTML page based on the new-based component. .

When you execute the program, you can't see the browser output, but an intraweb controller window (see Figure 21.2). A Stand-Alone Intraweb application is an HTTP server that will be described in detail in the next part. The window you see is to call the IWRun function that is created by defraweb applications for each Stand-Alone Intraweb application. You can select a browser in this debug window and run the program by it, or copy the URL to the clipboard, and paste it into your browser. The program uses a random port by default, which is different each time, so the URLs are different each time. You can change this behavior by setting the port port attribute by selecting the Server Designer (a bit like data module). In this example I use 8080 (a normal HTTP port), of course, other values ​​can also be.

The code of the intraweb program is mainly on the server, but Intraweb can also generate JavaScript to control some of the characteristics of the program, so special code can be performed on the client. You can implement it using special client components or write some special JavaScript code. As a comparison, the two buttons in the following routines IWSIMpleApp implement displays a message box through different ways.

IWBUTTON2 in the two buttons uses the Delphi code to display a message box using the server-side event.

Procedure TFormMain.iWButton2Click (Sender: TOBJECT);

VAR

NITEM: Integer;

Begin

NITEM: = IWListBox1.itemindex;

IF NITEM> = 0 THEN

WebApplication.showMessage (iwlistbox1.items [nitem])

Else

WebApplication.showMessage ('no item seed ";

END;

The second (iWbutton3) in these two buttons uses JavaScript, which is to implement the JavaScript event handle in the Delphi program by correctly set the JavaScript event handle in the property editor of the button's Scriptevents attribute.

INTRAWEB event script editor

After the death

See it, create an intRAWEB application and create a form-based Delphi application: Place the component on the form and processes their events. Of course, the effect is different, after all, this program is running in the browser. In order to let you understand how it works, we briefly look at this simple program. This will help you understand the effect of setting component properties and use component programming.

This is a browser-based program, so there is no HTML code that is sent to the browser to better understand its working mechanism. Open the IWSIMpleApp program source code page, will find a three parts. The first part is similar to the following style list:

.Iwedit1css {position: absolute; left: 40; Top: 40; z-index: 100;

FONT-STYLE: Normal; Font-size: 10pt; Text-Decoration: none;

Intraweb use styles not only determine the appearance of each component, such as fonts and colors, and can determine the location of the component, the default mode is positioned. Each style is affected by many attributes of components. If you have a style sheet knowledge, you can simply test it; if you are not familiar with the style sheet, then believe in intraweb, it will paint the components on the web page.

The Second Block Consists of JavaScript Scripting. The Main Script Block Contains Initialization Code and The Code of Client-Side Event Handlers for the Components, Like The Following:

The second block contains a description of JavaScript. The main script block contains the client event processing code for the initialization code and components, for example:

Function IWBUTTON1_ONCLICK (ASENDER) {

Return SubmitClickConfirm ('iWbutton1', '', true, '');

}

The scripting section of the page has also references to other files required by the browser and made available by IntraWeb Some of these files are generic; others are tied to the specific browser:. IntraWeb detects the browser being used and returns different JavaScript code and base JavaScript files. Scripts also involve other files generated by Intraweb required by some browsers. These files are somewhat universal, and some are bundled to specific browsers: intRAWEB can detect the browser used to return different JavaScript code and basic JavaScript files.

Note: Because all browsers can identify JavaScript, Intrawe only supports some browsers. Supported browsers have the latest version of Microsoft Internet Explorer, Netscape Navigator, and Mozilla for open source code (I use). Since Opera supports JavaScript more limited, if you are identified by default, intraWeb will issue an error message (depending on the Controller's SupportBrowSers attribute). Opera can be used with free Arcana components, which is officially supported in the IW 5.1. Remember the browser may fake identity: For example, Opera often recognizes IE. To make the site are not limited by the browser, set up more browsers, but may result in run errors and contradictions.

The third part HTML is the definition page structure. Inside the Body tag is a FORM tag (the same line) with the action to be executed:

Action = "/ exec / 3 / DC323E01B09C83224E57E240" Method = "post">

The Form tag is attached to the specified user interface component, such as buttons, and edit boxes:

ID = "iWedit1" Class = "iWedit1css">

OnClick = "Return IWButton1_onclick (this);"

ID = "iwbutton1" class = "iwTton1css">

The form also hides the intraweB component for transmitting information before and after. However, the URL is the most important way information in Intraweb. URL in the program is similar below:

http://127.0.0.1:8080/exec/2/dc323e01b09c83224e57e240

The first part is the IP address and the STAND-Alone Intraweb application port (which will be different from the different architecture), and the exec command is the number of cumulative requests, followed by the session ID. We will discuss session later. But now we can say that intraweb uses the URL token instead of cookies to ignore the browser settings to make the application available. If you like, you can use the cooks instead of the URL tag by setting the Controller's TrackMode property. Intraweb architecture

Before demonstrating how other intraweb components in Delphi7, let's discuss the key to Intraweb: Different development modes for web development, namely appmode and pagemode. The former can develop into a separate running executable, or also developed into ISAPI DLL, and even apache modules. AppMode can truly show the excellent features of intRAWEB. PageMode is an intraweb sheet of WebBroker or WebSNAP program that develops any programs except the executable, such as ISAPI, Apache Module, CGI, etc. IntrawEB provides three different but have a cross-based architecture based on both modes:

Standalone Mode provides a Web Server like the first routine. This is quite convenient for debugging (you can run directly in the development environment and set breakpoints). The program developed by Standalone Mode can run in the intranets and allow users to work offline on their own computer. If the parameter -Install runs the Stand-Alone program, the program will work in the form of service and do not display the dialog interface. Standalone Mode provides a way to develop AppMode programs that use intraweb itself as a web server.

Application Mode can develop a business web service to create an Apache Module or an IIS Dynamic Link Library. Application Mode has all intraweB full features including session-oriented management, and is preferred to develop web programs that can be upgraded via Web. Accurately, Application Mode can be developed to become a Stand-Alone program, an ISAPI dynamic link library, or Apache Modules.

Page Mode provides a way to integrate intraweb pages and WebBroker and WebSNAP applications. Page Mode is able to inject intraWeb features to existing programs or other technologically-based dynamic interactions, providing better interactions. Page Mode is the only choice for using intraweb technology in the CGI program, but Page Mode does not have session management features, while the Stand-Alone Intraweb program with this feature does not support Page Mode.

The example behind this chapter is mainly used to pursue simple and debugging. But it will also involve Page Mode.

转载请注明原文地址:https://www.9cbs.com/read-29827.html

New Post(0)