Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
PopupPanel and it's size (GWT 1.1)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ayzen  
View profile  
 More options Aug 13 2006, 5:40 pm
From: "Ayzen" <ay...@p5com.com>
Date: Sun, 13 Aug 2006 14:40:13 -0700
Local: Sun, Aug 13 2006 5:40 pm
Subject: PopupPanel and it's size (GWT 1.1)
Hi.

This code works in GWT 1.0.21 and doesn't work with new release:

setPopupPosition(0, 0);
super.show();
setPopupPosition((Window.getClientWidth() - getOffsetWidth()) / 2,
                 (Window.getClientHeight() - getOffsetHeight()) / 2);

I'm using this in my popup's show() method for positioning it in the
middle of the screen, but in GWT 1.1 popup's "getOffset..." methods
return very small and not correct numbers.

What's wrong with PopupPanel in GWT 1.1 or what should I use to get the
size of my popup?

Thanks.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
blambeau  
View profile  
 More options Aug 14 2006, 10:28 am
From: "blambeau" <blamb...@gmail.com>
Date: Mon, 14 Aug 2006 07:28:36 -0700
Local: Mon, Aug 14 2006 10:28 am
Subject: Re: PopupPanel and it's size (GWT 1.1)
First idea: are you sure that you call the show() method before
querying getOffset...() methods ? Offset sizes cannot be determined
before adding the popup to the DOM (after super.show() when using
Popups).

Second idea: I've got similar problems with popups ... but in a more
complicated situation. The following example works correctly (maybe
your simplified example here does not suffer the problem at all) :

public void onModuleLoad() {

    PopupPanel sample = new PopupPanel() {
        public void show() {
            super.show();

            int cWidth = Window.getClientWidth();
            int cHeight = Window.getClientHeight();
            int myWidth = getOffsetWidth();
            int myHeight = getOffsetHeight();
            setPopupPosition((cWidth-myWidth)/2,(cHeight-myHeight)/2);
        }
    };

    sample.add(new HTML("<h1>Hello world</h1>"));
    DOM.setStyleAttribute(sample.getElement(),"border","1px dashed
black");
    sample.show();

}

In my case, it seems that the getOffset...() methods return correct
results only when the browser has been "javascript idle" at least one
time between the popup creation and the Offset size query. I don't
understand the problem exactly for now but I resolved it by using
DeferredCommand. Really strange ...

blambeau


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ayzen  
View profile  
 More options Aug 18 2006, 4:20 am
From: "Ayzen" <ay...@p5com.com>
Date: Fri, 18 Aug 2006 01:20:26 -0700
Local: Fri, Aug 18 2006 4:20 am
Subject: Re: PopupPanel and it's size (GWT 1.1)
Hi blambeau.

Thanks for your reply. It works with DeferredCommand.

But is it a bug? In version 1.0.21 "getOffset..." methods work fine for
popups...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
blambeau  
View profile  
 More options Aug 18 2006, 10:52 am
From: "blambeau" <blamb...@gmail.com>
Date: Fri, 18 Aug 2006 07:52:17 -0700
Local: Fri, Aug 18 2006 10:52 am
Subject: Re: PopupPanel and it's size (GWT 1.1)
I think it can be seen as a bug ...

However, I cant' understand the real bug cause, and then I'm not able
to provide a short entry point to reproduce it. This kind of material
is probably needed by the GWT team to fix the bug. Maybe you have ?

blambeau


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
(1 user)  More options Aug 18 2006, 5:25 pm
From: "Scott Blum" <sco...@google.com>
Date: Fri, 18 Aug 2006 17:25:17 -0400
Local: Fri, Aug 18 2006 5:25 pm
Subject: Re: PopupPanel and it's size (GWT 1.1)
Hi Ayzen,

The size of any DOM element cannot be queried until it is fully
attached to the DOM.  Instead of overriding show(), try overriding
onAttach():

protected void onAttach() {
  super.onAttach();
  int left = (Window.getClientWidth() - getOffsetWidth()) / 2;
  int top = (Window.getClientHeight() - getOffsetHeight()) / 2;
  setPopupPosition(left, top);

}

Scott

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
blambeau  
View profile  
(3 users)  More options Aug 18 2006, 7:27 pm
From: "blambeau" <blamb...@gmail.com>
Date: Fri, 18 Aug 2006 16:27:03 -0700
Local: Fri, Aug 18 2006 7:27 pm
Subject: Re: PopupPanel and it's size (GWT 1.1)
Hi all,

same discussion here :
http://groups.google.com/group/Google-Web-Toolkit/browse_frm/thread/7...

I'm not sure to understand the problem exactly but it seems that, in
release 1.1, the real attachement of a widget to the DOM is not ensured
as a post condition of add(Widget). I think that the real attachement
is made asynchronously (need confirmation, by a GWT expert ...), and
notified by onAttach. When using popup, show() calls add() but cannot
ensure that the attachement is made.

Any expert comment welcome here.

Solutions:

1) DefferedCommand : not safe because you can't assume that the command
is actually executed before popup attachement (seems to be, but
not a specification).

2) onAttach will probably work, onLoad is better (javadoc of onAttach :
"It must not be overridden, [...] To receive notification when a widget
is attached to
the document, override the onLoad method). However, if your
popup/dialog is not directly responsible of its own placement, it's not
the place to use but ...

3) ... in this last case, the 'popup position responsible' may wait for
isAttached() to be true, with a repeating Timer for example (I don't
like that solution).

4) Finally, an external onLoad notification provided by the popup seems
the best choice to me.

