0
votes

I'm new in GWT, and have problem with view implementation... I use MVP, and SmartGWT. I'll expose this by defining how I settle my MVP and what its weird.

In my onModule, I define class builded with UIbinder. I've declared a LayoutPanel and set it like this in the constructor of the class.

layoutPanel = binder.createAndBindUi(this);

I have container in this class:

public void setBodyLayout() {
panel.setWidgetLeftWidth(menuPanel, xx, PCT, xxx, PCT);
panel.setWidgetRightWidth(bodyPanel, xx, PCT, xx, PCT);
}

menuPanel and bodyPanel are both simplePanel declared in the class above(UIfield use with UIbinder). There are in LayoutPanel. For the method display of my ActivityMapper I've got this method (In reality I have two ActivityMappers, two method that like below and two containers, for menu and body)

public AcceptsOneWidget getBodyContainer() {
return new AcceptsOneWidget() {
  @Override
  public void setWidget(IsWidget w) {
    Widget widget = Widget.asWidgetOrNull(w);
    bodyPanel.setWidget(widget);
  }
};}

return in my onModule, I declared my ActivityMapper like this

BodyActivityMapper bodyContainerActivityMapper = new BodyActivityMapper(clientFactory);
ActivityManager bodyContainerActivityManager = new ActivityManager(bodyContainerActivityMapper, eventBus);
bodyContainerActivityManager.setDisplay(my_class_described_above.getBodyContainer());

the same work was done with MenuActivityMapper...

Finally

RootLayoutPanel.get().add(my_class_described_above.getLayoutPanel());

when getLayoutPanel() return my layoutPanel declared in the class that I have declared above.

So, each region have its own ActivityMapper.ActivityMapper for the menu have only one activity, and "ActivityMapperBody" have sevral activities triggered by menu.

Utility of container are to settle my layout for different "action". I defined zone with it, in order to receive view started with activity.

But this configuration work only with view builded with UIbinder... In each view, I declare a Layout and return it like this

public Widget asWidget() {
  return my_layout_declared;
 } 

When I return my layout, nothing works. I really don't understand why, and I figure that its worse with smartgwt. All I want its just retrieve my layout and put it in my container... Work with smartgwt can save a lot of time...

I've more detailed my issue to make sure that anyone understand. And ask to you Chris Lercher if your post can help me.

Thank for reading

1
Mixing SmartGWT with other GWT widgets is difficult, see the official Smart GWT FAQ This is because of the special way Smart GWT renders its widgets and layouts. Please note that - contrary to the statement in the mentioned FAQ - other GWT widget libraries usually do not have that problem.Chris Lercher
So what's my option ? Give up with smartgwt ? All I need, its just to send a composite or what ever build with smartgwt widget to a SimplePanel. But only UIBinder seems to be appropriate way. Does anyone have a solution to just add a smartgwt widget in a SimplePanel without weird behavior ?user1621997

1 Answers

0
votes

The Smart GWT FAQ mentions a solution:

If you absolutely must place a Smart GWT interface inside a GWT container and you want it to fill the container, the best approach is to listen for a window-level resize event and run your own layout calculations that ultimately call resizeTo() on your topmost Smart GWT widget.

However, it is wrong by saying that

...GWT containers [do not] fire events when they are resized

Layout panels (the "new" panels since GWT 2.0, which was released on Dec 08, 2009) actually do (see the ProvidesResize and RequiresResize interfaces). So if you have such a panel as your MVP body container (and if its parents are also LayoutPanels up to a top RootLayoutPanel), then you can also override the body container's onResize() method instead of listening to the Window resize event.

So how can you solve your concrete problem?

You need to call resizeTo(width, height) on your topmost Smart GWT layout

  • When you put in a (new) Smart GWT layout, e.g. maybe you put in a new one when the Place changes.
  • When the window resizes, or when other things happen that change the size of the container (alternatively, if you're using Layout Panels, you can use its onResize())

For the resizeTo(width, height) call, you'll have to determine the width and height by asking the surrounding container, e.g. by using

container.getElement().getClientWidth()