TripleToe
06-15-2004, 01:39 PM
I'm trying to create a class which will basically be a panel that contains a listbox along with some buttons (to be added later). The list will be dynamically populated by a server-side datasource. I want to use this so that I can specify the dataset/datapath for the list of items when I declare the instance of the class.
Below, I've pasted what I have come up with based on the examples and input I've found in the forums. It does work but it feels very clumsey and I'm sure it is full of potential problems and inefficencies. Antrun, can you or anyone else look it over and tell me if there is a better way to refine this?
Thanks
<canvas bgcolor="0xeaeaea" width="800">
<!-- Data Set for loading list of subjects -->
<dataset name="subjectdataset" request="true" src="Subjects.xml" type="http"
querystring="action=all"/>
<!-- Data Set for loading list of teachers -->
<dataset name="teacherdataset" request="true" src="Teachers.xml" type="http"
querystring="action=all"/>
<!-- Generic list panel class -->
<class name="adminpanel" extends="view">
<!-- Title of the panel -->
<attribute name="paneltitle" value="null" type="string" />
<!-- DataPath for the list in the panel -->
<attribute name="listdatapath" value="null" type="string" />
<!-- Oninit method loads list with remote data from datapath passed as
an attribute in the instance tag -->
<method event="oninit">
this.mainview.itemlist.textlistitem.setDataPath(th is.listdatapath);
</method>
<!-- Text Banner at the top of the panel -->
<simplelayout axis="y" spacing="10" />
<statictext name="title" oninit="this.initText()" y="10" x="10">
<method name="initText">
this.setText(parent.getAttribute('paneltitle'));
</method>
</statictext>
<!-- List box -->
<view name="mainview">
<simplelayout axis="x" spacing="10" />
<list name="itemlist" shownitems="5" scrollable="true" width="300" height="75">
<textlistitem name="textlistitem" width="300" datapath="" text='$path{"name/text()"}'
value='$path{"@id"}' />
</list>
</view>
</class>
<!-- end of class definition -->
<!-- Instances of list panel displayed in tabs -->
<tabs id="system_administration_tabs" x="20" y="20">
<!-- Subjects Tab -->
<tabpane text="Subjects">
<adminpanel paneltitle="Subject List" listdatapath="subjectdataset:/subjects/subject"/>
</tabpane>
<!-- Teachers Tab -->
<tabpane text="Teachers">
<adminpanel paneltitle="Teacher List" listdatapath="teacherdataset:/teachers/teacher"/>
</tabpane>
</tabs>
</canvas>
Below, I've pasted what I have come up with based on the examples and input I've found in the forums. It does work but it feels very clumsey and I'm sure it is full of potential problems and inefficencies. Antrun, can you or anyone else look it over and tell me if there is a better way to refine this?
Thanks
<canvas bgcolor="0xeaeaea" width="800">
<!-- Data Set for loading list of subjects -->
<dataset name="subjectdataset" request="true" src="Subjects.xml" type="http"
querystring="action=all"/>
<!-- Data Set for loading list of teachers -->
<dataset name="teacherdataset" request="true" src="Teachers.xml" type="http"
querystring="action=all"/>
<!-- Generic list panel class -->
<class name="adminpanel" extends="view">
<!-- Title of the panel -->
<attribute name="paneltitle" value="null" type="string" />
<!-- DataPath for the list in the panel -->
<attribute name="listdatapath" value="null" type="string" />
<!-- Oninit method loads list with remote data from datapath passed as
an attribute in the instance tag -->
<method event="oninit">
this.mainview.itemlist.textlistitem.setDataPath(th is.listdatapath);
</method>
<!-- Text Banner at the top of the panel -->
<simplelayout axis="y" spacing="10" />
<statictext name="title" oninit="this.initText()" y="10" x="10">
<method name="initText">
this.setText(parent.getAttribute('paneltitle'));
</method>
</statictext>
<!-- List box -->
<view name="mainview">
<simplelayout axis="x" spacing="10" />
<list name="itemlist" shownitems="5" scrollable="true" width="300" height="75">
<textlistitem name="textlistitem" width="300" datapath="" text='$path{"name/text()"}'
value='$path{"@id"}' />
</list>
</view>
</class>
<!-- end of class definition -->
<!-- Instances of list panel displayed in tabs -->
<tabs id="system_administration_tabs" x="20" y="20">
<!-- Subjects Tab -->
<tabpane text="Subjects">
<adminpanel paneltitle="Subject List" listdatapath="subjectdataset:/subjects/subject"/>
</tabpane>
<!-- Teachers Tab -->
<tabpane text="Teachers">
<adminpanel paneltitle="Teacher List" listdatapath="teacherdataset:/teachers/teacher"/>
</tabpane>
</tabs>
</canvas>