Web Application Opener - WebSnap!
Written by cotne64212001 / 9/28
Update
(This article uses Delphi 6.01 as Blue Ben, please update your Delphi to version 6.01!)
Chapter, preface
WebSnap is the latest Web Application for Delphi 6, and she is based on the previous version of WebBroker, and added a lot of functions lack in WebBroker InternetExpress framework. Although it is a strong, but from the perspective of the technical angle, the two have been renewed. In the WEBBROKER INTERNETEXPRESS framework, the biggest problem is that the power of support is too simple, such as Session, Pages Manager, Servier-Side Scipe, etc. Developing Web Application, which is the necessary, the ability to be in this architecture. It is necessary to rely on the support of the 3RD-Party component, or write such components from the order to full the need for the special case. The WebSnap racks have completed these functions and added a lot of new components. Borland strengthened WebBroker, plus the Multi-modules function used by the management network page. This function enabled us to make a simple and automatic manipulation of our work in processing Pages Manager. In addition to this, WebSnap used a lot of new and practical Design Patterns concepts on the framework. This decision allows WebSNAP to extend the extension of transverse or longitudinally, allowing the day to be transplanted with the expiration of the time. Borland also plans to put WebSnap's entire frame to Kylix after day, so that Delphi design will set up a Web application in both Windows and Linux platforms, which is a great voice for cross-platform demand. It is unpleasant in the beauty of the beauty, and the WebSnap accompanied by Delphi 6, and the document is too small. In the case of this pantastic stand, there is no way to make the auxiliary assistant, which makes it easy to use.
When delphi 6 shipments, only the model of WebSnap, which is indeed! These paradigm have quite standards, and many WebSNAP skills are applied appropriate, but unfortunately Too standard, it is easy to know that it is easy to know how it is, it is easy to generate bottlenecks when practical applications, and there is no explanation of files to be inquiry, so users can only rely on the defect paradigm or in NewsGroup Ask others, let's learn about the entire WebSNAP architecture and use skills, this is not only no efficiency and time! I hope this article is slightly reduced, because the WebSnap architecture is quite huge, I divide WebSnap into two articles. Article, one is an overview, the other is the application, the overview of the design concept and basic applications of WebSnap, the application will cover the advanced application and design WebSnap components, the old saying! I hope you can These two articles get the knowledge you want. The first chapter, the view of the WebSnap
WebSnap is a positive structure, which makes this frame to expand or migrate after the day, Borland uses a lot of near-generation Design Patterns to build her. The use of Patterns can make the extension of the entire system framework, which can be used to unfamiliar with the illegibility of Patterns, which also makes the problem of learning curve growth. These makers are often difficult to solve the flow of the entire WebSnap framework in the beginning, and it is easy to lose in the many components and the melin. But once you have to give this, you will be a beautiful side of this frame. In this chapter, I tried to make an overview of WebSnap, so that you have a basic understanding of the entire frame, the chapter of the rear is reused to guide you to make a step. This can be your first time to touch WebSnap, so I suggest that you read this chapter to read this chapter, you don't have to force it to solve all the things talked about this chapter. You don't need to stop staying in this chapter. After the day, I will return to this chapter to recover, which will be more relatively light.
1-1 WEBSNAP's eight major components
WebSnap consists of dozens of components and interface (interfaces), where the relationship between the components and interface is quite complex, in which chapter, we use the 17 elements you can see in Component Palette and Web Module as Based, divided into eight categories: Web Module PageProducer Dispatcher Adapters Sessions Valuelist Wrapper Services
1-2, Web Module
In a large component of WebSNAP, Web Module is located in the nucleus of the nucleus, and she plays the role of the container element in WebSNAP. You can place Web Components in Web Module or it's its non-visualty components, just like you use TDATAMODULE components to us. In fact, she is also in TDATAMODULE, just added a lot of functions set for the web. Web module in WebSnap is divided into two categories, which can be subsequently divided into two small classes in each class:
Application Module Page Module Data Module Generic Module Page Module Data Module
In a WebSNAP program, it is necessary to include an Application Module. In this web module, you must put a TWEBAPComponents component, this component is the center of WebSnap. All CLIENT Request (web page requirements or Action) will be distributed by her Global Components components. Application Module plays a CONTOL CENTER (control center) role in the player, anything to this program will be sent to Application Module first. WebSnap provides two different types of Application Module, because of the different special cases, you can select the Application PageModule that can output the available web page, which is not exported to the web page, just place the material or its non-visuality DataModule. When you choose to output the Application Module that outputs the web page, you must place a pageProducer component to this module, the role of this component is the ability to provide PageModule output web pages, usually we will use Application PageModule to be the first page of the website, but this is not Absolute, we can also use Application DataModule to set the default page feature value of the PageDispatch component to our home page, which will become the homepage. Application DataModule and Application Page Module functions are the same, and the difference is that the web module is the ability to output the network page. Application DataModule does not have the ability to output the web page, because she is just a component container with a Control Center. Generic Module and Application Module's functionality is the same, and the difference is only on the special power of Control Center. The following is the transportation flow map of Web Module: (Figure: 1)
In this process, there is a key to pay special attention, that is, when you choose Application Module is PageModule, assume that the requested web page is not specified in the Client Request message, and the PageDispatcher component is located in Application PageModule. The PageProducer component is returned to the client side after using her to output the web page. As discussed above, this movement will be affected by the DefaultPage characteristic value of the PageDispatcher component, you can use it to change the level of the home page by changing this characteristic value. From the process you can find that the role played by the Dispatcher component in WebSNAP is a message distributor. The role is to output the client request to the correct module, then output web pages via the output web capabilities provided by the PageProducer component in this module. Rear back the client. When the web page is included in the web page, WebSnap will call Active Script Engine to solve these Script code, produce the most final HTML Document, and then pass back from WebBroker to the Client side. To support Serviceside-script, the TPAGEProducer component in the INTERNETEXPRESS architecture has been enhanced as a component that can be handled Script, and you can set your schedule for your schedule to make the Script Engine type of Script Engine. WebSnap support JScript and VBScript two Script language, which should be supported after the day, should be supported more script engine (such as: PHP). In the entire framework of WebSNAP, the difference between the components is often determined on the Interface acting in the components, and the web module is not extrovive. The difference between Application Module and Generic Module is on the interface of IgetWebAppServices, and the Application Module tries to this interface, and this interface defines a function of removing the TWEBComponents component, so WebSNAP can remove the TwebAppComponets component via the letter in this interface. The Dispatcher class element or other Global Components is obtained via her. Generic Module does not make this mesh, this interface is the source of Control Center capabilities.
And the difference between the PageModule DataModule is that IPageResult, ISetWebContentOptions, IGetDefaultAction, IGetProducerComponent, IProducerEditorViewSupport five this interface, the interface is implemented IPageResult function element must provide an output page, when implemented WebSnap encountered when this interface element She will call the output function to obtain web content. The IgetDefaultAction is defined in a letter of removing the DEFAULTACTION object. The meaning of this item is often mixed to trigger the action of this action when this Page Module Activate is activated. The thing is not, she will only be troved in special circumstances, and this situation will be explained in the chapter below. The IGETPRODUCERCOMPONENT mesh is defined to get a function of the PageProducer component. Dispatcher needs to use this letter to get the pageProducer component in Web Module, and use her to output the web page. IProduceReditorViewSupport is the interface used by IDE. It is used to clarify Module to have those files, such as XML, Script, etc. (Simple saying is that you can see those files in IDE). ISETWEBCONTENTOTIONS interfacia only uses the HTML Template file in Web Module with an includepage command, and avoids the incomplete internal capacity of the incomplete Script schedule. Web Module provides several events to let us handle, these events are quite straightforward. Activate class events are triggered at Module activated or leaving, that is, at the Dispatcher Analysis Client Request, the Web Module name needs to be obtained, and then find the onActivate event when the corresponding web module is found, and the ONDEACTIVATE event is triggered when the Module is leaving. One thing must be annotation here, Activate / deActivate events are not equal to Create / Destroy events.
When the web is set to oncached mode, the Activate / Deactivate event may be triggered many times, and the Create / Destroy event will only trigger when Module is established or eliminated, then triggered Activate / Deactivate class event, DispatchPage class The event will be on the output of the web page after the Dispatcher activation Web Module. In practice, you should put the initialized program code in Activate event, but this has an exception, that is, when you provide an action in a Web Module Users execute, if the power to be turned, the activate event will not be triggered when executing the action after execution, because the module is already activated when executing Action is executed, that is, Activate has already It was performed. At this time, you must move the primary code code to the DispatchPage class, which will be triggered after each output network page. We can also guide web pages in the DispatchPage class event, which will be used when we don't want users to enter the page directly, but hopes that when we turn to the page via an action, we can apply this event. To handle, we will discuss Activate, DispatchPage, DefaultAction in the following sections. 1-3, PageProducer
In addition to the TPAGEPRoducer in the original internetExpress architecture, WebSnap also provides two new PageProducer for TXSLPAGEPRODUCER, TADAPTERPAGEPRODUCER. TadapterPageProducer is a more common PageProducer component that is more common in WebSnap. She allows us to set up the web page application program with the visualization network page, with the same time delay. These capabilities come from both IWebComponiteteditor and iProduceReditorViewSupport. IWebComponnedIitor can make TadapTerPageProducer filters the sub-component type, which is important because in WebSNAP is distinguished by the actual interface, so most of the WebSNAP components are inherited to Tcomponent, and they must depend The actual interface is to determine if it can be a sub-component of TadapTerPageProducer. IProduceReditorViewSupport is the same as the xxeditorViewSupport in Module, and the difference is Module to use her on the Code Editor, and TadapTerPageProducer is to use her on Visual Page Designer. There is a WebPageItems property in the TadapTerPageProducer component, which comes from the parent category TBASepageItemsProducer at TadapterPageProducer. This is the place where the tadapterpageproducer stored sub-components, the method of WebSNAP recognizes such components is to determine whether the component does IGETWEBComponentlist, and then obtains IWebComponentList, after the iWebComponentList, these sub-components are processed. In TadapTerPageProducer, three events are provided, and the onhtmltag event is used to tell a TAG, and then the designer is replaced with its content, and our usual uses her to change the network page of a certain section. The getContent event is before the TADAPTERPAGEPRODUCER output. OnHTMLTAG is only triggered when there is TAG (such as <#test>) in the HTML Template file, and the getContent event will be triggered before each output network page. The value of the value is the time than the time to trigger, which also represents the table. You cannot handle Server-Side Script in onhtmltag. Because Server-Side Script, the Server-Side Script has been completed and transferred to HTML file.
GetContent allows you to handle Server-Side Script, but this requires some skills, I will mention this type of skills in INSIDE Websnap. TXSLPAGEPRODUCER is to allow you to use XSL to handle the network page, which is wide from the knowledge of XSL part, so I left the associated use when I stayed when I stay. The Server-Side Script currently generated by the TADAPTERPAGEPRODUCER component cannot be forth. If you want to have more control over Serverside-script, you can choose to use TadapTerPageProducer to design your webpage, then copy HTML content to TPageProducer after completion Use TPAGEPRoducer instead of the original TadapTerPageProduCder to output a web page, which has a detailed way in the appendix of this article. 1-4, Dispatcher
From the figure, you should have a role that dispatcher playing in the WebSnap architecture. Two Dispatcher Components, TPAGEDISPATCHER, and TADAPTERDISPATCHER, and after TwebDispatcher, you have three DISPATCHER components in Delphi 6. TPAGEDISPATCHER is a component that distributes the web page. When the Client Request is a web page, TPAGEDISPATCHER is responsible for finding the page and transfers the controller to the page module. TadapterDispatcher is used to distribute an action request, for example, there is a button in your web page, this pressing a Action, so when the user presses this button, Tadapterdispatcher will find the web module where this Action component is located. The Action element is obtained to perform the action. Dispatcher also provides control of the user's rights, when tPageDispatcher finds the page of the Client side, she will first check the weight information of this page to determine whether the user is eliminating to obtain the page. Similarly, when tadapterdispatcher distribution Action, you will also check the execution of the Action component to set the same work, the sections of the rear, will introduce this part. The Dispatcher class element doesn't look much, and something is the main corner of the Pages Manager in WebSnap. If you have a line, you can do it without writing, and you have the function of Page Manager.
(Figure: 2) Above the above figure, we can clearly see the operation mode of the Dispatcher component. Here is something to pay later. When the Action is executed, it will call the TPAGEDISPATCHER component to turn to the destination web page. At this time, the RedirectOptions feature value in the Action component It is the key to deciding whether to perform the DefaultAction event in the destination page.
1-5, Adapters
Adapter is the case in WebSNAP, and the same time is also the most complex and unpredictable part. In the object guide design mode, Adapter is defined into a new item into a new item and uses her in another system to achieve the purpose of reuse. Adapter in WebSnap is four categories:
Adapter Container Adapter Items Adapter Control Container Adapter Control Items
Adapter Container is an Adapter container component that includes Adapter Items, such as TapplicationAdapter, TendusesSionAdapter, TDataSetadapter, etc. Adapter Items class features include Tadapterfield, Tadapteraction, TadapterDataSetfield, etc. These two types of Adapter belong to Scriptable-Object, which means that you can use them in Active Script to take them in Adapter, just like the use of ASP Object to use them in ASP. In addition to these two types of Adapter, Adapter Control Container and Adapter Control Items are auxiliary Adapter components. Your components you have visited by TadapTerPageProducer are this type, which is this type, and these Adapter's main purpose is support for visualization settings. Technical, you can use these Adapter to join Adapter Container and Adapter Items and produce HTML Form or Script. Such Adapter can be called Adapter Adapter, it is worth noting that Adapter Control Container and Adapter Control Items are not scriptable-object, and their existence is to let you use Visual Page Designer to design web pages, and dynamically generate Script With HTML code:
( image 3)
In the figure, we can see that the Adapter Control class components are used to output the ADAPTER class components to the components in HTML. For example, TadtPerForm uses Adapter Container to produce HTML FORM, TadapterEditColumn will use Adapter Items to produce TextBox or HTML Edit Control in CHECKBOX. There are many things that they do. Examples such as the production of Script, or have some HTML TABLE, or some of them should produce the CLIENT SIDE SCRIPT code. In Adapter Items, it is also divided into two categories, Tadapterfield and Tadapteraction. Tadapterfield is used to handle information, you can think of her as a variable that can be used in Script. Tadapteractions is used to handle Action, such as HyperLink, Button, etc. At the same time, the Adapter Control Items will also be divided into two categories. First, use to handle tadapterfield's TadapterEditcolumn, TadapterDisplayField and other components, and the other is to handle TadapteractionButton components for Tadaptection. Adapter plays a strong role in WebSnap, so that she is a must-have condition that she issued a WebSNAP program. In the back surface, I will make more adapter components more complete introduction. 1-6, sessions
The session function is a function of a web page that often uses the functions. For example, in a shopping network station, the purchase car function, or the ability to keep the user to log into the information, you need her to help. In the WEBBROKER INTERNETEXPRESS architecture, it is not supported by SESSION, and we often have to help 3RD-Party components or self-writing process. In WebSnap, Borland made up this gap, she provided TsessionServices to control the status of the session. When your Application Module contains a TsessionServices component, when Client Request is reached, WebSnap will establish a session item in WebContext, and you can use this item to use this item to handle SESSION information in any one Web Module. After processing the network page, WebSnap will transfer this session into cookies and pass back the client. This CLIEN is sent to Web Server when you look at this website next time. At this time, the WebSnap has been taken out by cookie. From this discussion, you can send it, the session function is to build on the cookie, and the session will follow the same time when closing the cookie when the Client's browser settings is closed, which is the same as the general web page. Current WebSNAP does not store session in the file, so you cannot use session in a non-DLL-type WebSNAP program, because the session stored in the memory is disappeared, so we can use WebSnap. The stored repository is retained session, and this technology will be discussed in the session. Using the session object in WebSnap is a very easy thing, but there are some special circumstances that you need to pay more, that is when the user opens two browsers, how should we use two different sessions or share one? This is a quite important topic in some webpages. In the session of the session, we will discuss these issues in an in-depth discussion. 1-7, Valuelist
The Valuelist class component is a role in WebSnap. For example, TWEBUserList is used to use the use of the TENDUSERADPATER component, or TDataSetValuelist is used for the TadapterDataSetfield component. It is also an Adapter, which also represents the original ADATper components in some cases. The Valuelist component is quite simple and easy to use, you can easily use her, this concept is Delphi 6 new features added to TStrings, simple saying is a name follows a value, such as: Site = www.borland.com.tw, Site is the name, the corresponding value is www.borland.com.tw. The sections of the rear, we will use her to achieve the functions commonly used in the multi-network station. 1-8, Wrapper
I didn't have to have seen this East West, and she made you can use Scriptable-Object, such as using Scriptable-Object, as described in Active Script, as the Script code code of the Script:
<% = VADAPTER1_BORLAND.DISPLAYTEXT%>
Vadapter1_borland is a tadapterfield component, can Tadapterfield can only be used in delphi? Didn't wrong! But this is not a single pure tadapterfield element, she is a TadapterfieldWrapper element. This Wrapper component contains a reference to a Tadapterfield component. When you use this Wrapper component, she will transfer you to the true tadapterfield element. This is also the secret of Scriptable-Object in WebSNAP. The Wrapper component on the Windows platform is actually a COM object. Before the PageProducer is processed by Active Script, she will establish a Wrapper component for all Scriptable-Object. After completion, Script Document Active Script Engine Processing, and Active Script Engine allow us to use COM objects in Script, so we can use these Wrapper components. When the Active Script Engine is completed, the last HTML Document will produce the last HTML Document, and the HTML is passed back to the client side by the WEBSNAP.
1-9, SERVICES
This type of component is usually a national feature, mainly a system feature in the auxiliary WebSNAP program. For example, the SessionService component is responsible for providing the SESSION support in the WebSNAP program. When you place this component to Application Module, you can Any part of the program uses the session object to save the information. The LocateFileService component is responsible for the file access function in the WebSNAP program. After you put a LocateFileService component to Application Module, all related file access movements will pass this component, so you can use her event to read the file or Other processing. Because these components are placed in Application Module, you can save her in any of the way in any Web Module in the program. This chapter
In this section, we made a significant discussion on WebSnap. You may not know what you discuss with this section, and you can even say blur! Don't be discouraged, this is normal! You will gradually understand it in the discussion below What is discussed here.