10.07.2015 Views

Tutorial section in PDF - Custom Training Courses - Coreservlets.com

Tutorial section in PDF - Custom Training Courses - Coreservlets.com

Tutorial section in PDF - Custom Training Courses - Coreservlets.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

@UiFactory• Create non-private method with widget type asthe return type• Place @UiFactory <strong>in</strong> front of that method– E.g., @UiFactory MyWidget make(Str<strong>in</strong>g name){return new MyWidget(…);}– The method’s argument names be<strong>com</strong>e attributes to the widget<strong>in</strong>side the UI XML as if they were part of a constructor• Import widget library package as usual• Inside .ui.xml, use widget as usual– Can still use attributes with setters besides the constructor args• Usually, this approach works well when us<strong>in</strong>g a3 rd party widget library23Example Preparation• Use FancyOptionalTextBox fromGwt<strong>Custom</strong>Widgets2 project– Exported Gwt<strong>Custom</strong>Widgets2 Java JAR <strong>in</strong>to theGwtUiB<strong>in</strong>der1/war/WEB-INF/lib directory• S<strong>in</strong>ce this JAR has no server-side <strong>com</strong>ponents, it can really beplaced anywhere outside the war directory so it doesn’t getdeployed with the web app but only <strong>com</strong>piled <strong>in</strong>to JavaScript– Adjusted GwtUiB<strong>in</strong>der1 project properties (Libraries) to<strong>in</strong>clude the gwtcustomwidgets2.jar• Inserted this l<strong>in</strong>e <strong>in</strong>to GwtUiB<strong>in</strong>der1.gwt.xml:24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!