Hi all,
I am having trouble building a dynamic GUI that is dependent on
information form the server.
I am calling an RPC that returns an array of strings,this contains the
display names of the menu items i would like to place inside a
VLayout.
The problem is I cannot access a non-final variable inside the RPC
implementation.And if i change the VLayout variable to final,adding
widgets to it does not have the effect i'd like(it does not add the
items to the VLayout).
In other areas of my project i have achieved the same affect by just
adding the menu items to a pre-defined div-id that resides in my html
( by doing this RootPanel.get("my.div.id").add(item);) This works
nicely!But I cant do this again because i'm not adding these items to
a pre-defined tag, rather, i'm adding them to a VLayout.
Here is a snippet of my code trying to add items to a VLayout inside
an RPC:
***************************************************************************************************************************************************
final VLayout vLayout1 = new VLayout();
uiService.getDataList(new AsyncCallback<String[]>() {
@Override
public void onFailure(final Throwable caught) {
Window.alert("Could not connect to server,
please check your
connection.");
}
@Override
public void onSuccess(final String[] result) {
if (result == null)
Window.alert("No data in datalist");
else {
// Iterate through all the items in the
dataset list
for (int i = 0; i < result.length; i++)
{
// TODO loop through datasets
and create list
MenuItem item = new
MenuItem(result[i], "data");
vLayout1.addChild(item);
}
}
}
});
***************************************************************************************************************************************************
Does anyone have a suggestion or workaround?
I have tried populating an arrayList inside the RPC and then using the
arrayList's content to create the menu items and add them to the
VLayout but when that code executes the arrayList is empty.
It's probably because that code is executed before the RPC returns.
Would appreciate any suggestions!
Thank you in advance.
Regards
Fred
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.