Re: Get data of widgets in a Panel or dynamically determine their class
you can try checking widget.isAttached on all the widgets.
the one widget that is added will return you a true.
now that you know the widget you can retrieve the data entered.
hope it helps
Sudeep
On Wed, Feb 10, 2010 at 9:23 PM, mrubioroy <mrubioroy@gmail.com> wrote:
Hi all,
I'm dynamically adding different widgets (TextBox, CheckBox or
TextArea) to a Panel, depending on the columns found in an SQL table.
Once the different fields are filled up by the user and the "Save"
button is clicked, the code must collect all the introduced data and
send it to server side.
The problem I have is: How do I access data on every widget without
knowing what class is each one? That is, I can have access to any
widget in the Panel, using the getWidget method:
myPanel.getWidget(i)
But how do I access data? I've tried something like
TextBox myWidget;
myWidget = (TextBox) myPanel.getWidget(i);
String data = myWidget.getText();
But this generates an exception if the Widget is of type CheckBox,
because it cannot be cast to TextBox class.
If I could determine the class of myPanel.getWidget(i), then I would
use some if's to cast that to whatever class it's needed.
Thanks
Miguel
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home