The replacement text from an OnHTMLTag event handler need not be the final HTML sequence you want to use in the HTTP response message. You may want to use several page producers, where the output from one page producer is the input for the next.
The simplest way is to chain the page producers together is to associate each page producer with a separate action item, where all action items have the same PathInfo and MethodType. The first action item sets the content of the Web response message from its content producer, but its OnAction event handler makes sure the message is not considered handled. The next action item uses the ContentFromString method of its associated producer to manipulate the content of the Web response message, and so on. Action items after the first one use an OnAction event handler such as the following:
procedure WebModule1.Action2Action(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); begin Response.Content := PageProducer2.ContentFromString(Response.Content); end;
void __fastcall WebModule1::Action2Action(TObject *Sender, TWebRequest *Request, TWebResponse *Response, bool &Handled) { Response->Content = PageProducer2->ContentFromString(Response->Content); }
For example, consider an application that returns calendar pages in response to request messages that specify the month and year of the desired page. Each calendar page contains a picture, followed by the name and year of the month between small images of the previous month and next months, followed by the actual calendar. The resulting image looks something like this:
The general form of the calendar is stored in a template file. It looks like this:
<HTML> <Head></HEAD> <BODY> <#MonthlyImage> <#TitleLine><#MainBody> </BODY> </HTML>
The OnHTMLTag event handler of the first page producer looks up the month and year from the request message. Using that information and the template file, it does the following:
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|