Friday, March 7, 2014

Re: layout panel problem, invisible panels

Had a similar issue and ran into this thread. ContentWidgetView of GWT showcase actually does something similar however instead of extending HeaderPanel it simply wraps the content portion of the header panel in a simplelayoutpanel then makes a similar setsize(100%,100%) call in the constructor. Went with this approach. Also noteworthy is that if you need a scrollpanel, add your widget in the simplelayoutpanel to a scrollpanel vs replacing the simplelayoutpanel with a scrollpanel (similar to what the showcase code does, showcase way works if your widget that needs scrolling isn't a layoutpanel). 

On Wednesday, 10 July 2013 04:54:19 UTC+1, Zak Linder wrote:
I do not use UiBinder, but I have come across this problem as well, and have found a solution that works for me.

The problem is that HeaderPanel only sets the size of the contentContainer, it does nothing with the contentContainer's child widget (HeaderPanel#getContentWidget()). Aiden's suggestion of using ResizeLayoutPanel as the content widget will not work for the same reason (I tried :P). So, my fix is to always wrap the content widget in a SimpleLayoutPanel that fills the contentContainer:

public class HeaderLayoutPanel extends HeaderPanel implements ProvidesResize{

  @Override
  public void setContentWidget(Widget w){
    SimpleLayoutPanel panel = new SimpleLayoutPanel();
    panel.setSize("100%", "100%");
    panel.setWidget(w);
    super.setContentWidget(panel);
  }
}

setSize("100%", "100%") works because the contentContainer's dimensions are always set in px. Also, remember that this needs to be added to a LayoutPanel for it to fill all available space.

I called this class 'HeaderLayoutPanel' and had it implement the ProvidesResize marker interface because I feel that the SimpleLayoutPanel wrapper makes this a 'true' LayoutPanel, since it does fulfill the onResize() contract for the content widget.

Hope that helps!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment