Version: SmartClient Version: v9.0p_2013-09-14/PowerEdition Deployment (built 2013-09-14)
Browser: FireFox 23.0.1
I am having some problems in understanding what is accessible in dynamically loaded screens using Canvas.getByLocalId() and within the actual Javascript. I read in this post (http://forums.smartclient.com/showpost.php?p=108862&postcount=5) that what I am doing is possible, and I have achieved my goal, but I'm either not doing it right or it is not going to be as robust as I would like in the real world.
In a test application I am using RPCManager.loadScreen() to load a screen that contains a simple text entry field and a button. I would like to populate the text field with a value when the button is pressed.
Using the debugger I can determine the ID that is assigned to the text field. If I use that ID in my click handler, all works well.
Alternatively, if I pass in ALL_GLOBALS in the call to loadScreen() I can access the text field using the ID that I provided. Both these situations make sense to me.
However, what I'd really like to do is continue having loadScreen() replace my globals IDs yet somehow still be able to reference them by the actual ID contained in the screen definition. I thought getByLocalId() may be the key, but there are two problems with this:
1) getByLocalId() works great until I try to get a FormItem within a DynamicForm. It will pull other nested components without issue (e.g. Tabs within TabSets within HLayouts), but can't seem to return a FormItem within a DynamicForm. Perhaps this is because of the nature of FormItems and the manner in which they are created (i.e. by passing a descriptor to the DynamicForm)...?
2) Even if that worked, I don't think it would help me in the Javascript which has to rely on the actual ID that ends up being assigned to the component in the DOM. Have I understood that correctly?
Here's my screen definition:
and my code to load it is very basic:
The call to getByLocalId() returns null, and the line with the comment "Problem line" generates the following warning:
[ERROR] [sizing] - 14:23:02.671:MUP9:WARN:Log:ReferenceError: testItem0 is not defined
Since this behavior largely makes sense to me, am I simply expecting too much or is there a way for me to continue taking advantage of the global Id substitution behavior in the framework to prevent clashes, yet be able to easily reference my individual fields using the local IDs provided in the screen definitions?
Thanks in advance for your time.
Regards,
Gary O'Donnell
Browser: FireFox 23.0.1
I am having some problems in understanding what is accessible in dynamically loaded screens using Canvas.getByLocalId() and within the actual Javascript. I read in this post (http://forums.smartclient.com/showpost.php?p=108862&postcount=5) that what I am doing is possible, and I have achieved my goal, but I'm either not doing it right or it is not going to be as robust as I would like in the real world.
In a test application I am using RPCManager.loadScreen() to load a screen that contains a simple text entry field and a button. I would like to populate the text field with a value when the button is pressed.
Using the debugger I can determine the ID that is assigned to the text field. If I use that ID in my click handler, all works well.
Alternatively, if I pass in ALL_GLOBALS in the call to loadScreen() I can access the text field using the ID that I provided. Both these situations make sense to me.
However, what I'd really like to do is continue having loadScreen() replace my globals IDs yet somehow still be able to reference them by the actual ID contained in the screen definition. I thought getByLocalId() may be the key, but there are two problems with this:
1) getByLocalId() works great until I try to get a FormItem within a DynamicForm. It will pull other nested components without issue (e.g. Tabs within TabSets within HLayouts), but can't seem to return a FormItem within a DynamicForm. Perhaps this is because of the nature of FormItems and the manner in which they are created (i.e. by passing a descriptor to the DynamicForm)...?
2) Even if that worked, I don't think it would help me in the Javascript which has to rely on the actual ID that ends up being assigned to the component in the DOM. Have I understood that correctly?
Here's my screen definition:
Code:
<DynamicForm ID="testForm" width="100%" height="100%" autoDraw="false">
<items>
<FormItem name="textItem0" ID="textItem0" title="Test Field" constructor="TextItem"/>
<FormItem ID="buttonItem0" name="buttonItem0" constructor="ButtonItem">
<title>Populate Test Field</title>
<click><![CDATA[
isc_TextItem_0.setValue("Here is a value");
textItem0.setValue("Here is another value"); //Problem line
]]></click>
</FormItem>
</items>
</DynamicForm>Code:
RPCManager.loadScreen("tabbedScreen", new LoadScreenCallback() {
@Override
public void execute() {
getScreen().getByLocalId("textItem0");
}
}, new String[] { });[ERROR] [sizing] - 14:23:02.671:MUP9:WARN:Log:ReferenceError: testItem0 is not defined
Since this behavior largely makes sense to me, am I simply expecting too much or is there a way for me to continue taking advantage of the global Id substitution behavior in the framework to prevent clashes, yet be able to easily reference my individual fields using the local IDs provided in the screen definitions?
Thanks in advance for your time.
Regards,
Gary O'Donnell