blambeau


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
(1 user)  More options Aug 18 2006, 8:05 pm
From: "Scott Blum" <sco...@google.com>
Date: Fri, 18 Aug 2006 20:05:52 -0400
Local: Fri, Aug 18 2006 8:05 pm
Subject: Re: PopupPanel and it's size (GWT 1.1)
On 8/18/06, blambeau <blamb...@gmail.com> wrote:

> 2) onAttach will probably work, onLoad is better (javadoc of onAttach :
> "It must not be overridden, [...] To receive notification when a widget
> is attached to the document, override the onLoad method).

My bad!  You're quite right, overriding onLoad() is the preferred approached.

Scott


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luc Claes  
View profile  
(1 user)  More options Aug 21 2006, 9:53 am
From: "Luc Claes" <luc.cl...@gmail.com>
Date: Mon, 21 Aug 2006 06:53:53 -0700
Local: Mon, Aug 21 2006 9:53 am
Subject: Re: PopupPanel and it's size (GWT 1.1)
Hi,

I must be missing something.
Take the following simple example:

public class AboutDialog extends DialogBox {
        public AboutDialog() {
                DockPanel panel = new DockPanel();

                setText("About");
                HTML aboutText = new HTML("Test application");
                panel.add(aboutText, DockPanel.CENTER);

                setWidget(panel);
        }

        public void show() {
                super.show();
                DeferredCommand.add(new Command() {
                        public void execute() {
                                // 'Too late': the dialogbox 'jumps' to its destination position
                                center();
                        }
                });
        }

        public void onLoad() {
                center();       // 'Too early': getOffsetWidth and getOffsetHeight are not
yet defined
        }

        public void center() {
                int nLeft = (Window.getClientWidth() - getOffsetWidth()) / 2;
                int nTop = (Window.getClientHeight() - getOffsetHeight()) / 2;
                setPopupPosition(nLeft, nTop);
        }

}

- The popup dimensions seems not to be correctly defined at 'onLoad()'
time.
- Dimensions are correctly defined when using a DeferredCommand but the
dialogbox 'jumps' to its final destination (even if onLoad() is left
undefined).

Is there something wrong in the above code ?
If not, is there an intermediate solution (ie 'known' dimensions  and
no jump effect) ?

Luc


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
(1 user)  More options Aug 21 2006, 2:55 pm
From: "Scott Blum" <sco...@google.com>
Date: Mon, 21 Aug 2006 14:55:16 -0400
Local: Mon, Aug 21 2006 2:55 pm
Subject: Re: PopupPanel and it's size (GWT 1.1)
Luc,

Are you using 1.1.0?  I tested your exact code on Win32 hosted,
IE/Win32 web, and FF/Win32 web.  I commented out your show() override
and got exactly the behavior you would expect.. calling getOffset*()
from onLoad() worked fine for me.

Scott


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luc Claes  
View profile  
 More options Aug 21 2006, 3:29 pm
From: "Luc Claes" <luc.cl...@gmail.com>
Date: Mon, 21 Aug 2006 12:29:15 -0700
Local: Mon, Aug 21 2006 3:29 pm
Subject: Re: PopupPanel and it's size (GWT 1.1)

Scott Blum wrote:
> Luc,

> Are you using 1.1.0?  I tested your exact code on Win32 hosted,
> IE/Win32 web, and FF/Win32 web.  I commented out your show() override
> and got exactly the behavior you would expect.. calling getOffset*()
> from onLoad() worked fine for me.

> Scott

Scott,

Yes, I'm using GWT 1.1.0.

In both hosted mode (Win32) and FF 1.5.0.6, I obtain the following
values:

At 'onLoad()' time: getOffsetWidth() : 3, getOffsetHeight() : 3
At 'DeferredCommand' time: getOffsetWidth() : 78, getOffsetHeight() :
46

Luc


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
 More options Aug 21 2006, 10:32 pm
From: "Scott Blum" <sco...@google.com>
Date: Mon, 21 Aug 2006 22:32:19 -0400
Local: Mon, Aug 21 2006 10:32 pm
Subject: Re: PopupPanel and it's size (GWT 1.1)
Luc,

My mistake.  You are indeed right, it's borked.  I didn't notice
before I posted that in your sample, the text is off-center; just as
you'd expect if it centered on the top-left corner (as if it had zero
size).  This is broken, and it seems the only workaround right now is
to do a DeferredCommand and deal with jumpiness.  This issue is on
Joel's hotlist for the upcoming release.

Thanks!
Scott

On 8/21/06, Luc Claes <luc.cl...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
blambeau  
View profile  
 More options Aug 22 2006, 5:57 am
From: "blambeau" <blamb...@gmail.com>
Date: Tue, 22 Aug 2006 02:57:10 -0700
Local: Tues, Aug 22 2006 5:57 am
Subject: Re: PopupPanel and it's size (GWT 1.1)
Hi,

your example confirms to me that the real behavior of GWT when
attaching widgets to the DOM stay unclear.

Could anyone provide a clear explanation of the way widgets are
attached?

Working on another example (not popup), I realized that the onLoad()
approach is not ensured to work, because
the real size of a Widget depends of its children. It seems that
onLoad() of the parent may be called before the
onLoad() notification of the children (probably a requirement for some
situations ?), explaining that the approach
does not work if the children load take some time.

Why does the DeferredCommand work ? Probably because the children
attachements is executed first ! Here again,
it's not a perfect explanation ... A better one should be based on the
architecture of GWT and javascript generated code.
I'm not GWT expert and I never used javascript before. Many subtilities
are unclear to me ... sorry !

blambeau


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google