aino-komal / mvp4g

Automatically exported from code.google.com/p/mvp4g
0 stars 0 forks source link

DockLayoutPanel does not render correctly in a view. #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm currently using 1.1.0.

What I'm attempting to do is have a DockLayoutPanel as my main widget (like 
the grid in the samples).

To duplicate I took the Mvp4gHistory project and did the following :

1) Changed mvp4ghistory.html file to <!DOCKTYPE html>
2) Did the following code change in RootTemplateView.java :

DockLayoutPanel dock=new DockLayoutPanel(Unit.EM);
    DeckPanel message=new DeckPanel();
    DeckPanel top=new DeckPanel();
    DeckPanel bottom=new DeckPanel();
    DeckPanel center=new DeckPanel();

    @Override
    protected Widget createWidget(){
        messageBar.setStyleName( "messageBar" );
        message.add(messageBar);
        message.setSize("100%", "100%");
        top.setSize("100%", "100%");
        bottom.setSize("100%", "100%");
        center.setSize("100%", "100%");
        dock.setSize("100%", "100%");
        dock.addNorth(message, 5);
        dock.addNorth(top, 5);
        dock.addSouth(bottom, 5);
        dock.add(center);
        return dock;
    }

    public Label getMessageBar() {
        return messageBar;
    }

    public void setBottomWidget( Widget w ) {
        bottom.clear();
        bottom.add(w);
        bottom.showWidget(0);
    }

    public void setMainWidget( Widget w ) {
        center.clear();
        center.add(w);
        center.showWidget(0);
    }

    public void setTopWidget( Widget w ) {
        top.clear();
        top.add(w);
        top.showWidget(0);

    }

    public void clearMainWidget() {
        center.clear();
    }

Now I have tried creating widgets and putting them into the dock as a test 
(instead of the DeckPanels), but even on a static display it isn't 
rendering correctly (although Chrome will sometimes get close).

I recall reading something about it maybe having something to do with 
RootView and RootPresenter but have no idea how to overcome it.

Original issue reported on code.google.com by hipgno...@gmail.com on 26 Jan 2010 at 5:13

Attachments:

GoogleCodeExporter commented 9 years ago
Could this message help you 
http://groups.google.com/group/mvp4g/browse_thread/thread/8ced7f667001afe4?

I will look at it and let you know.

Original comment by plcoir...@gmail.com on 27 Jan 2010 at 12:11

GoogleCodeExporter commented 9 years ago
The problem is by default Mvp4g add the RootView to GWT RootPanel. LayoutPanel 
(like 
DockLayoutPanel) doesn't work well with RootPanel. 

A workaround for this issue is to not use the default entry point of Mvp4g but 
uses 
your own and have the following lines of codes:
   Mvp4gModule module = (Mvp4gModule)GWT.create( Mvp4gModule.class );
   module.createAndStartModule();
   RootLayoutPanel.get().add((Widget) module.getStartView());

Original comment by plcoir...@gmail.com on 27 Jan 2010 at 12:46

GoogleCodeExporter commented 9 years ago
I had actually tried the second part of that message :

Mvp4gModule module = (Mvp4gModule)GWT.create 
( Mvp4gModule.class ); 
     module.createAndStartModule(); 
     RootPanel.get().add((Widget) module.getStartView()); 

with no luck (after, of course, changing the .xml etc. to load from a module.

I just tried adding the constructor mentioned in the first. It failed to create 
the 
Element, but by just using the .add it seems to work. Of course, I'm not sure 
that 
what it's generating is perfect, but at least the data is being displayed!

public RootTemplateView(){
        RootLayoutPanel.get().add(dock);
        /*Element element=DOM.createDiv();
        element.setClassName("hidden");
        setElement(element);*/

    }

Original comment by hipgno...@gmail.com on 27 Jan 2010 at 12:46

GoogleCodeExporter commented 9 years ago
With your demo I tried your method and it worked. However, with my actual 
project I've 
found I need the RootLayoutPanel.get().add(dock) line.

I'm not sure what's different, apart from the fact that I have an 
DockLayoutPanel 
embedded in the main DockLayoutPanel (a similar configuration to the GWT E-Mail 
sample).

Original comment by hipgno...@gmail.com on 27 Jan 2010 at 1:47

GoogleCodeExporter commented 9 years ago
Your RootView extends LazyPanel, right? Could this be the problem?
A DeckPanel can only have a LayoutPanel as a parent, but in the case your view 
extends a LazyPanel, then the parent of the DeckPanel is a SimplePanel, that 
could 
explain why the DeckPanel is not displayed.

Could you try to have your view extends Composite instead of LazyPanel?

Original comment by plcoir...@gmail.com on 27 Jan 2010 at 3:49

GoogleCodeExporter commented 9 years ago
I only know Mvp4g at the usage level but I don't think it is a bug with Mvp4g 
itself.  I am using Mvp4g 1.1

In addition to using RootLayoutPanel (and <!DOCTYPE>) as pointed out by 
plcoirier (Jan 2, 2010), it seems that the start view and its chain have to be 
layouts ... below is what I got ...

MainView.ui.xml ...
    <g:DockLayoutPanel unit="PX">
        <g:north size="25">
            <g:HorizontalPanel>
                <g:cell width="1200" horizontalAlignment="ALIGN_RIGHT">
                    <g:MenuBar ui:field="menu" width="140px" animationEnabled="true" autoOpen="true">
                        <g:MenuItem ui:field="settingMenuItem">
                            <g:MenuBar vertical="true" animationEnabled="true">
                                <g:MenuItem ui:field="preferenceMenuItem"/>
                            </g:MenuBar>
                        </g:MenuItem>
                        <g:MenuItem ui:field="loginMenuItem"/>
                    </g:MenuBar>
                </g:cell>
            </g:HorizontalPanel>
        </g:north>
        <g:north size="30">
            <g:DecoratedTabBar ui:field="tabBar"/>
        </g:north>
        <g:center>
            <g:LayoutPanel ui:field="body"/>
        </g:center>
    </g:DockLayoutPanel>

ContentListView.ui.xml ... content of "body" above ...
    <g:DockLayoutPanel unit="PX">
        <g:north size="30">
            <g:SimplePanel>
                <g:Label>Header</g:Label>
            </g:SimplePanel>
        </g:north>
        <g:south size="30">
            <g:SimplePanel>
                <g:Label>Footer</g:Label>
            </g:SimplePanel>
        </g:south>
        <g:center>
            <g:SimplePanel>
                <g:Label>Body</g:Label>
            </g:SimplePanel>
        </g:center>
    </g:DockLayoutPanel>

Original comment by ltb...@gmail.com on 21 Jul 2010 at 4:23

GoogleCodeExporter commented 9 years ago
I'm closing this bug since Mvp4g can be used with any kind of layout.

Original comment by plcoir...@gmail.com on 11 Nov 2010 at 11:52