How to add an additional widget to PopupPanel

417 views
Skip to first unread message

Ho Jimmy

unread,
Apr 3, 2010, 7:22:15 AM4/3/10
to google-we...@googlegroups.com
Hi,
 
I am using PopupPanel, containing a vertical panel which has all username, password textfields and submit button, for user authentication.
The widget is added to the PopupPanel by PopupPanel.setWidget(loginPanel).
When the user type the wrong password, I want to add a line of message under the loginPanel of the same PopupPanel.
I have tried PopupPanel.add(new Label("Please type your password again"), but it is not successful.
Since PopupPanel is extended from SimplePanel, why the add method from SimplePanel does not work?
How can I add the Label widget to the PopupPanel?
 
Thanks a lot
 
 

Dan

unread,
Apr 3, 2010, 9:44:54 AM4/3/10
to Google Web Toolkit
You can't add more than one widget to a PopupPanel. You have to add
something like a VerticalPanel to the PopupPanel, and then you can add
multiple widgets to the vertical panel.

Eric

unread,
Apr 4, 2010, 12:15:32 AM4/4/10
to Google Web Toolkit

On Apr 3, 9:44 am, Dan <danpr...@gmail.com> wrote:
> You can't add more than one widget to a PopupPanel. You have to add
> something like a VerticalPanel to the PopupPanel, and then you can add
> multiple widgets to the vertical panel.
>

Which is better? Adding a widget to the VerticalPanel inside the
PopupPanel,
or having a named 'error' widget to the VerticalPanel, and changing
its CSS
class to toggle its visibility?

Eric

kozura

unread,
Apr 4, 2010, 12:46:22 AM4/4/10
to Google Web Toolkit
Just depends on how you want your app to work, having a error/status
widget embedded can be a less obtrusive than a popup. Can also just
use setVisible instead of going through CSS.

Blessed Geek

unread,
Apr 5, 2010, 3:22:58 PM4/5/10
to Google Web Toolkit
It is with the understanding that to use PopupPanel or other
derivatives of SimplePanel (e.g. DialogBox), you can only use one
child widget.

SimplePanel, as its name suggests, allows only one child widge. And
you need to use setWidget to set the child widget. That is why it is
called "Simple".

In order to place more than one child widget, you have to set a
complex panel as its child widget. For example, you could set the
child widget to a HTMLPanel, and then add widgets to the HTMLPanel.

Or, you could use VerticalPanel or HorizontalPanel as its child.

Why:
That is a good design strategy, in my observation, because it lets me
the user be the decision maker on the orientation of the widgets
(flow, html, vertical, horizontal, grid, etc). I do not want
PopupPanel to decide for me the orientation because that would add an
extra layer of orientation control that I may not want.

Let us say that GWT architects decided to set FlowPanel as the complex
panel for PopupPanel. What if I wanted HTMLPanel or VerticalPanel
instead? Then I would have to add another complex panel into the
existing complex panel - why would I want to add an extra layer of
panel? I want to decide what to do myself rather than have some one
else decide how the flow of contents in my use of PopupPanel should
be.

Reply all
Reply to author
Forward
0 new messages