0

I have a small issue with XWT, to put it simply, I have an foo.xwt file which has approximately the following structure:

<Composite 
    <Composite.Resources>
       <r:MyDataProvider key ="myInstance" name="myInstance" ObjectId="myInstanceObjectId"/>
    </Composite.Resources>

    <Composite>
       <w:SmartSpinner name="mySmartSpinner" .... />
    </Composite>
 </Composite>

In the foo.java class, I have the following method:

@PostConstruct
protected void init() {
    SmartSpinner mySpinner = (SmartSpinner) XWT.findElementByName(parent,"mySmartSpinner");
    MyDataProvider myDataProvider = (MyDataProvider ) XWT.findElementByName(parent,"myInstance")
}

The SmartSpinner is found, no problem. However, the MyClass instance returns null.

I can't find a serious documentation about XWT, and I basically clueless about how it work, what interface it gives etc .... I'm actually impressed that the guy previous me actually managed to create a working interface. So if you have any idea, it will be really appreciated

Milan
  • 1,547
  • 1
  • 24
  • 47
  • Might try fixing the single-quotes in XWT.findElementByName(parent, 'myInstance') – avojak Jul 11 '16 at 18:11
  • Also: "I can't find a serious documentation about XWT" Have you tried the official [XWT Documentation](https://wiki.eclipse.org/XWT_Documentation)? I see a "Hello World" example and a lot more which seem to give a nice introduction to XWT. – avojak Jul 11 '16 at 18:12
  • I fixed the '' issue thanks, however this was not in my code. Yes I know about the "hello world" documentation, but our product is far beyond what's in this doc. Also, I found a method "XWT.findDataProvider". Since MyDataProvider implement the interface IObjectDataProvider i tried to used it to obtain the DataProvider. So far the only thing I managed to get is something similar to a full access to all my class members - even privately inherited -, but still no data provider. – Milan Jul 11 '16 at 18:26

1 Answers1

0

A resource is not an element, so, try XWT.findResource(parent, "myInstance") instead.

erdal.karaca
  • 693
  • 1
  • 4
  • 20
  • Thank you, this method actually gave me a list of my IDataProviders However, I opted for a another solution based on static String updated from a dynamic dictionary which is already implemented and used accro the java application. My only issue with this is that the variable have to be public, but I found this to be better than an hard-coded string in the XWT. Even is this string is to be overriden, it may encourage people to start duplicating the XWT again, and i do not want this. Perfect solution would be to use private members and getter but I do not know if this is possible. – Milan Jul 14 '16 at 18:34