How to Debug in Openlaszlo
All who used openlaszlo knows that its very difficult to debug each statements. The one way is to put alert statements. But we have to create different alert object, that too statically, so as to find what is happening or whats the current value. This is practical only in case of small applications. But in case of big applications, this will not be practical. So please try the below example. Here all the lines we wanted will be displayed one after the other. Thus we can check different scenarios.
<window x="${parent.width - 400}" width="400" height="200" name="Ajith" visible="true" id="DebugWindow" oninit="bringToFront()" resizable="true">
<edittext name="Debugger" id="debuggertext" multiline="true" width="${parent.width-20}" height="${parent.height-65}" text="--Start of Debug Statements--" y="20">
<handler name="oninit">
this.field['fakeScroll'] = this.field['scroll'];
var del = new LzDelegate(this, "doScroll");
del.register(this.field, "onfakeScroll");
</handler>
<handler name="onscroll" reference="field">
if (field.scroll != field.fakeScroll) {
field.setAttribute(' fakeScroll', (field.scroll - 1) * -1);
}
</handler>
<method name="doScroll" args="arg">
field.setScroll((-1 * field.fakeScroll) + 1);
</method>
<scrollbar scrolltarget="parent.field" scrollattr="fakeScroll" scrollmax="${parent.field. maxscroll+parent.height-1}" stepsize="1" name="scroller" align="right"/>
</edittext>
<method name="write" args="p">
var today_date = new Date();
var today_datef = today_date.getHours() + ":"+ today_date.getMinutes() + ":" + today_date.getSeconds()+ ":" + today_date.getMilliseconds() + "ms";
this.Debugger.setAttribute(' text', this.Debugger['text'] + "\n" + today_datef +" "+p);
this.Debugger.setSelection(0,t his.Debugger['text'].length);
return;
</method>
<button>clear
<handler name="onclick">
debuggertext.setAttribute(" text","");
</handler>
</button>
</window>
And just use the below statement to print your message :
DebugWindow.write(" your message ");
The debugger will also give the time at which each statement will execute. This will be useful in case of performance checking.
Hope you guys will enjoy debugging using the above code. Please do give your valuable suggestions
Subscribe to:
Comments (Atom)





