Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    addChild, WidgetCanvas and Size

    I want to point out a difficulty I have with adding gwt widgets to smartgwt canvases.

    If you directly add the gwt widget to a canvas, it adds a WidgetCanvas around it. The essential problem is that when you create a widget canvas, the constructor sets the size based on the widget's dom attributes, not the size set using setwidth on the widget object. This invariably leads to the WidgetCanvas being 100x100 because the size isn't set in the dom.

    If you can add a WidgetCanvas yourself you can set the size yourself, but otherwise you need to do something like:
    Code:
    libraryCanvas.getChildren()[0].setHeight(height);
    libraryCanvas.getChildren()[0].setWidth(width);
    If there's a better way to do this I'd be very interested to know, but otherwise please make the widgetCanvas at least look at the object's attributes.

    #2
    We've been discussing this internally and it's not clear what exactly you're expecting. GWT's core UIObject/Widget classes do not appear to have a notion of current or configured width or height other than what is stored on their DOM element, which we already access when a WidgetCanvas is created.

    Is there something else that you suggest WidgetCanvas should look at to determine the GWT's widget's "actual" width or height?

    Comment


      #3
      Thank you for your reply.

      I don't have a particularly good answer as I haven't delved particularly deep into GWT itself, my experience is through SmartGWT. I was under the impression from using the debugger and inconsistencies I saw between it and firebug that there was a disconnect. Knowing better how WidgetCanvases and the GWT dom elements work together, I was able to figure out two reasons why my widget canvases weren't sizing correctly.

      (1) Lots of javascript libraries don't care about "px" and create the size correctly, and the gwt clients will happily send a "500" out to the javascript library. It looks like GWT, when it sees a size of 500, will leave the size blank in the dom, no matter what is generated by the javascript library. The blank size is picked up by the SmartGWT which interperts it as 100x100. So the javascript library generated divs show the correct sizes, but the gwt doesn't get it and so neither does smargwt and so I have a 100x100 WidgetCanvas.

      (2) I had a callback that triggered the initial sizing of a gwt widget, so when the widget was added to the canvas and the dom was looked at in generating the widgetcanvas, the gwt widget didn't have a size. I had to later go in and resize the WidgetCanvas through the children method listed above.

      Thanks for the help.

      Comment

      Working...
      X