Hi Laszlo community,
I'm writing this email in order to get help understanding an issue
with initstage. I've read that setting initstage of a view to defer
would disable the calling of of the init handler, that would only be
called if the completeInstantiation() method is used.
So I'm trying to use this in order to make sure the remotecalls
invocation in an init handler are only done, after the in loading of
the javarpc.
Unfortunately the init handler is called anyway and so I'm getting an
error with invoking remote calls that aren't yet available:
Equipment's init handler called
ERROR: getAvailableModels could not invoke; is remote service loaded?
Created component equipment
__LZloaderReturnData data= «Object#1| {..., stubinfo: [object Object],
stub: [object Object]}»
... loadmc= «LoadObj#2| undefined (loading)»
...responseheaders= undefined
«Object#1| {..., stubinfo: [object Object], stub: [object Object]}»
Configuration loaded
Below is the code I'm using:
<canvas width="100%" height="100%" bgcolor="0xc92222" debug="true">
<!--<include href="resources/resources.lzx" /> -->
<handler name="onconstruct">
canvas.configuration.load();
</handler>
<security>
<allow>
<pattern>^configuration\.Configuration</pattern>
</allow>
</security>
<javarpc name="configuration" scope="session"
remoteclassname="configuration.Configuration"
createargs="['/home/daniel/workspace/BoundmoreGUI/database/configuration.xml']">
<handler name="onload">
Debug.write("Configuration loaded");
canvas.equipment.completeInstantiation();
</handler>
<handler name="ondata" args="res">
Debug.write('(types ondata) response is:', res);
</handler>
<handler name="onerror" args="errmsg">
Debug.write('(types onerror) error:', errmsg);
</handler>
<remotecall name="getAvailableModels"
funcname="getAvailableModelsOL" />
<remotecall name="selectModel" funcname="selectModelOL" />
<remotecall name="getInstanceDate" funcname="getComponentsDate"
/>
</javarpc>
<node name="equipment" initstage="defer">
<handler name="oninit">
Debug.write("Equipment's init handler called");
var dataset = new LzDataset(this);
dataset.setName("available_models");
canvas.configuration.getAvailableModels.setAttribute('dataobject',
this.available_models);
canvas.configuration.getAvailableModels.invoke(['equipment']);
Debug.write("Created component " + this.name);
</handler>
</node>
</canvas>