Announcement

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

    advice: embedding GWT widgets and resizing/redrawing

    hi community members,

    I spant two days working out the obvious - how to wrap a GWT widget within a canvas and make it work through resizing etc. There are several threads here mentioning this problem.

    What I did is very simple, but for this particular case it works and the performance overhead is negligeable..

    The problem is, that smartGWT does not force the GWT widgets to resize and redraw after resize. However when removed and added again, the hierarchy of smartgwt widgets and their potential gwt children/members do redraw..

    Thus it's possible to catch the events you want to trigger re-rendering of the GWT widget and do above mentioned action after manually resizing them. Then they do resize and redraw...

    example of embedding gwt-cal:

    Code:
    public class SmartGWTCal extends Canvas
    {
    	private Canvas base;
    	private DayView gwtCal;
    
    	public SmartGWTCal(final DayView gwtCal)
    	{
    		this.gwtCal = gwtCal;
    
    		base = new Canvas();
    		base.setWidth100();
    		base.setHeight100();
    		base.addChild(gwtCal);
    		addChild(base);
    		
    		addResizedHandler(new ResizedHandler()
    		{
    			public void onResized(ResizedEvent event)
    			{
    				gwtCal.setHeight(base.getHeight() - 10 + "px");
    				gwtCal.setWidth(base.getWidth() - 10 + "px");
    				gwtCal.doComponentLayout();
    				removeChild(base);
    				addChild(base);
    			}
    		});
    	}
    I'm sorry to post such a triviality, however i wished I found this solution two days ago, so for all the people whose stupidity index >= mine, here it is :-D

    yours,
    -- peter
Working...
X