Web Application Opener - WebSnap (2)

zhaozj2021-02-08  206

Web Application Opener - WebSnap!

Chapter 2, the first WebSNAP program

2-1, get a step

I talked about Many aura, this chapter, I started to write our first WebSnap Application, first let us open new items dialog, after switching to the WebSnap page, you will see the following picture:

Delphi 6 provides three WebSnap Wizard to add the speed of our open process, please select WebSnap Application to build a new WebSnap Application Project.

From the on the left picture, we can see the Server Type this option. For the convenience, you will choose WebAppDebuger and enter a coclassname. Let me see the selection of the second section, I can see that two modules with Page Module and Data Module can choose, this is the Application Module that I have discussed in the previous section. In this example, our Application Module must be able to output a web page, so please select Page Module, which makes Delphi produces an Application Page Module, which is our home page. At the same time, you can also see a Components to press New. After you do her, you will open the right window, you can let us choose the components in Module in this window. This allows me to explain the meaning of these components:

Application Adapter This component is encapsulated Application Information, such as Title Information, etc. By Application Module is activated after each Client Request to reach, we can use TAPPLICAPTER DATA, ACTIONS characteristic value to put some whole domain information or an action operation.

End User Adapter This component is an Adapter that enables the user's management and authority control, which is responsible for the Login / Logout and Right Control of the Users. When Dispatcher is before the Client Request is paid to any Module, she must use her to make it to make it, whether the user is right to enter this module. Two this type of Adapter is provided in WebSNAP, one is another TENDUSERSESSIONADAPTER that will use the use of the use of the use of the use of TENDUSERSESSIONADAPTER in Session.

Page Dispatcher This component is responsible for solving the Page Request information in Client Request, and then finds the correct Page Module to guide to the correct Page Module. Adapter Dispatcher Adapter Dispatcher is responsible for solving the Action information in Client Request and finds the Module and Action Element in the Action to execute the Action. For example, the useer presses a bitton, and the Button is coming to an Action, which will be sent to Adapter Dispatcher.

Dispatch Actions This component is an element that is in WebBroker. In this article, I will not discuss this component, you can find the way to use in the book of Li.

Locate File Service This component provides file management function, such as the include file command in Script, or to take HTML Template File, which will be operated by this component.

Sessions Service is to provide the SESSION support. When your Application Module contains this component, it behaves that your Application Module has the ability to handle session.

User List Service stores the enabled function of the use of the user's material, and the TLoginApterForm element will use this component to confirm the user's information, then use the TendUseradapter component to complete the entire login.

In this example, we only need to hook three components: ApplicationAdapter, Page Dispatcher, and Adapter Dispatcher. After selecting OK, press the OK to return to the left side of the window, please select Page Options to press New, open this window:

The options in this window can make us set up the pageproducer component for the Page Module and the output of the network page, in this example, I selected TPAGEPRoducer to use JScript language. The next HTML section allows us to set whether to produce a new HTML File and HTML Template style, please select Standard Template in the Template part, which can make Delphi produce standard HTML Template File. In addition, in the Page section, we can set up the two characteristics values ​​for setting up Page. Name is the name of Module, and Title is displayed on the title string on the web page. There are two options below this section, and the public is used to control whether this page is public. When Published is disable, this page will be hidden, and the user cannot access the URL. This page is. In some things we can use some skills to output this Page to the navigator's browser, which is often used in the web page of the dynamic production or a guaranteed network page. Login Required is a representative to enter this page, the user needs to pass the Login action, if you launch the Application Module as the Page Module that you need to enter before login, the user must first go to your website before entering your website. In this example, we can use the preset value (login required = false). After the OK will go back to the initial window, I will see the Caching section, this option controls Module, it is necessary to save in the memory of the memory or release. If you use the server type is CGI, because the characteristics of the CGI schema is to release the memory remember after executing, this option is not meaningful. But if you use Isapi or Apache Share Module, you have to adjust this option, select Cache Instance Although you can speed up this Module, you will cost some memory, so please be careful This option is. All of us will always store the Application Module in cache because she is the most common Module, which is the pre-set option. After the first time OK press New, we finished the first step in this Websanp Application:

The ability to edit and preview HTML in the IDE environment of Delphi 6. When you switch to Home Unit, you should be able to see 5 TAB Page under Code Editor, please switch to .html page, you will see the following Screen: In addition to displaying and editing HTML in IDE, we can also see a Script program like ASP in the HTML file, which is one of the main features of Websnap, she allows us to use JScript or VBScript to write a webpage And the components provided by WebSNAP can be used inside. For example, Page and Application These two components are corresponding to TWEBPageInfo and TapplicationAdapter, which represents the operation of the two Script Object of Page and Application, which will be in the TWEBPAGEIFO and TAPPLICAPTER in the guide program. The figure below is WebSNAP generated HTML files. Process:

( Figure 4)

In Figure 4, we can see that when PageProducer will generate Wrapper Object after obtaining Script document, then the entire Script Document is interpreted by the ScriptAble-Object. But the focus is that the components are scriptable-object, those are not? On the skill In the eight types of Eight types mentioned in the first chapter, in addition to Adapter Control in the Adapter class, it is Scriptable Object. Its true pair in Script, is a Wrapper item produced by Scriptable-Object, and she will transfer the Script to her exercise to the true item:

( Figure 5)

In Figure 5, you can happen, TADAPTERWrapper (I am actually TWEBAPLICAPPER, she relates to tadapterwrapper) Pack the TapplicationAdapter component, and TadapterfieldWrapper packs the tadapterfield component. The speech is explained by application.today.value. When we get an Application.today this command, Application's Wrapper item calls TapplicationAdapter to get Today this Tadapterfield and build a TadapterfieldWrapper, pass the Tadapterfield item, and then return to script engine. The Script Engine can be taken by tadapterfield.value values ​​by TadapterfieldWrapper.Value, which is the operational manner of Scriptable-Object. Let me return to the way, to this, I have finished a simple web page, you can start the WebAppDebuger after you press the program, and then open IE / Netscape to view our web page. Start WebAppDebuger's detailed steps can be found in my previous article, successful words, you will see the following screen in IE / Netscape: In the Delphi IDE, we can also set an external program of editing web pages, such as FrontPage or It is a professional web editorial program such as Dreamwaver, which is very convenient. To have this function, we must adjust some settings in the open environment. Please open the Tools-Enviroment Options and select the Internet page, you can see two files in the face:

HTML and XML, please select the HTML and press EDIT to press New:

If you have installed FrontPage on your computer or Dreamwaver, you should be able to see them in the Edit Action list. Please select a web page editor after pressing OK to go back to IDE, if you have the Internet Toolbar to display the Internet Toolbar on the IDE, you can cut the .html page, click External Edit to start the network page editor. If you don't have anything, please select the Internet to display Internet Toolbar on Toolbar.

Internet Toolbar

On my computer, the page editing program is Ultradev, so I pressing the picture of the External Edit after the new button: Next is the work of the web page, the IDE of Delphi 6 is really very convenient? If the web page edited People are not your own words, you can copy UHOME.html to her, and then put it back in your project after design.

2-1, cow knife small test, simple adptfield

Now let me return to Delphi IDE, now there is a question, if I want to display this day today, what should I do? It's very simple! We can use Tadapterfield with JScript to finish this work. Please switch to Home Module, you can send it to the Data value in the TapplicationAdapter component, double press her, will open the next picture:

We can add components of the Adapterfield class in this Field Designer window, please click on the designer surface:

In this option, we can add Adapterfield to TapplicationAdapter, please select the Add All Fields option, which will add a TapplicationTitleField component to the TapplicationAdapter component. After completing, please click Right to select the New Component order:

Please choose a new Adapterfield component, then set the characteristics of this Adapterfield component again:

In this approach, our purpose is to use this Adapterfield to get the day of the day in Script. Therefore, we have to write a date on this AdapterField, please cut to the events page, write the online eventValue event:

Procedure thome.adapttodaygetValue (Sender: Tobject; var value: variant); begin value: = DATETOSTR (date);

After completing, we have to write the script scheme of the value, please cut .html page in the Application.Title to join the following Script program:

This day is <% = Application.today.Value%>

After the compilation is completed, you should be able to see this picture:

Very simple? Taking this effect, I have to write an ASP Object first, and then use the ASP to call this object. In the process, it is necessary to use two tools, but also get the rules of COM complex and unbelievable, after WebSnap, this cut is changed. We can get the advantages of Serverside-Script, and you can use the familiar components and Delphi to set up a web page, which increases the output of the program. In this example, you will be very sorry for our new Adapterfield to use the way to use the TITLE. It seems that the use of Title seems to be much simpler. This is due to the Wrapper Object of ApplicationAdapter, which has passed the value of Title to the value of the Title, which takes the form of the Wrapper Object, and I will discuss this part in the INSIDE WebSnap. 2-3, coupons, Adapterfield and Adapteraction

The purpose of the Adapterfield component is to process information. There is also a component of the same level in WebSNAP: AdapterAction, this adapter is used to implement a move. At the next, I should use Adapteractions. I have to set a simple computer, and the purpose is just the addition of the value to the entered. Go back to the IDE to add a Page Module to the propose, please use Internet Toolbar or NEW ITEMS Dialog.

In this page module, choose AdapterPageProducer, she allows us to set up the Visual Page Designer to set the Visual Page Designer to set up the Visual Page Designer.

Then I added an Adapter component to save Adapterfield and Adaptection:

Press our double by DATA characteristic value in Adapter components, add three Adapterfield: FirstValue, SecondValue, Result

FigST and Second These two AdapterField are the materials used to store the use of users. Result is used to display the results. Next, I need a certain button to do, and it is sure to say that it is an adaptection because I need to press the Identip. Remember? Adapteraction is used to implement action, please double-press the ActionS feature value in Adapter Add an adaptection:

The character value of the Action is then set.

At that, we also define a variable to save the results, so as to display the results of the calculations to the utility. In this case, we must need to make a concept, on the surface, Adapterfield is used to store information, but the container for storage materials (that is, variables) is to be available. Therefore, please add this parameter declaration in the Class section of the program: Private FRESULTVALUE: STRING

Before using this variable, we need to initialize her, led the next calculation result is incorrect, remember the first section of the web module explanation? The best initialization event is not oncreate, is onactivate! Please change in this event. Initially become empty strings, then add an OnGetValue event to AdaptResult this Adapterfield, add the following section code:

Value: = FRESULTVALUE;

At the end, we add the scheduled calculation units in the Adapteraction.onexecute event:

procedure TCalc.AdaptCalcExecute (Sender: TObject; Params: TStrings); var v1, v2: Integer; begin v1: = AdaptFirstValue.ActionValue.Values ​​[0]; v2: = AdaptSecondValue.ActionValue.Values ​​[0]; FResultValue: = IntToStr (V1 V2); END;

You can feel that in this incident, I use Adapterfield.ActionValue this characteristic value rather than Value. This is because WebSNAP will save the value entered by the user in ActionValue. If this example is explained: the user enters two values ​​and pressing Calc pressing the browser will put these information POST. HTTPPOST METHOD) In ​​the WebSNAP program, the WebSNAP will then solve the two values ​​entered by the user to the AdapterField.ActionValue feature, then remove the Action information and execute the action. Why do you want to be numb? Oh! You won't want to combine ActionValue with Value, because this is the value that you want to identify and the value of the user

Continue our procedures, now we have to turn the web page of the planning platform. Please press AdapterPageProducer to open the Visual Page Designer window:

Press the Rat right button on AdapterPageProducer Add an AdapterForm component:

Then press the right button on Adapterform to select New ComponetNs to add an AdapterFieldGroup component.

The Adapter characteristic value of AdapterfieldGroup is then set to Adapter1. By do not want the utility to modify the value of the result, because she is calculated by us, I have to change the Result's control to the plain text display. Please press the right button on adapterfieldgroup1, select the Add All Fields option:

Pick up the FLDRESULT ITEM and set her view module for VMDisplay.

If you work, you will see that RESULT's explicit mode has become a pure text.

Next, we must also provide an confident press that allows the utilityrs to select the action. Press the right button on Adapterform and select AdapterCommandGroup to add new components.

Then set her DISPLAYCOMPONENT characteristic to adapterfieldgruop1.

Then press the right button on AdapterCommandGroup1 to add an AdapteractionButton.

Place her PageName and ActionName characteristic value.

After you have finished, you can see the picture below:

In order to stop this, we have finished this network page of this computer, and then please compile her and open the IE to browse our webpages:

This chapter

In this chapter, we discussed WEBSNAP's basic design and adapterfield and adapteraction components in the WEBSNAP program, which also learned the TPAGEPRODUCER and TADAPTERPAGEPRODUCER components.

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

New Post(0)