Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I use a ComplexPanel with a GWT ActivityManager
    primarykey
    data
    text
    <p>I'm trying to modify the GWT 2.1 HelloMVP example code to use a more complex UI. (I'm not allowed to provide the link due to a two link limit)</p> <p>My problem is that ActivityManager.setDisplay only accepts objects that implement AcceptsOneWidget. LayoutPanel and other ComplexPanel's don't implement AcceptsOneWidget. The example code uses a SimplePanel instead. But I can't seem to nest complex Widgets within the SimplePanel (they don't display).</p> <p>I've found a few discussions on this problem: </p> <p><a href="http://www.google.com/url?sa=D&amp;q=https://stackoverflow.com/questions/5143196/is-there-a-acceptsonewidget-which-also-providesresze-other-than-scrollpanel%3Fanswertab%3Dactive%23tab-top" rel="nofollow noreferrer">http://www.google.com/url?sa=D&amp;q=https://stackoverflow.com/questions/5143196/is-there-a-acceptsonewidget-which-also-providesresze-other-than-scrollpanel%3Fanswertab%3Dactive%23tab-top</a></p> <p><a href="http://www.google.com/url?sa=D&amp;q=http://www.tempura.org/rants/2010/10/using-layoutpanels-with-gwt-2-1s-activitymanager/" rel="nofollow noreferrer">http://www.google.com/url?sa=D&amp;q=http://www.tempura.org/rants/2010/10/using-layoutpanels-with-gwt-2-1s-activitymanager/</a></p> <p>People suggest the solution is to create a subclass of the ComplexPanel I want that implements the AcceptsOneWidget interface. Like so: </p> <pre><code>public class PanelForView extends LayoutPanel implements AcceptsOneWidget { IsWidget myWidget = null; @Override public void setWidget(IsWidget w) { if (myWidget != w) { if (myWidget != null) { remove(myWidget); } if (w != null) { add(w); } myWidget = w; } } } </code></pre> <p>This sounds great but it doesn't seem to work for me. Perhaps because I'm using GWT 2.3 instead of 2.1 or 2.2. In my EntryPoint I expect to simply replace the SimplePanel with my new PanelForView class and have the app run as before. Like so: </p> <pre><code>public class HelloMVP implements EntryPoint { private Place defaultPlace = new HelloPlace("World!"); // private SimplePanel appWidget = new SimplePanel(); // Replace this with PanelForView private PanelForView appWidget = new PanelForView(); // This compiles but doesn't work. // private SimpleLayoutPanel appWidget = new SimpleLayoutPanel(); // This doesn't work either. public void onModuleLoad() { // Create ClientFactory using deferred binding so we can replace with different // impls in gwt.xml ClientFactory clientFactory = GWT.create(ClientFactory.class); EventBus eventBus = clientFactory.getEventBus(); PlaceController placeController = clientFactory.getPlaceController(); // Start ActivityManager for the main widget with our ActivityMapper ActivityMapper activityMapper = new AppActivityMapper(clientFactory); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay(appWidget); // Start PlaceHistoryHandler with our PlaceHistoryMapper AppPlaceHistoryMapper historyMapper= GWT.create(AppPlaceHistoryMapper.class); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, defaultPlace); RootPanel.get().add(appWidget); // Goes to place represented on URL or default place historyHandler.handleCurrentHistory(); } } </code></pre> <p>This compiles fine but when I run it, I see nothing but a blank screen now. Is there something extra I have to do to initialize a ComplexPanel? Am I just misunderstanding something? I've tried adding Widgets and calling setSize to no avail. This is my first GWT project. </p> <p>Thanks for your time. </p> <p>Corey</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload