Is SplitLayoutPanel stupid or arrogant?

1,500 views
Skip to first unread message

stagirus

unread,
Apr 15, 2012, 8:01:35 PM4/15/12
to google-we...@googlegroups.com
Pardom me for humanizing the all mighty SplitLayoutPanel. This panel seems to be very powerful except that it is making itself unfriendly and useless in the following scenario.
 
In our application, we needed a vertical splitter (content in North and South). We require the widget to spread out within its parent panel, by calling splitter.setSize("100%", "100%"). But SplitLayoutPanel only takes pixels (setPixelSize). Providing fixed pixel size is not an option for our application. (Our custom built spitter is not properly functioning with Standardards Mode enabled.)
 
Why is SplitLayoutPanel forcing pixel sizes only and not supporting the basic GWT design feature? Is there any work around for this problem?
 

KevMo

unread,
Apr 15, 2012, 11:30:35 PM4/15/12
to google-we...@googlegroups.com
Check out the docs.  https://developers.google.com/web-toolkit/doc/latest/DevGuideUiPanels

When should I not use layout panels?

The panels described above are best used for defining your application's outer structure — that is, the parts that are the least "document-like". You should continue to use basic widgets and HTML structure for those parts for which the HTML/CSS layout algorithm works well. In particular, consider using UiBinder templates to directly use HTML wherever that makes sense.

stagirus

unread,
Apr 16, 2012, 12:38:25 PM4/16/12
to google-we...@googlegroups.com
KevMo:
 
The URL below came up in many of my google searches. But they do not address my issue? Or, do they?
 
My question/issue is more to do with using a SplitLayoutPanel where specific pixel sizes are not available or not feasible? Is there any other widget that supports splitter behavior and also accepts other units such as 100% for widhth and height?

Qian Qiao

unread,
Apr 16, 2012, 12:55:35 PM4/16/12
to google-we...@googlegroups.com

I don't quite understand here. When you say you require the widget to
spread out in it's parent, do you mean:
a) The widgets added to each of the region of the split panel, namely
the north and the south, should occupy its entire given space?
or
b) the SplitLayoutPanel need to fill up its parent?

You usage of the term 'splitter' is also slightly confusing. I've
always assumed it means the little drag-able thing between the
regions, but from what I've read in your email, you seemed to name the
entire Panel splitter, is that correct?

If you want meaningful help from anybody, you'll need to post a bit
more code snippets.

-- Joe

stagirus

unread,
Apr 16, 2012, 1:14:15 PM4/16/12
to google-we...@googlegroups.com
My apologies for my English being not that helpful.
 
As my original post stated: SplitLayoutPanel.setSize("100%", "100%") does not function as one would expect. In our case, the instance of (new SplitLayoutPanel) is added into another panel (VerticalPanel) that in turn fills (spreads) out within its parent panels/widgets. Our layouts are very complex.
 
Unfortunately, SplitLayoutPanel only shows up when I invoke SplitLayoutPanel.setPixelSize(600,600). This is the problem.
 
I hope this makes sense for you all. May I should report this as a defect?
 
 

Qian Qiao

unread,
Apr 16, 2012, 1:37:04 PM4/16/12
to google-we...@googlegroups.com

Ah, it makes a lot more sense now.

The problem here is that you are adding a LayoutPanel, or more
generally, something that implements RequiresResize to a container
that doesn't implement ProvidesResize.

So in your specific case, you SplitLayoutPanel doesn't acquire its
size anywhere, until you've specifically given it with setPixelSize().

Off the top of my head, I can think of a few simple solutions:
a) if it's only north and south, try just using VerticalSplitPanel?
b) Switch the entire layout of you application to standards mode and
use layout panels throughout
c) Since your vertical panel cannot be resized anyway, implement a
custom ProvidesResizeWrapperPanel which sets it's own size to (100%,
100%) and, this is doable because your own panel doesn't have to use
pixel as it's unit. This custom panel then wraps the VeticalSplitPanel
inside the "position: relative" element and ensures that it calls the
VerticalSplitPanel's onResize method after it's been attached to the
DOM. Voila. :)

I hope this helps solving your problem.

-- Joe

stagirus

unread,
Apr 16, 2012, 3:27:33 PM4/16/12
to google-we...@googlegroups.com
Probably, I got confused this time, though your response is very sound technically!

