|
|
Monday, July 5. 2004PHP meets ASP.NET WebControlsTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Think you know what's coming
Have played a little with direct support for ASP.NET markup in WACT (http://wact.sf.net) - examples online here: http://wact.sourceforge.net/examples/show.php?group=tags/dotnet/ The key point for PHP is performance. My view is handling objects of the type of complexity ASP.NET has, at runtime (i.e. every time a PHP script is requested) is going to be slow. By making clear divide between compile time and run time though, it's possible to implement similar functionality in PHP. Right now I believe WACT (of course I'm biased) is the optimal design for achieving this. Part two of "Declaring UIs with XML" in the Internation PHP mag looks at WACT and "Extended HTML'. My understanding is that WACT is similar to .NET in that it only parses the actual HTML file on the first execution. After that it stored a (serialized?) compiled version.
Does patForms do something similar or is it parsed every page load? We are planning to implement some kind of HTML template parser for CEP modules as well (http://sf.net/projects/cep). I have even successfully used WACT running as a CEP module. I think they would have to be compiled in some way for performance sake. patForms parses the file once and then writes two files:
1. An HTML file that contains placeholders for all elements (format of the placeholder can be set, so you my use it with any templating engine) 2. A serialized array with all elements and their attributes. So loading a form from a template is quite fast, although I never benchmarked it. The bottleneck in most of my applications still is patTemplate as it does not compile, yet. Stephan "My understanding is that WACT is similar to .NET in that it only parses the actual HTML file on the first execution. After that it stored a (serialized?) compiled version."
That's correct - the template engine is a PHP code generator. Each WACT template tag has (basically) two classes - a compile time class, responsible for code generation and a lightweight runtime class which you interact with. The means the peformance overhead for a tags "static behaviour" - stuff that only changes when the template itself changes - it restricted to the compile stage while "dynamic behaviour" is available at runtime. It's probably easiest to see this with the form:inputautocomplete tag. The compile time class, InputAutoCompleteTag generates both PHP and Javascript; http://wact.sourceforge.net/api/WACT_TAG/InputAutoCompleteTag.html At runtime you work with the much simpler InputAutoCompleteComponent; http://wact.sourceforge.net/api/WACT_COMPONENT/InputAutoCompleteComponent.html This has only one method you need to think about - setAutoCompleteList() - you pass this an indexed array of words to use for auto completing the input text field. An example of a "WACT users" script using the inputautocomplete tag is here; http://wact.sourceforge.net/examples/showsource/showsource.php?file=tags/form/inputautocomplete.php Somewhat over complicated (it's also doing validation) but you can see interaction with the tag in the AddressFormView::prepare() method; // Builds an indexed array of countries importVarFile('/select/countrylist.vars'); // Get the runtime component from the template $Country =& $this->Form->getChild('Country'); $Country->setAutoCompleteList(array_keys($list)); The template for the form is here; http://wact.sourceforge.net/examples/showsource/showsource.php?file=tags/form/templates/source/inputautocomplete.html All the Javascript generation is taken care of for you. The working example is online here: http://wact.sourceforge.net/examples/tags/form/inputautocomplete.php Try typing "Ge" and it should complete with "Germany" (depending on your browser). Apologies for over advertising. Get excited about WACT and somehow it's very hard to explain, although very easy to use. I will never get over forgetting to mention parForms. I had planned it, but somehow the first time in the talk I thought about Stephan was when I talked about PEAR's XML packages ... sorry ...
The author does not allow comments to this entry
|
php_network_getaddresses: getaddrinfo failed: Name or service not knownphp_network_getaddresses: getaddrinfo failed: Name or service not known |