GWT: How do I get a Button widget reference given a FormPanel? - gwt

I'm using GWT 2.4. I have a reference to a FormPanel, which contains a Button, with id="save." How do I get a reference to the Button widget given the form panel instance?
Note, that Button is not a direct descendant of formPanel, so "formPanel.getWidget()" will not automatically return a reference to the Button.
Thanks, -

You can use
formPanel.getWidget(),
if you're using com.google.gwt.user.client.ui.FormPanel. It will give you the reference to the widget you've added in the FormPanel.

Related

Reuse the tab of a component in another component except a widget in touch ui aem

I have a component /apps/myproject/component1.
In its dialog i have some widgets.Now I have another component /apps/myproject/component2 and its dialog want to use the same tab but a widget should be removed and one should be added in component2 touch UI dialog in AEM.
I tried to achieve it using
sling:resourceType :"granite/ui/components/foundation/include"
path:"/apps/myproject/component1"
on tab1.
But if i want to add and remove a widget, i am not able to do that.
Can anyone please help me?

in GWT, How to loop Gui Widget inside a panel?

Let say, I got a VerticalPanel that have some widgets (label, button, ...) that were added into it. How can i loop that VerticalPanel & access the widgets in it?
Well you can use iterator,As i explained in the question How get all widgets of certain type?.
Iterator<Widget> widgets= vpanel.iterator();
Point to remember:
This method only gives the widgets added to the panel.
You have to iterate over child panels also(if its contains).
Or otherwise pick #Manolo's answer from same thread,If you are using GWT third party library GQuery.

why GWT Cell widgets are fater?

I wanted to know how cell widgets are faster compared normal (old) GWT widgets?
I have gone through the gwt article
Developer's Guide - Cell Widgets
It says
A cell widget renders its user interface as an HTML string, using innerHTML instead of traditional DOM manipulation
Can anyone please explain the above? and How?
In a normal GWT Grid you have to add each Widget separately, which means the browser can not optimize this in any way. Each widget you add also has its own event handler.
So you will create at least one DOM Element per Widget you add and append it into the grid.
CellWidgets first render all childs into a String which is then added to the DOM, by calling setInnerHTML (the browser can optimize this call and add all childs in a batch) and the event handling is only done once by the CellWidget.

embed GWT component TWICE and more in HTML page

I need to embed my GWT component which is a text area which do some functionalities in the key up and key down events twice and more on the same HTML page, in fact when i try to embed it in two different DIVs it appears only one time.
can any one help figure that problem?
A widget can only have one parent in the DOM. The widget will be contained by the last parent to which it is added. If you need to have a widget type appear more than once on the page you need to create more than one instance of the widget.

Why does GWT's RichTextArea implement HasInitializeHandlers?

...and what can I do with my RichTextArea after the onInitialize method has been called that I cannot do before?
N.B. This is a cross-post from the GWT Google group, which produced no response.
An InitializeEvent is fired just after the widget is attached to it's parent. Code that depends on the widget being attached to it's parents and thus the DOM shouldn't be executed before that point.
The RichTextArea widget uses an iframe and this seems to be the cause that some functionality is only available after creation, also depending on the specific browser. I have no full list of all specific cases where you need to initialize code after the widget is attached. But one example specific the RichTextArea widget is if you want to set the focus on the widget the widget must be attached.
You could get the same behavior by extending the RichTextArea widget and overriding the onLoad method, but that requires creating a new class.