Hybrid View

  1. #1
    Ext User
    Join Date
    Sep 2008
    Posts
    6
    Vote Rating
    0
    algesten is on a distinguished road

      0  

    Default [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.

    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 );
        
      }
    Hosted mode:



    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.

  2. #2
    Ext User
    Join Date
    Sep 2008
    Posts
    6
    Vote Rating
    0
    algesten is on a distinguished road

      0  

    Default


    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 );
    
      }

  3. #3
    Ext User
    Join Date
    Sep 2008
    Posts
    6
    Vote Rating
    0
    algesten is on a distinguished road

      0  

    Default


    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*

  4. #4
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    No problem, I am glad the issue went away.

Thread Participants: 1