Is it possible to build stand alone widgets as opposed to full blown applications in GWT ? For example, I could use a create a slider widget as a jquery plugin and use it to add interactivity to my existing HTML page (which may be a JSF or JSF etc. generatd HTML) along side some other jquery based widgets from third parties on the same page ? Is this possible with GWT ?
Is it possible to build stand alone widgets as opposed to full blown applications
Share
Yes you can, and some of standard widgets have allready implemented static methods for attaching them without use of Rootpanel (so you can do “DOM programming”), for example look at HTML Widget. It has static method wrap for that purpose:
so in your code you can use it for attaching widget to existing DOM elements:
you can make similar static method in your widget:
but crucial is to call widgets protected method onAttach before attaching to dom – it subscribes the widget to global dom event broadcaster, and call RootPanel.detachOnWindowClose on your widget to prevent memory leaks.