Zapatec and Delphi
Zp includes very steady support for Ajax call-backs and it has some solutions to interchange data with the server: in XML, Json and HTML document formats.
Zp incorporates a complete UI of very flexible components (Widgets),
which have complete Ajax support and permit to construct very impressive
The aim is to use the Zapatec in a Delphi/IntraWeb application, with the intention to utilize ZP Ajax techniques to communicate the two worlds. We can call it ZADI.
I suppose that the reader is familiar with IntraWeb, and that he knows the Ajax technique purpose. If the reader is very knowledgeable about Zapatec then it is wonderful, but if you don’t know about the Zp then maybe it is better if you start looking for in http://www.zapatec.com to learn a little bit about the library.
Trick 1) Include the Zapatec library in files directory.
Really it is a very "obvious" step and it is the first one, which is also very simple way to use Ajax in your IW program.
You can do easily the first ZADI version by creating a normal Delphi IW application, coping the Zapatec Ajax library to the /files directory in the new application.
When executing the application, you access to it at following direction:
http://127.0.0.1:8080 (for example)
Now, you can try with
Then you will see the demo page, and it is served by the IW application. So really this is the very first Zapatec Ajax Delphi IntraWeb application.
Really there is not so much new in this step for an experimented programmer,
but it is important to bear in mind that in /files directory, you can
Trick 2) Communication between Zapatec and IntraWeb
We must find the way to communicate the Zp components with the IntraWeb server.
I have explained How connect IntraWeb and Ajax, with details from the IntraWeb server perspective. But now, I will talk about the Zapatec possibilities and problems.
We can do it in a “traditional” way of IntraWeb (a POST command), which refreshes the entire windows, or by an Ajax call which interchanges partial information.
By the moment, we will see the ZpMenu, ZpGrid and ZpForms components. The objective is to create a complete set of components than to make easy the use of the Zapatec in a Delphi/IntraWeb application and simplify the job.
With zpMenu, we can illustrate the traditional way to communicate with the server.
zpMenu is an elegant component to create Menus in Web Pages.
Basically, it is build from a list of elements ( <UL> <LI> ) which convert in a pretty menu. You can personalice the menu in a lot of aspects, by choosing in the predefined themes and adding dynamic effects.
The way to communicate with the server can be in Ajax, both in order to obtain the data to construct the menu and to “inform” to the server the selected option .
But the easier (and probably more practical) is in “traditional” way, by sending the data menu included in the Web page, and doing each selection trigger a POST call to the server.
A zpMenu can be defined as following:
We can see then the link is like this:
It is a classical <a> HTML element which makes the reference to the SubmitClick function.
To make this function work, you must pass the following params:
The component name which processes the response, and the param ‘raiz=00E591F0’ which in our case is represented by the selected menu item.
Really, it is easy to use it on a Web Page, but we have a Delphi component to make it easier to be used in an IntraWeb application.
TGpZpMenu Generates a zpMenu, from the classic TmainMenu in our application. It includes some codes to render the HTML code.
In this component, we will see more “complex” aspects in the Zapatec library.
zpGrid generates a functional data table, with sorting, selection, editing and more…
If you use the ZpGrid component, you want to serve the data by the IW program connected to a database
I don’t try to explain all the ZpGrid functionality, but I must talk about how a ZipGrid is created on the page. You can use a code similar to the next paragraph.
sourceType: Indicates de type of data transport to obtain de data for the table. In the example “ xml/url” refer to data in XML format obtained in a URL direction set in source.
Here the great problem is:
An IntraWeb page communicates with the server by using POSTcommands in which some necessary information is included locate the component which process the answer.
But ZpGrid call to the URL which obtain the data by using GET commands (with no any additional information). Really, the XML support in other Widgets have the same problem, and this is not good for the IW application.
To solve the problem, we will use a second trick.
All the XML calls in the components, are handled by Zapatec.Transport.fetchXmlDoc function.
Let’s go to “intercept” this function, in order to include the missing params.
Don’t worry if you do not understand the line:
MakeCallIW is a function which generates the content to pass in the POSTcall.
I don’t explain how to construct the IW server calls, because you can read ajax4intraweb.htm which explain how to do it.
There is another consideration about how to create the correct XML answer in the IntraWeb app, and each Zp component has specifics params and rules, I will explain each one in next articles. Really it is not easy to talk about all the problems/issues, because for example its necesary to make each Ajax call after the other one ( here we can doubt about an IntraWeb limitation in handling simultanius POST commands ),
By the moment, we have Delphi IntraWeb components which support ZpMenu, ZpGrid and ZpForms. The objective is to create a complete set of components that make easy the use of the Zp components in a Delphi/IntraWeb application and simplify the job. We will publish the first demos ASAP.
Teléfono: 978-610539 - Fax: 978-610861 -Trav.Agustina Aragón 1,1e 44002 Teruel ( España ).webmaster
Copyright © 1997-2004 , [Multi-Informatica Teruel, S.L].La información contenida en este documento está sujeta a modificaciones sin previo aviso. Otros productos u organizaciones mencionadas aquí son marcas comerciales o marcas registradas propiedad de sus respectivas organizaciones o propietarios.