PDA

View Full Version : HELP with LzDelegate


pydyp
06-24-2007, 04:57 AM
Suppose:

<canvas debug="true">
<dataset name="myDataset" src="..." type="http" querytype="POST" request="false"/>
<method name="Case1">
Debug.write('Case1');
</method>
<method name="Case2">
Debug.write('Case1');
</method>
<button text="Case1">
<handler name="onclick">
...
myDataset.doRequest();
</handler>
</button>
<button text="Case2">
<handler name="onclick">
...
myDataset.doRequest();
</handler>
</button>
</canvas>

I would like, before doing the request, to choose the ondata method of the dataset.
Ex:
when I click on the button1 -> doRequest -> ondata: method Case1
when I click on the button2 -> doRequest -> ondata: method Case2.

I know it's possible to do that with LzDelegate, but I dont understand how.

Could someone show me the code to write.

Thank you.
Sorry for my bad english

jug
06-24-2007, 08:19 AM
Hi,

With delagates :


<canvas debug="true">
<dataset name="myDataset" src="..." type="http" querytype="POST" request="false"/>

<handler name="oninit">
this.del1 = new LzDelegate(this,'Case1',myDataset,'ondata');
this.del2 = new LzDelegate(this,'Case2',myDataset,'ondata');
this.del1.disable();
this.del2.disable();
</handler>

<method name="Case1">
Debug.write('Case1');
this.del1.disable();
</method>

<method name="Case2">
Debug.write('Case1');
this.del2.disable();
</method>

<button text="Case1">
<handler name="onclick">
canvas.del1.enable();
myDataset.doRequest();
</handler>
</button>

<button text="Case2">
<handler name="onclick">
canvas.del2.enable();
myDataset.doRequest();
</handler>
</canvas>



Or, without :

<canvas debug="true">
<dataset name="myDataset" src="..." type="http" querytype="POST" request="false"/>

<attribute name="onDataMethod" value="none"/>
<handler name="ondata" reference="myDataset">
var func = canvas[canvas.onDataMethod];
if ( func ) func();
</handler>

<method name="Case1">
Debug.write('Case1');
</method>

<method name="Case2">
Debug.write('Case1');
</method>

<button text="Case1">
<handler name="onclick">
canvas.onDataMethod = 'Case1';
myDataset.doRequest();
</handler>
</button>

<button text="Case2">
<handler name="onclick">
canvas.onDataMethod = 'Case2';
myDataset.doRequest();
</handler>
</button>

</canvas>


I don't know which one is the best... SO I put both of them ;)

Bye

pydyp
06-24-2007, 11:33 PM
Thank you very much.
That will help me a lot.

Pierre-Yves