1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    42
    Vote Rating
    0
    obender is on a distinguished road

      0  

    Default GWT widgets' margins in RowLayout in beta 5?

    GWT widgets' margins in RowLayout in beta 5?


    The setMargin/setSpacing was removed from RowLayout and it seems like there is no good way now to set margins for GWT components added to the RowLayout.
    The setStyleAttribute (that is suggested in the JavaDoc and example) is a method of the GXT Component class so it would work if you add GXT components to the container with RowLayout but what about the cases when you need to add GWT component.
    The only solution I can see is to wrap any GWT component in to the WidgetComponent is this is the right way.

  2. #2
    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


    Any widget added to a container which is not a component will be wrapped automatically. You have 3 choices:

    1. Wrap your widget before adding to container.
    2. Add to container then get the wrapped widget.
    2. Use DOM to set the margin: DOM.setStyleAttribute(widget.getElement(), "margin", "10");

  3. #3
    Ext User
    Join Date
    Apr 2008
    Posts
    42
    Vote Rating
    0
    obender is on a distinguished road

      0  

    Default


    ok, thanks

  4. #4
    Ext User andrey's Avatar
    Join Date
    May 2008
    Location
    Boston
    Posts
    34
    Vote Rating
    0
    andrey is on a distinguished road

      0  

    Default What's the philosophy?

    What's the philosophy?


    Hi Darrel,

    It seems that one of the advantages GWT and Ext-GWT is the notion that java developers (or non-javascript or CSS experts) are able to program RIAs effectively. The replacement of methods such as setMargin() and setSpacing() in favor of methods that interact with the underlying CSS seem to contradict the advantage mentioned above. Certainly the workarounds suggested in this thread indicate a regression in the ease-of-use of the API.

    I am curious about the reasoning and philosophy regarding this change?

    Thanks,
    Andre

  5. #5
    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


    Audrey
    You raise some good points. The reason for the change is related to how the layouts now work. Previously, margins and spacing were manually calculated and the widgets size and position were adjusted. This has been changed in favor of using CSS. With this approach you are able to specify margins for all 4 sides and can use all CSS units, not just pixels.

    I have made some changes so that you can still apply margins using the layout. First, there is a new LayoutData class that supports a Margins object. RowData, FlowData (new), FillData (new) now extends LayoutData. The base Layout class will apply the margins automatically when the component is rendered. So you can now either apply margins directly, or use a LayoutData.

    For example:

    Code:
      public void onModuleLoad() {
        Viewport v = new Viewport();
        v.add(new Button("Button 1"), new FlowData(10));
        v.add(new Button("Button 2"), new FlowData(0, 5, 5, 5));
        RootPanel.get().add(v);
      }
    How does this sound?

  6. #6
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    +1

    me like the new layoutdata ways which is very in-the-spirit-of GWT me thinks....

  7. #7
    Ext User andrey's Avatar
    Join Date
    May 2008
    Location
    Boston
    Posts
    34
    Vote Rating
    0
    andrey is on a distinguished road

      0  

    Default


    Yes, the "layout data" approach is much better and consistent with BorderLayout and RowLayout.

    Thx,
    Andre

  8. #8
    Ext User
    Join Date
    Apr 2008
    Posts
    376
    Vote Rating
    0
    zaccret is on a distinguished road

      0  

    Default


    It looks good