A GWT components library - how to organize for Uibinder use?

92 views
Skip to first unread message

cbruno...@gmail.com

unread,
Nov 29, 2024, 2:20:57 PM11/29/24
to GWT Users
Hello,

Im creating a component library for GWT and I want to be able to use the components in UI binder. However, when implementing my components, each component gets its own package, containing styles, and package private classes needed to build the component. 

However, to use in Uibinder, I need to do something like <m:button.Button text="Click" />

where m points to the package with my components.

Whats is bugging me is the extra "button" in the declaration. Is there anyway to flatten this aside from creating another package with objects simply extending the implementation ?

Thanks

Jens

unread,
Nov 30, 2024, 6:49:08 PM11/30/24
to GWT Users
UiBinder is XML and you have to import the package as namespace in order to use the components. Personally I would not create another package with classes extending the implementation because both classes would be public and both can be used in UiBinder then. That is likely confusing. I would put all components in the same package. Package private classes supporting a component could have the component name as prefix so they form a group in your IDE through sorting.

-- J.

cbruno...@gmail.com

unread,
Nov 30, 2024, 11:59:36 PM11/30/24
to GWT Users
Thanks Jens. This is my first Java project where I am sole architect. I ended up doing what you recommended, although I moved the ui.xml and css files into a sub-package to keep the top level package as clutter free as possible. 

Craig Mitchell

unread,
Dec 2, 2024, 5:04:18 AM12/2/24
to GWT Users
Not saying this is the correct way, but I just have my simple common widgets in the one package, and specialised widgets in their own package.  Ie:

<ui:UiBinder
  xmlns:ui="urn:ui:com.google.gwt.uibinder"
  xmlns:g="urn:import:com.google.gwt.user.client.ui"
  xmlns:w="urn:import:mypackage.widgets"
  xmlns:s="urn:import:
mypackage.widgets.special">

<w:Button ui:field="myButton" />
<w:Link ui:field="myLink" />
<s:SpecialWidget ui:field="mySpecialWidget" />
Reply all
Reply to author
Forward
0 new messages