Including other XML files
To avoid large gui descriptions, gui4j supports a mechanism to include other xml files. For each inclusion, an alias must be defined
which is the prefix for all identifiers defined in the included file. Hence, gui4j builds hierarchical names when including other files.
Content of file basic.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE View SYSTEM "view.dtd">
<View>
<edit guiId="myedit" value="getValue" setValue="setValue(?value)"/>
</View>
Content of file main.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE View SYSTEM "view.dtd">
<View>
<Include url="basic.xml" alias="incA"/>
<Include url="basic.xml" alias="incB"/>
...
<tableLayout guiId="myedits" rows="p" cols="p,p">
<placeTl row="0" col="0" id="incA/myedit"/>
<placeTl row="0" col="1" id="incB/myedit"/>
</tableLayout>
</View>
As can be seen in this example, the include mechanism allows also to duplicate definitions. Without this duplication technique, one component identifier
must not be used twice.
Controller delegation
The base reference for all method calls in a xml file is the current controller. When including other xml files, another call base might be specified
with the controller attribute:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE View SYSTEM "view.dtd">
<View>
<Include url="basic.xml" alias="incA" controller="getControllerA"/>
<Include url="basic.xml" alias="incB" controller="getControllerB"/>
...
<tableLayout guiId="myedits" rows="p" cols="p,p">
<placeTl row="0" col="0" id="incA/myedit"/>
<placeTl row="0" col="1" id="incB/myedit"/>
</tableLayout>
</View>
In that example, the file basic.xml is included where the definitions with alias incA uses the controller returned by the method
getControllerA, and the definitions with alias incB uses the controller returned by getControllerB.
This concept is usually used, to divide complex graphical user interfaces into sub forms where each sub form is handled by a separate controller
or to reuse similar definitions/layouts.
Parameter instatiation
The parameter concept allows to refer to named components without a definition. When this file is included, these parameters must be
instantiated using the Arg tag inside the Include element.
Content of comp.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE View SYSTEM "view.dtd">
<View>
<Param id="compA"/>
<Param id="compB"/>
...
<tableLayout guiId="main" rows="p" cols="p,p">
<placeTl row="0" col="0" id="compA"/>
<placeTl row="0" col="1" id="compB"/>
</tableLayout>
</View>
Content of use.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE View SYSTEM "view.dtd">
<View>
<Include url="comp.xml" alias="comp">
<Arg param="compA" id="idA"/>
<Arg param="compB" id="idB"/>
</Include>
...
<edit guiId="idA" value="getValueA" setValue="setValueA(?value)"/>
<edit guiId="idB" value="getValueB" setValue="setValueB(?value)"/>
...
<tableLayout guiId="someId" rows="..." cols="...">
<placeTl row="0" col="0" id="comp/main"/>
...
</tableLayout>
</View>