hart
7 Mar 2008, 5:13 PM
Hi,
I'm new to Ext JS and I must say I'm very impressed with the look and feel of the output. I stumbled across Ext JS while looking for a solution to a fairly simple problem that is seemingly more difficult than I imagine it should be :)
I've spent the evening browsing and searching the forums and reading a lot of the tutorials and examples on the site without much success - so I thought I'd throw it out there.
I want to create a simple UI to add, edit, remove XML objects based on an XML Schema. Ie: every time I decide to add another element to the structure, I don't want to have to re-write the UI.
I have a fairly simple XML document structure:
<?xml version="1.0"?>
<config>
<name>example</name>
<domain>example.domain</domain>
<server>
<fqdn>mail.domain</fqdn>
<ip>192.168.1.1</ip>
<type>mail</type>
</server>
<server>
<fqdn>web.domain</fqdn>
<ip>192.168.1.2</ip>
<type>web</type>
</server>
<database>
<fqdn>db1.domain</fqdn>
<ip>192.168.1.3</ip>
</database>
</config>
With a corresponding XML Schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:element name="config">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="name" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="domain" type="xs:string"/>
<xs:element minOccurs="2" maxOccurs="unbounded" name="server">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="fqdn" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="ip" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="mail"/>
<xs:enumeration value="web"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" name="database">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="fqdn" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="ip" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I looked at length at the XML-FORM example but couldn't figure out how to dynamically create the form itself, from either the xml or the schema (preference, based on type information).
Additionally, even if I got that far, I am struggling with how to represent the form part of the UI - specifically when editing/adding a new entry, the form needs to be dynamically modifiable pre-submission to allow the "addition" of extra array elements such as "server"s and "database"s (see XML structure).
Doesn't seem that complicated in my head, but when I stare at the code, my mind goes blank :(
Ideas/comments/suggestions welcome.
Cheers
Leigh
I'm new to Ext JS and I must say I'm very impressed with the look and feel of the output. I stumbled across Ext JS while looking for a solution to a fairly simple problem that is seemingly more difficult than I imagine it should be :)
I've spent the evening browsing and searching the forums and reading a lot of the tutorials and examples on the site without much success - so I thought I'd throw it out there.
I want to create a simple UI to add, edit, remove XML objects based on an XML Schema. Ie: every time I decide to add another element to the structure, I don't want to have to re-write the UI.
I have a fairly simple XML document structure:
<?xml version="1.0"?>
<config>
<name>example</name>
<domain>example.domain</domain>
<server>
<fqdn>mail.domain</fqdn>
<ip>192.168.1.1</ip>
<type>mail</type>
</server>
<server>
<fqdn>web.domain</fqdn>
<ip>192.168.1.2</ip>
<type>web</type>
</server>
<database>
<fqdn>db1.domain</fqdn>
<ip>192.168.1.3</ip>
</database>
</config>
With a corresponding XML Schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:element name="config">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="name" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="domain" type="xs:string"/>
<xs:element minOccurs="2" maxOccurs="unbounded" name="server">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="fqdn" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="ip" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="mail"/>
<xs:enumeration value="web"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" name="database">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="fqdn" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="ip" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I looked at length at the XML-FORM example but couldn't figure out how to dynamically create the form itself, from either the xml or the schema (preference, based on type information).
Additionally, even if I got that far, I am struggling with how to represent the form part of the UI - specifically when editing/adding a new entry, the form needs to be dynamically modifiable pre-submission to allow the "addition" of extra array elements such as "server"s and "database"s (see XML structure).
Doesn't seem that complicated in my head, but when I stare at the code, my mind goes blank :(
Ideas/comments/suggestions welcome.
Cheers
Leigh