PDA

View Full Version : ExtJs output from a XML file?!



neonexus
7 Nov 2008, 8:29 PM
Yes, you read the title correctly.

The best way to describe this project (Currently codenamed "Coyote", which spawned from the acronym CYOT, which stood for Create Your Own Tag), is to say that Coyote is a PHP-based system, designed to take XML as input, and output data given to it by tag definitions. Tag definitions are PHP functions tied to tags.

In other words, it reads the XML, and runs a function for each tag.

What does this have to do with ExtJs you ask? Think of it this way, I write an XML file, and Coyote does all of the dirty work of creating Ext components. Well, perhaps the best way is to see it in action. I'll have a flow-chart of the logic eventually.

I forewarn you, there is a lot going on in both the XML file, and the output. I did comment a portion of the XML file. However, the output is a little rough to read (for a couple of reasons). Also, these are live files, meaning they can and will change from time to time. If you see any errors, just reload, I'm probably toying with the files. I apologize about that in advance.

Basically, I created this XML file:

You can find it here (http://neonexus.freehostia.com/coyote/index)

Which gets piped through Coyote. Coyote then outputs a resulting document:

Which you can find here (http://neonexus.freehostia.com/)

I can't post the PHP code that drives this system right now, because, for one thing, it's not finished yet. (Edit: However, if you would like to see the class that I built and everything that's related to ExtJs, let me know, I would love to get your opinion.) I am also not sure of what direction I'll be allowed to take this in (either leave it open-source, or charge for it). So, until that time, this is what I can show you.

Please let me know what you think of it, won't you?! :D

NeoNexus DeMortis

P.S. Shout out to the Ext Gui Builder (http://extjs.com/forum/showthread.php?t=14702). I love that tool. That thing is bad a**!

steve.neill
7 Nov 2008, 9:20 PM
Have been working on the same idea using a client side JS renderer. Takes XML and converts to Ext.

Here's a sample of the XML.


<?xml version="1.0" encoding="UTF-8"?>
<ui xmlns:my="http://www.xxxxxxx.com/XMLSchema">
<item autoScroll="true" closable="true" cls="a-class-name" constrain="true" height="500" maximizable="true" modal="false" resizable="true" width="700" xtype="window">
<listeners>
<render my:handler="MyApp.Path.To.handlerFunction"/>
</listeners>
<tbar>
<item enableToggle="true" id="a-dom-id">
<text><![CDATA[Some text...]]></text>
<listeners>
<click my:handler="MyApp.Path.To.handlerFunction"/>
</listeners>
</item>
<item xtype="tbfill"/>
<item xtype="tbseparator"/>
<item icon="../../image/something.gif" my:helpId="xxxxxxxx">
<text><![CDATA[Text]]></text>
<listeners>
<click my:handler="MyApp.Something.help"/>
</listeners>
</item>
</tbar>
<item ctCls="some-class" id="another-dom-id" my:faultTemplate="MyApp:fault" my:model="MyApp:anEventHandler" my:template="MyApp:aTemplate" region="center"/>
</item>
</ui>

The nice thing about defining UI as XML is that you can run XSLT's over it to create different output for admin vs user roles, for example.

All the JS is on-demand loaded, which means that the base JS footprint remains constant no matter how large the app gets. As the user interacts with the app, js snippets get loaded.

We've been using this approach for about 6 months now and it works very well.

neonexus
7 Nov 2008, 9:41 PM
Interesting. There's only a few minor differences in our two systems that I can see, aside from the obvious.

First, my system isn't strict. What I mean is, you don't have to have any XML definitions (`<?xml version="1.0" encoding="UTF-8"?>`), or the content type sent from the browser.

Second, the logic is way different with our parsers. Because of the way my system is built, and the direction I want to go with this, my system is designed to be a little more like XUL than it is XML.

I say that because of your use of the <item> tag, and my use of it. Your version is open to all xtype's. With mine, an <item> is a wrapper for other elements. As well your <text> and mine (which isn't in place in the example). What's up with the CDATA tags? Are those required or are you just a very strict standards type of guy? I'm just curious.

I'm intrigued by the server loaded components. I haven't been able to get that working just yet, because of the overall structure of Coyote. Coyote was never originally intended to be an API for Ext. It was intended to run PHP instructions based on a XML file. This little EXT project has consumed roughly 8 months of my free time to develop. It's no where near being what I would call complete, but it is really coming along. I hope to have it completed by next summer.

evant
8 Nov 2008, 12:11 AM
Out of interest, a guy I used to work with created a tag library for ColdFusion, you might want to have a look at it,, just for kicks:

http://www.madfellas.com/blog/index.cfm/2008/10/27/ColdExt-Beta-3-Lots-of-Ext-JS-goodness

neonexus
8 Nov 2008, 2:38 PM
Evant,

That's pretty neat as well. I wish I knew more about cold fusion, but from everything described, it sounds like he built his framework in just about that same manner I did, making it easy for the developer to add or modify tags as need be. I'll have to look into this more.