Hybrid View
-
10 Sep 2008 11:38 PM #1
[CLOSED] Hosted mode layout not working
[CLOSED] Hosted mode layout not working
Platform: Mac OS X, Java 1.5.0_13
GWT: 1.5.2
GXT: 1.0.1
Safari: 3.1.2
The following code displays badly in hosted mode.
Hosted mode:Code:public void onModuleLoad() { Viewport viewport = new Viewport(); viewport.setLayout( new BorderLayout() ); LayoutContainer north = new LayoutContainer(); north.add( new Html("North") ); viewport.add( north, new BorderLayoutData(LayoutRegion.NORTH, 33) ); north.setStyleAttribute("background", "red"); LayoutContainer west = new LayoutContainer(); west.add( new Html("West") ); viewport.add( west, new BorderLayoutData(LayoutRegion.WEST, 100, 50, 250) ); west.setStyleAttribute("background", "blue"); LayoutContainer center = new LayoutContainer(); center.add( new Html("Center") ); viewport.add( center, new BorderLayoutData(LayoutRegion.CENTER) ); center.setStyleAttribute("background", "green"); RootPanel.get().add( viewport ); }

If I press the "compile" button in the hosted mode browser I launch Safari and it looks correct:

Not sure if this is a GXT, GWT or Mac OS X specific problem.
-
11 Sep 2008 1:32 AM #2
Workaround
The problem has something to do with that LayoutData is set in Component by a Java method , whilst it is being read by JSNI.
Layout.insert(Widget widget, int index, LayoutData layoutData) is using Component.setLayoutData() to set the data on the component.
Layout.getLayoutData() uses the JSNI implemented method WidgetHelper.getLayoutData(c) to read it.
This workaround uses JSNI for both setting and reading:
Code:public void onModuleLoad() { Viewport viewport = new Viewport() { @Override public boolean insert(Widget widget, int index, LayoutData layoutData) { Component component = wrapWidget(widget); if (layoutData != null) { WidgetHelper.setLayoutData(component, layoutData); // use JSNI to fix hosted mode problem } boolean added = super.insert(component, index); return added; } }; viewport.setLayout( new BorderLayout() ); LayoutContainer north = new LayoutContainer(); north.add( new Html("North") ); viewport.add( north, new BorderLayoutData(LayoutRegion.NORTH, 33) ); north.setStyleAttribute("background", "red"); LayoutContainer west = new LayoutContainer(); west.add( new Html("West") ); viewport.add( west, new BorderLayoutData(LayoutRegion.WEST, 100, 50, 250) ); west.setStyleAttribute("background", "blue"); LayoutContainer center = new LayoutContainer(); center.add( new Html("Center") ); viewport.add( center, new BorderLayoutData(LayoutRegion.CENTER) ); center.setStyleAttribute("background", "green"); RootPanel.get().add( viewport ); }
-
11 Sep 2008 2:53 AM #3
And the problem is fixed with 1.0.4 that is compiled against GWT 1.5.2.
Most likely down to something about JSNI code compiled with 1.4.x not being compatible with code compiled in 1.5.2.
Just get the latest version.
*kicks self for wasting everyone's time*
-
11 Sep 2008 5:38 AM #4
No problem, I am glad the issue went away.


Reply With Quote