Friday, May 30, 2014

Re: DockLayoutPanel displays in body, not in div

On Friday, May 30, 2014 11:13:57 AM UTC-4, Patrick May wrote:
On Friday, May 30, 2014 4:58:40 AM UTC-4, Jens wrote:
LayoutPanels are meant to be put into other LayoutPanels. RootPanel or anything you get with RootPanel.get(<id>) isn't a LayoutPanel. So if you have a DockLayoutPanel you should put it into a RootLayoutPanel. 

RootLayoutPanel doesn't do any magic though. It just puts a LayoutPanel into the <body> using RootPanel.get().add(layoutPanel) that fills the entire space. When you now call RootLayoutPanel.get() you are getting that LayoutPanel back and thus your DockLayoutPanel would be added to the LayoutPanel. In addition RootLayoutPanel listens for window resize events and calls a special onResize() method that all LayoutPanels have and which causes them to recalculate some sizes. As this involves some overhead you should only use LayoutPanels to define your general app structure. 

In your example you should be able to see the DockLayoutPanel if your container that has the "ui" id has a fixed size and either position:absolute or position:relative applied.

-- J.

Thanks for the explanation.  My goal is to have the DockLayoutPanel in a div, because I have other elements in my page so I can't give the whole body to the DockLayoutPanel.  If I understand you correctly, the only way I can accomplish this is to set my div to have position:absolute or position:relative and to fix it's size.  I don't know the size to fix -- I'd just like it to take whatever it needs.  Is there any way to accomplish that?

Thanks again,

Patrick

I just tried wrapping the DockLayoutPanel in a VerticalPanel and it displays in the div just fine.

Not knowing why this works makes me nervous, though.
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment