Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Controlling layout with SmartGwt and Gwt widgets

    Hi folks,

    I'm having trouble with the layout of a Gwt widget in a SmartGwt application. My app has a fixed-height header (toolbar with menus), a fixed-height footer (status info), and a page (selected according to the menu) that stretches to fill the remaining space. On one of the pages, I have a fixed-height DynamicForm and google map that should (but does not) fill the remaining space on the page.

    My problem is that I cannot figure out how to set the height of the google map to fill the page. If I set the height of the map as "100px", it will indeed be 100 pixels high, but setting "100%" results in a height of 0.

    To make this easier to reproduce, I replaced all my widgets with SmartGwt Labels and replaced the map with a Gwt Label, so that my "app" now consists of an index.html (which has a "style" section to set the height of the Gwt label in css) and a single SmartGwt java file. Both of these files are shown below.

    The result of compiling and running this app is shown in the attachment, where you can see that the height of the Gwt Label (analog my map) is minimized according to content, and not expanding to fill the space available.

    I'm using FireFox 11.0 and Chrome 21.0.1180.82 - both behave in the same way. The SmartClient Developer Console shows: SmartClient Version: v8.2p_2012-07-16/LGPL Development Only (built 2012-07-16)

    I'd be very grateful to anyone who can figure out how to get the map to expand to fill all of the height available on the page.

    Finally, here are the index.html and the SmartGwt java file.

    index.html
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    	<title>SmartGwtDemo</title>
    	<link rel="shortcut icon" href="images/favicon.ico" />
    	<script> var isomorphicDir = "gwt_demo/sc/"; </script>   
    	<script>window.isc_useSimpleNames = false</script> 
    	<script type="text/javascript" src="gwt_demo/gwt_demo.nocache.js"></script>
    
    <style type="text/css">
    .jae-GwtLabel{
    	color: #ffffff;
    	background-color:#ff0000;
    	width: 90%;
    	height: 100%;
    }
    </style>
    	
    </head>
    <body id="page">
    	<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
    	<noscript>
    		<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
    			Your web browser must have JavaScript enabled in order for this application to display correctly.
    		</div>
    	</noscript>
    </body>
    </html>
    AppLoader.java
    Code:
    package de.jaemc.demo.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.Timer;
    import com.google.gwt.user.client.Window;
    import com.smartgwt.client.widgets.Label;
    import com.smartgwt.client.widgets.layout.Layout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class AppLoader implements EntryPoint {
    	
    	VLayout viewPort = new VLayout();  
        Layout  head = new Layout();
        VLayout page = new VLayout();
        Layout  foot = new Layout();
    	
    	@Override
    	public void onModuleLoad() {
    
    		Window.enableScrolling(false);
    		Window.setMargin("50px");
    
            viewPort.setShowEdges(true);  
            viewPort.setWidth100(); 
            viewPort.setHeight100();
            viewPort.setMembersMargin(5);  
            viewPort.setLayoutMargin(10);
            
            // Create a header. 
            head.setHeight(50);
            head.setWidth100();
            head.setBackgroundColor("#C3D9FF");
            head.addMember(new Label("Head"));
            
            // Create a page with all the stretch  - and no content for now.
            page.setHeight("*"); // take all the stretch
            page.setWidth100();
            page.setBackgroundColor("#dddddd");
    
            // Create a footer.
            foot.setHeight(50);
            foot.setWidth100();
            foot.setBackgroundColor("#C3D9FF");
            foot.addMember(new Label("Foot"));
            
            viewPort.addMember(head);  
            viewPort.addMember(page);  
            viewPort.addMember(foot);  
            
            viewPort.draw();
            
            Timer t = new Timer() {
              @Override
              public void run() {
            	  addContentsToPage();
              }
            };
    
            // Schedule the timer to run once after 0.1 second.
            t.schedule(100);
    	}
    	
    	private void addContentsToPage(){
    		
    		// Add label 1. This is a SmartGwt widget and has a height of 50px
    		Label smartGwtLabel = new Label();
    		smartGwtLabel.setContents("This is a SmartGwt Widget : height = 50px");
    		smartGwtLabel.setBackgroundColor("#00ff0f");
    		smartGwtLabel.setHeight(50);
    		smartGwtLabel.setWidth("90%");
    
    		// Add label 2. This is a Gwt Widget and should take up all remaining height.
    		com.google.gwt.user.client.ui.Label gwtLabel = new com.google.gwt.user.client.ui.Label();
    		gwtLabel.setText("This is a Gwt Widget : Height (set is css) = 100%. Note the error in the display sizes");
    		gwtLabel.addStyleName("jae-GwtLabel");
    
    		page.addMember(smartGwtLabel);
    		page.addMember(gwtLabel);
    	}
            
    }
    Sincere thanks to anyone who can help!
    Attached Files

    #2
    Controlling layout with SmartGwt and Gwt widgets

    Hi folks,

    The issue reported below remains unresolved. And it seems I'm not the only one suffering. http://forums.smartclient.com/showthread.php?t=11889
    reports a very similar situation, and while a "workaround" is claimed in one of the responses, another response reports that the workaround fails. I tested it too and the workaround fails for me.

    Can anyone help me out? It's such a basic issue! I just cant imaging there is no solution!

    Cheers!

    Comment


      #3
      Please read the FAQ about mixing GWT and SmartGWT widgets. This is an example of needless mixing.

      Comment


        #4
        Thanks for the tip.

        I looked here: http://forums.smartclient.com/showthread.php?t=8159#aMix but this article does not give any clues on how to avoid such mixing of SmartGwt and Gwt widgets. Could you be just a tiny bit more precise in indicating where I should look?

        I'd be very grateful to know how to include a Google map without a Gwt widget. I'll watch for advice on that.

        Thanks in advance.

        Comment


          #5
          Adding a Google Map would not be an example of needless mixing, but your sample is.

          If you want to see how to embed a Google Map, there are many threads on this forum about it - use search.

          Comment


            #6
            Thanks for responding isomorphic, but your answers are not addressing my question.

            As mentioned in the first two paragraphs of my post, I am working with Google Maps and I already know how to include a map in a SmartGwt application. My problem is that I cannot figure out how to set the height of the google map to fill the (correctly sized) SmartGwt VLayout that contains it. If I set the height of the map as "100px", it will indeed be 100 pixels high, but setting "100%" results in a height of 0.

            Thanks also for the advice to use search... In the isomorphic documentation I found this: http://wiki.smartclient.com/display/Main/Smart+GWT+and+Google+Maps. Seeing "Smart GWT and Google Maps" in the link raised my hopes! However, here one finds only a link to a blog that leaves questions on re-sizing unanswered.

            Since there are many folks out there who also seem to have trouble with sizing/re-sizing of Gwt Maps in SmartGwt apps, perhaps you could spare us a few seconds to explain the solution - or point us to real documentation where a solution can be found - and not just some blog with a few matching keywords, but no answers.

            Comment


              #7
              Read harder.. to reiterate, you posted a code sample of a GWT Label and a SmartGWT Label unsuccessfully sharing space. This is useless mixing of components.

              If you're having trouble with a meaningful use case such as embedding a Google Map, post code that isn't working for that.. or avoid doing so by searching these forums for other posts showing working code for embedding Google Maps.

              You've just linked to a thread showing working code for Google Maps, with people reporting issues with Google Earth (completely different thing).

              Comment

              Working...
              X