Open a widget in a new browser window

2,493 views
Skip to first unread message

LFCPD

unread,
Feb 19, 2008, 4:07:11 AM2/19/08
to Google Web Toolkit
Hi all!

I have a little problem... I have an Hyperlink in my web page and when
the user clicks on this hyperlink, a new browser window should be
opened containing a widget (a widget made by me that contains a form
with textboxes, labels, comboboxes...). But I don't know how can I do
it... Or maybe instead of an hyperlink I could use a simple botton...

Can you help me?

Thanks!

Peter Blazejewicz

unread,
Feb 20, 2008, 3:35:55 PM2/20/08
to Google Web Toolkit
Hello,

there are several possible answers to your implemenation question,
I'd like to show only 3 that are common I believe:
#1
open new window (standalone browser window) and communicate with
javascript
#2
open new window (standalone as in #1) and load new gwt module into it
#3
open new UI element (a.k.a window, dialog, popup, dialogbox) within
your application

#1 and #2 opens new browser window and there are several cons for
that:
- you need to deal with how browsers render new window elements (url
bar, navigation buttons, title, size, new or tabbed window, etc)
- you cannot easiy communicate back to your main (parent) application
- you need to take care about separate window L&F and usability, etc

With #1 & #2 you can use GWT Window.open(...) class,
For solution #1 it is useless because it does not return so called
"opener" reference back to your application. SO immadiately you fall
into writing JSNI code for communication. Also with #1 you cannot use
Java to build UI elements, you need to use some hack javavascript to
write UI and logic for it.
When using #2 you use Window.open(...) method as well but simply loads
new GWT module into it, e.g. to gather user feedback/data and persists
it into database on window close or form submission. It is easily to
implement, can be parametrized from parent application just by passing
key/values in Window.open url, etc. The drawback is that you need to
have separate compilation unit for such kind of dialogs
With #3 solution (non-native UI window element within application) you
usually don't need to do anything special, just show dialogbox which
works as separate applicaiton window with specific purpose which is
the same as for #1 & #2. But everything stays within your application
Java code and can be really easily managed and implemented,

search group for "new window", "opener" or simliar terms for more,

regards,
Peter

LFCPD

unread,
Feb 21, 2008, 3:23:04 AM2/21/08
to Google Web Toolkit
Thank you very much for your answer, but I still have problems...

For example, in my application I have the following code:

final Button button = new Button();
verticalPanel.add(button);
button.addClickListener(new ClickListener() {
public void onClick(final Widget sender) {
CreateReservationForm cr = new CreateReservationForm();
cr.setVisible(true);
}
});
button.setText("New Button");

(CreateReservationForm is a composite) I'd like to open the
CreateReservationForm widget in a new window. But when I click on the
button, nothing happens. Following there is the code for trying to
open a new window from an hyperlink, I'd like to open the same form
(CreateReservationForm), but I don't know what is the url for this
composite.

final Hyperlink isAvailableHyperlink = new Hyperlink("Is Available",
"some history token");
flexTable.setWidget(0, 3, isAvailableHyperlink);
isAvailableHyperlink.addClickListener(new ClickListener() {
public void onClick(final Widget sender) {
Window.open(url, name, features);
}
});

Could you write me the correct code to do that?

Thank you very mucj!

Peter Blazejewicz

unread,
Feb 21, 2008, 3:31:13 PM2/21/08
to Google Web Toolkit
hi,

if I undersand you are trying to show dialog box subclass:
http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/user/client/ui/DialogBox.html
That's #3 solution, all within the same browser window,,

regards,
Peter

LFCPD

unread,
Feb 22, 2008, 3:28:51 AM2/22/08
to Google Web Toolkit
You are right! I needed a DialogBox!

Thank you very much!!!

LFCPD

unread,
Feb 26, 2008, 3:14:32 AM2/26/08
to Google Web Toolkit
Hi,

I realized that a DialogBox is not what I was looking for exactly... I
need a different browser window, the form must be in this window and
this one must have the properties of a window (resizable, close
button, maximizize button...). This window must be independent from
the other browser window. Because the DialogBox gets closed when I
click outside this one, and I can't move it using the mouse... Can a
DialogBox support this properties?

I tried to use a Window (the one from the gwt and the gwt-ext), but
these don't work... Following there is the code.... There is something
wrong?

import com.gwtext.client.widgets.Window;

[...]

CreateReservationForm cr = new CreateReservationForm();
final Window w = new Window();
w.add(cr);
w.show();

Thank you very much!

walden

unread,
Feb 26, 2008, 8:09:49 AM2/26/08
to Google Web Toolkit
LFCPD,

I'm not getting a clear sense of your requirement. Are you looking
for a modal dialog in a box that can be repositioned within the
browser? If so, then DialogBox (or some equivalent) is what you
want. Can you be more clear in what you mean by "this window must be
independent..."?

Walden

LFCPD

unread,
Feb 26, 2008, 9:55:16 AM2/26/08
to Google Web Toolkit
Hi Walden,

In my application I have a main page, and in this main page there is a
link that when you click on it, a form is opened. I'd like to open
this form in a new browser window, not in the same window as the main
page, I mean, I don't want this form to be a part of the window... I
don't know if you understand me... If I open this form in a DialogBox,
the user won't be able to resize or move the DialogBox using the
mouse...

This form is build dynamically. Depending on what the user wants to
do, the form will have more or less fields, other fields will be added
depending on the content of other fields filled by the user... I'd
like to have the form with a fixed size, and if more fields appear in
the form, I'd like to have a scroll bar... I have used a ScrollPanel,
but it doesn't work like I wish... The type of window I want is the
one like a private chat in skype or msn. When you want to initiate a
chat in skype or msn, a new browser window is opened and it is
independent from the main window (the one with all the contacts)...

I hope if I've explained everything clearly...

Thank you!!!

walden

unread,
Feb 26, 2008, 10:40:56 AM2/26/08
to Google Web Toolkit


On Feb 26, 9:55 am, LFCPD <laieta.hip.hop...@gmail.com> wrote:
> Hi Walden,
>
> In my application I have a main page, and in this main page there is a
> link that when you click on it, a form is opened. I'd like to open
> this form in a new browser window, not in the same window as the main
> page, I mean, I don't want this form to be a part of the window... I
> don't know if you understand me... If I open this form in a DialogBox,
> the user won't be able to resize or move the DialogBox using the
> mouse...
>

Stop right there. GWT DialogBox can be dragged by its header. I'm
not sure about making it resizable. MyGWT has Shell widgets, which
are also popups, which can be both dragged and resized and thoroughly
modal. There is nothing in your description that suggests that would
not work. IMO, going outside to another browser Window will cause you
more problems than it will solve.

Walden
Reply all
Reply to author
Forward
0 new messages