Working with Page ModeLast Updated: 9/22/2008 | |
| Sections above here: Home » Development » Page Mode | |
|
Sections below here: Topics in this section: |
The most important thing to remember when working with PageMode, is that it is basically and add-on to other technologies such as WebBroker or WebSnap. Therefore, it is vital that you know and understand either of these technologies to successfully develop applications using PageMode. On the Atozed website there is a tutorial about WebBroker for beginners. WebBroker is a low-level interface. The problem is that it is often pitched as a high-level one. PageMode can be considered as "plugins" that sit on top of WebBroker (or WebSnap), which means that you are not actually building an IW application but more a WebBroker application where parts of it are generated using IW. Consider IW in PageMode as a "third-party" add-on to WebBroker. The first step is to create a new WebBroker application. In this case, an ISAPI DLL will be created. For more information on WebBroker, see the Delphi online help or tutorials on the Atozed website. Once the WebBroker application has been created, a new IW form will be added to the project. To do this, use the IntraWeb wizard page in the Object Repository. Depending on whether the application is going to be designed for PDA devices, PageForm 3.2 should be chosen as opposed to PageForm.
After you click on the Ok button a new IW form will be displayed. This form is very similar to the IW forms used in Application Mode, however it has some specific properties that are related to Page Mode. In particular there are three properties that are important:
What AutoProcess indicates is whether the parameters will be automatically read and matched to components on the form. This in most cases has to be set to True. Since this form represents a actual "HTML form", an important property of any HTML form is the Form Action. This property can be set using the FormAction. However, in most cases, the FormAction would be to call the underlying IWPageForm itself, therefore by setting the PostToSelf property to True, this will be taken care of and FormAction can be left blank. If on the other hand, the post has to be handled by a WebAction defined in the WebModule, PostToSelf would need to be set to False and FormAction would need to contain the appropriate action. In the case of this example (see PageForms in the Demo directory), PostToSelf is set to True and FormAction is left blank. The next step is to drop some controls on the form.
In this case, a IWLabel and IWURL are placed on the form. The next step is to create a second IW form. Again, using File -> New -> IntraWeb -> New Form a new Page Form is created. Before placing any code in either form, some previous steps are required. Note: Some units might not be included automatically in the new page form. If the compiler complaints about undeclared symbols, check if they aren't in this units first: IWApplication, IWTemplateProcessorHTML, IWLayoutMgr and/or IWHTMLControls. When using PageMode, the underlying technology takes care of displaying the forms. In Application Mode a form would be displayed using something like: TIWForm.Create(WebApplication).Show; In the case of PageMode this is a slightly different. To display the first form, define a WebAction in the WebModule as /main.
Set the Default value to True and define the PathInfo and Name (as displayed in the figure above). As with any normal WebBroker application, there are two ways to send a response back. One is using the property Producer and the other is by setting it in code. In this case, the same thing can be done to display the IW form. However, there are two previous steps required. The first is one-off per application and that is to use a IWModuleController. This is a component that automatically creates an IWServerController. All that needs to be done is to drop ONE of these components on the WebModule. ![]()
There are no additional properties or events that need to be assigned. Just placing one on the WebModule is sufficient. The next step required to display an IW form is to use a IWPageProducer component. ONE is required PER form (or assign it dynamically at runtime). This component has only one event which is the OnGetForm. This event returns the contents of the IW form to the broker. procedure TWebModule1.prodMainGetForm(ASender: TIWPageProducer; This is similar to what is used in Application Mode, except that here, instead of doing a Show, the result of creating the form is assigned to the VForm parameter. The next step is to assign the producer to the WebAction using the Object Inspector. Since there is a second form in this application, the same steps are performed for the second form. As can be seen from the event, the owner of the form is also passed in as a parameter (AWebApplication). A second WebAction needs to be defined to display the second form. This is again done in a similar manner to the first WebAction. Note: When adding a IWPageProducer and assigning the event in the WebModule, two units have to be added to the uses clause, IWApplication and IWPageForm (IWPageForm32). What is left is to display the second form from the first one using an IWURL. To do this, all that is needed is to call the WebAction that produces the second form. The URL can be assigned to the IWURL in the form's OnCreate event: procedure TformMain.IWPageFormCreate(Sender: TObject); The second form prompts for a name and displays a label. This is programmed exactly the same as in application mode. Therefore you can see that working with PageMode gives you the RAD flexibility of IW and allows you to work with existing technologies. Much of the way things are done coincides with Application Mode, apart from some minor differences that have been mentioned in this example. |
(C) 2002-2009 - Atozed Software Ltd. | |