Are you saying, the so called LayoutPanels in GWT 2.X are not compatible with the ubiquitous GWT panels such as VerticalPanel? This implies there were some design flaws in non-layout panels. Rather than fixing the design limitation in older panels, GWT team has introduced a separate layout panel design. This is sad because it must be a totally painful process to upgrade the older panels into new LayoutPanels?

For the SplitLayoutPanel to acquire size information, will it be sufficient to make just the parent panels including RootLayoutPanel to be LayoutPanels? I suppose the child widgets could be non-layout panels, right?

GWT shows that HorizontalSplitPanel and VerticalSplitPanel as deprecated. Do they work well in standards mode? I am not sure these panels support our requirements either.

Qian Qiao

unread,
Apr 16, 2012, 10:53:09 PM4/16/12
to google-we...@googlegroups.com
On Tue, Apr 17, 2012 at 03:27, stagirus <mohan...@gmail.com> wrote:
> Are you saying, the so called LayoutPanels in GWT 2.X are not compatible
> with the ubiquitous GWT panels such as VerticalPanel? This implies there
> were some design flaws in non-layout panels. Rather than fixing the design
> limitation in older panels, GWT team has introduced a separate layout panel
> design. This is sad because it must be a totally painful process to upgrade
> the older panels into new LayoutPanels?

The are compatible to a certain extend, but the underlying technology
they use are totally different.
The API of the new LayoutPanels and old Panels are very similar, so in
most cases it really is just changing the class you use that's all.

These layout panels place whatever that are inside them absolutely,
i.e., they use position: absolute and left, right, top, bottom in
order to display correctly. The advantage of this is that there's no
need for the JavaScript to interfere when the size of the window
changes and the underlying browser will take care of all of that and
in return, the performance much much better. The drawback, however, is
that all widget's size will need to be specified, you can no longer
say: I want the north to auto expand with the widget that's inside it,
instead, you can only do: the maximum size of the north is 100px, if
what's inside it is bigger, it'll need to scroll.

The reason they can't simply "fix" the old panel is that it'll break
backward compatibility, and the new layout panels won't work in quirks
mode, so I think their decision to introduce new implementations and
get the uses to make concious decisions on the switch is a good one.

> For the SplitLayoutPanel to acquire size information, will it be sufficient
> to make just the parent panels including RootLayoutPanel to be LayoutPanels?
> I suppose the child widgets could be non-layout panels, right?

That is the idea. To put it in simple terms, you can put widgets that
doesn't implement RequiresResize in LayoutPanels, but LayoutPanels
will have to be inside widgets that implements ProvidesResize, it's as
simple as that. :)

> GWT shows that HorizontalSplitPanel and VerticalSplitPanel as deprecated. Do
> they work well in standards mode? I am not sure these panels support our
> requirements either.

Good point, they may not work in standards mode. As I said in my
previous email, if you can simply switch everything to layout panels,
do that; If not, implement a custom Container widget that implements
ProvidesResize and calls the LayoutPanel's onResize() when it's
attached to the DOM tree and is visible.

Hope it helps.

-- Joe

stagirus

unread,
Apr 17, 2012, 12:19:12 PM4/17/12
to google-we...@googlegroups.com
Thank you very much. I did not find many classes that are based on the new Layout panel design. Does the single LayoutPanel class support all the features of older HorizontalPanel and VerticalPanel. What about the AbsolutePanel and FlowPanels? Are they compatible with the new LayoutPanels?
 
 

Qian Qiao

unread,
Apr 17, 2012, 1:09:18 PM4/17/12
to google-we...@googlegroups.com

The underlying technology are almost exactly the same between
AbsolutePanel and LayoutPanels, where widgets inside them are placed
absolutely.

HorizontalPanels and VerticalPanels place child widgets inside table
cells. And tables behave differently to divs. However, it's perfectly
fine to place Horizontal/VerticalPanels inside layout panels, provided
that you don't then place layout panels inside the
Horizontal/VerticalPanels.

I recommend reading the javadoc of the widgets you are about to use,
and ensure that they work in standards mode. There are a few widgets
that only work in quirks mode and you'll need to avoid them. GWT had
however provided substitutes to them that works in standards mode in
most cases.

Again, the key is that LayoutPanels need explicit size information,
either by being inside a ProvidesResize, or by given the size, many of
the old style Panels don't, they auto expand as their contents grow.

Sometimes for sophisticated UI, developing your own widgets will
almost be unavoidable.

HTH.

-- Joe

Reply all
Reply to author
Forward
0 new messages