Dynamic XUL

Dynamic XUL dynamique is XUL description of XML component which use Freemarker directives ([#list, [#if) with square bracket syntax. The content of Wizard page can depends on Model of the XML component.

With XUL dynamic, you can display the list of field of JAVA class into a XUL Tree with checkbox.

After having selected class JAVA java.lang.Number (This window is opend when JAVA class Model has beed defined) :

XUL dynamic display a XUL Tree with the fields of the java.lang.Number class.

XML component

To write XUL dynamic, you must :

  • set dynamic="true" into the XML component. With dynamic="true", the model of XML component will be merge with the XUL content (to generate XUL according to model) before displaying the Wizard page.
    <?xml version="1.0" encoding="UTF-8"?>
    <component dynamic="true" >
      ...  
    </component>
  • define the model (xml or class) which must be merged with the XUL content with Freemarker.
  • write the XUL with Freemarker by using square bracket syntax. With this syntax, XML component is XML well formatted :
    [#list pojo.methods as m ]
    <treeitem checked="true" >
      <treerow   >
        <treecell label="${m.elementName}"  />
      </treerow>
    </treeitem>
    [/#list]           

Here the XML component qwhich display the XUL Treewhich contains fields of a JAVA class :

<?xml version="1.0" encoding="UTF-8"?>
<component dynamic="true" >
  <model>
    <!-- This component requires selection of XML File which is used into XUL Page (Input) /> 
         and into Template context (Output) -->
    <file type="class" key="pojo" useIntoInput="true" useIntoOutput="true" />
  </model>
  <input>
    <page title="Dynamic XUL component" >
      <description>After selecting a JAVA class, this XML component display list of fields 
                   of the Java class into a XUL Tree. 
                   XUL is describes with Freemarker directive [list ...]. </description>
      <box flex="1" id="" orient="vertical"
           xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">       
        <hbox height="100">
          <tree id="fields" checked="true" flex="1" >
            <treecols>
              <treecol label="Fields" flex="1"/>
            </treecols>
            <treechildren>
            
              <!-- DYNAMIC XUL -->
              [#list pojo.methods as m ]
              <treeitem checked="true" >
                <treerow   >
                  <treecell label="${m.elementName}"  />
                </treerow>
              </treeitem>
              [/#list]       
              
            </treechildren>
          </tree>
        </hbox>            
        <hbox>
          <label value="Output base dir:" />
          <textbox id="outputBaseDir" flex="1" />
          <button type="folder" target="outputBaseDir" label="Browse..." />
        </hbox>
        <hbox>
          <label value="Output file name:" />
          <textbox id="outputFileName" flex="1" />
        </hbox>       
        <hbox>
          <button type="preview" label="Preview..." />
        </hbox>      
      </box>                    
    </page>
  </input>
  <output>
    <file>
      <template uri="/ftl/Xml/XMLContextToJavaClass.ftl" />
    </file>
  </output>
</component>