View Full Version : Portal Auto Resize

22 Nov 2011, 12:49 AM
I've got a problem with the autoresizing of portals in my GWT application. Basically, I want to implement the portal like here (http://dev.sencha.com/playpen/gxt/portal/). So if I change the window size, I want that my portlets also resize automatically to fit the window again. I guess in the provided example you are using a ViewPort. However, I have to add a menu additionally, so I use a LayoutContainer to put my portal in:

portal = new Portal(PORTLET_SIZE);

portal.setStyleAttribute("backgroundColor", "white");
portal.setColumnWidth(0, .5);
portal.setColumnWidth(1, .5);

ContentPanel menuLayout = new ContentPanel();

BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
westData.setMargins(new Margins(5));

BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(5, 200, 5, 200));

mainLayout.add(menuLayout, westData);
mainLayout.add(portal, centerData);

So how can I implement the auto-resize behaviour for my portal? Is there also a way of setting the height of the layout container to the client window height? I haven't found a solution therefore yet.

24 Nov 2011, 12:28 AM
I had problems implementing something alike but not with portals ... with regular window+contentPanel.
I solved this by using FitLayout on the parent and let setSize(-1,-1) on child components. I don't know if this is the optimum solution for this, but it worked as a charm for me.
I hope it works on portal also.

Colin Alworth
28 Nov 2011, 1:21 PM
The Viewport class should be added at the root level of your widgets to get children to resize as the browser changes size. Additionally, as Catalin mentioned, you should make sure you are using layouts correctly at each level.

In your case, if the var mainLayout is a ViewPort and is added directly to the RootPanel instance, you should get the behavior you are after. Try posting a complete entrypoint that doesnt resize, and we can be more specific about what you need to change.