Announcement

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

    Showcase Featured Sample "Master Detail": rebuilding in NetBeans: ListGrid too narrow

    Hi -

    I am trying to use NetBeans 6.8 on my machine to build and run the Featured Sample - Master Detail from the SmartGrid 2.0 showcase located here:

    http://www.smartclient.com/smartgwt/..._master_detail

    The project compiles and loads, but the GridList is too narrow: only about 1 inch (about 2 cm) wide.

    The label above it ("Showing items in Category 'Rollfix Glue") is also too narrow.

    The 'Update' Form below the ListGrid is the last item in the VLayout, and it displays wide enough to be legible (although it does display somewhat narrower than in the on-line showcase mentioned above). Maybe it displays fairly wide due to the widgets inside it which may be forcing it to be wide enough to display them all.

    Is it necessary to copy some additional CSS file(s) into the project folder? Or is there some other thing that needs to be done in order for the ListGrid and the Label above it will display with the correct width?

    +++ +++ +++

    I am totally new to NetBeans and SmartGWT, but over the past few days of googling and playing around with NetBeans and SmartGWT I've been able to copy and paste on my local machine to get a few of the showcase samples to work locally in hosted mode. In each case the following steps are performed:

    - Add the smartgwt-2.0 library to a new NetBeans Java Web App project,

    - Copy and paste source code from the local showcase sample the main Java class MainEntryPoint.java into the NetBeans project

    - Add any additional referenced classes to the project, by creating a new package (eg, org.yournamehere.client.data) and drag their Java source files

    - Copy the web resources from the SmartGWT 2.0 folder in Windows into the NetBeans project

    - Add a line to Main.gwt.xml and WelcomeGWT.html and build and run.

    These steps are described in more detail below.

    For two other samples from the Smart GWT Showcase which I tested earlier (Animation Playpen and Tree Grid) everything worked fine.

    However, for the Master Detail sample I am getting this problem where the Label and the ListGrid are too narrow.

    +++ +++ +++

    (1) The SmartGWT 2.0 plug-in in NetBeans 6.8 was installed following the instructions here:

    Configuring Netbeans 6.5 to use SmartGWT (1.01b)
    http://www.plantstar.org/tutorials/N...s_Smartgwt.htm


    (2) In NetBeans, a new Java Web Application project was created by selecting the command 'File > New Project' was the dropdown menu. In the wizard, under 'Categories' the option "Java Web" was selected, and under 'Projects' the option "Web Application" was selected, and on the final screen of the wizard in the 'Frameworks' list, the box "Google Web Toolkit" was selected. All other fields were left with their default values.

    In the Project tree (in the left-hand pane of the IDE), the node 'Libraries' was right-clicked and the option 'Add Library...' was selected, and the "smartgwt-2.0" library was added.

    In Windows, all the SmartGWT web resource files and folders (except folder "WEB-INF" and file "index.html") were copied from the directory where SmartGWT was installed on this machine:

    ..\smartgwt-2.0\Showcase\war\

    to the NetBeans project directory:

    ..\MasterDetailTest\web\

    to make them available to the NetBeans project.


    (3) Using the copy of SmartGWT installed on the local machine (eg, in folder C:\programs), the file:

    file:///C:/programs/smartgwt-2.0/samples/Showcase/war/index.html

    was opened in the browser as a test, and in the list on the left 'Master Detail' was selected, which displayed the following page:

    file:///C:/programs/smartgwt-2.0/samples/Showcase/war/index.html#featured_master_detail

    Then, the button 'View Source' was clicked and the code in the Source file was copied into NetBeans into the Java class file:

    MainEntryPoint.java

    The original package name set by NetBeans was left unchanged, and the class name was changed (back) to MainEntryPoint.java.


    (4) In NetBeans in the Project tree in the left-hand pane, the option 'Source Packages' was clicked, and a new package 'org.yournamehere.client.data' was created. Then, on the local machine (where SmartGWT 2.0 has already been installed, eg in C:\programs\smartgwt-2.0), the following directory was opened in Windows:

    C:\programs\smartgwt-2.0\samples\Showcase\src\com\smartgwt\sample\showcase\client\data

    and the four Java source files

    ItemData.java
    ItemRecord.java
    ItemSupplyXmlDS
    ItemSupplyLocalDS

    were dragged-and-dropped from this Windows directory into the package org.yournamehere.client.data in the Project tree in the left-hand pane in NetBeans to add them to the project. Then in the edit pane for MainEntryPoint.java the mouse was right-clicked and the option 'Fix Imports' was selected.


    (5) The file Main.gwt.xml was modified by adding the following line:

    Code:
    <inherits name="com.smartgwt.SmartGwt" />
    per the instructions here:

    SmartClient Forums - SmartGWT Technical Q & A
    "how to figure out which modules to inherit"
    http://forums.smartclient.com/showthread.php?t=9782

    to produce the following result:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
    
    <module>
        <inherits name="com.google.gwt.user.User"/>
        <inherits name="com.smartgwt.SmartGwt" />    
        <entry-point class="org.yournamehere.client.MainEntryPoint"/>
    </module>

    (6) The file WelcomeGWT.html was modified by adding the following line:

    Code:
    <script type="text/javascript"> var isomorphicDir = "org.yournamehere.Main/sc/"; </script>
    per the instructions here:

    guj.com.br - Forums - Desenvolvimento Web - SmartGWT + NetBeans 6.7.1
    http://www.guj.com.br/posts/list/137140.java

    to produce the following result:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <meta name='gwt:module' content='org.yournamehere.Main=org.yournamehere.Main'>
            <title>Main</title>
        </head>
        <body>
            <script type="text/javascript"> var isomorphicDir = "org.yournamehere.Main/sc/"; </script>
            <script type="text/javascript"  src="org.yournamehere.Main/org.yournamehere.Main.nocache.js"></script>
        </body>
    </html>

    (6)(b) As an alternative, the following lines were also added to WelcomeGWT.html:

    Code:
    <link rel="stylesheet" href="Showcase.css">
    <link rel="stylesheet" href="css/CssStylesSample.css">
    to produce the modified file WelcomeGWT.html:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <meta name='gwt:module' content='org.yournamehere.Main=org.yournamehere.Main'>
            <title>Main</title>
            <link rel="stylesheet" href="Showcase.css">
            <link rel="stylesheet" href="css/CssStylesSample.css">
        </head>
        <body>
            <script type="text/javascript"> var isomorphicDir = "org.yournamehere.Main/sc/"; </script>
            <script type="text/javascript"  src="org.yournamehere.Main/org.yournamehere.Main.nocache.js"></script>
        </body>
    </html>
    However, this also failed to make the Label and the ListGrid display with the correct width.

    +++ +++ +++

    SmartGWT is a very well-designed Ajax package wrapping GWT, and NetBeans is a very powerful IDE. I am very excited to start using them together to build web applications. I understand that the initial stages can be slow, because there are many files involved and everything needs to be properly configured in order to work properly.

    If anyone has any ideas how to make this ListGrid and Label display at the proper width, it would clear up a big mystery for me!

    Thank you.
    Last edited by stefanscottalexx; 21 Feb 2010, 17:56.

    #2
    bump. i had a similar problem!

    Comment


      #3
      Netbeans may be including extra CSS files in your newly created GWT module. If you find any, remove it (see the FAQ for why this is a problem).

      Also, try creating a standalone project rather than starting with the Showcase. The Showcase is designed to show a series of mini-applications and is not a good starting point for a normal application (nor should you include the Showcase CSS in a normal application).

      Comment


        #4
        thanks

        Originally posted by Isomorphic
        Netbeans may be including extra CSS files in your newly created GWT module. If you find any, remove it (see the FAQ for why this is a problem).

        Also, try creating a standalone project rather than starting with the Showcase. The Showcase is designed to show a series of mini-applications and is not a good starting point for a normal application (nor should you include the Showcase CSS in a normal application).
        Hmm... these are interesting ideas.

        I will find this FAQ and try to see if NetBeans is adding any extra CSS files to my project.

        I also agree that it would be a good idea to do a standalone project. (I thought that this was a standalone project because I didn't think I was using the *entire* Showcase - I tried to build just the Master Detail form in the Featured Samples, by just creating a new empty Project in NetBeans and then copying and pasting a couple source code files from the Master Detail sample into the empty Project.) But of course it would be more interesting, and I'd feel more self-confident, if I could build a standalone project as you say - just starting from scratch. I will try this, but it's hard building a project from scratch involving NetBeans and SmartGWT without just one example showing how it's done. There are a lot of files to deal with in a single project and it's not realistic to expect a newbie to have the proper instincts to make it possible to wade through them all and figure out what's what.

        Some step-by-step examples of how to build some of the beautiful samples in the showcase - as *standalone* projects as you say, built from scratch in a typical Java IDE such as NetBeans, Eclipse, or IntelliJ (using the current versions of these IDEs, plus the current version of SmartGWT) would be a really big help to a lot of people who trying to learn SmartGWT and maybe buy it.
        Last edited by stefanscottalexx; 23 Feb 2010, 18:28.

        Comment


          #5
          Took out all CSS files - still not working

          Originally posted by Isomorphic
          Netbeans may be including extra CSS files in your newly created GWT module. If you find any, remove it (see the FAQ for why this is a problem).

          Also, try creating a standalone project rather than starting with the Showcase. The Showcase is designed to show a series of mini-applications and is not a good starting point for a normal application (nor should you include the Showcase CSS in a normal application).
          Well, I took out all the CSS files - and the ListGrid (and the Label above it) are still way too narrow: about an inch wide.

          This is taking me over a week just to get started with SmartGWT. After evaluating dozens of Java web frameworks I do feel that SmartGWT is the best thing out there, and it is one of the few pieces of software I actually am willing to spend some money on (approx. 700 USD to get the Pro version).

          I really could use a tutorial showing how to use NetBeans 6.8 and SmartGWT 2.0 to build a simple standalone project like the Master Detail which is in the Featured Samples in the Showcase.

          I thought I could just do this by creating a new project in NetBeans and copying and pasting the source code from the Master Detail sample into my project - plus any PNG files needed.

          But this isn't working. There are so many configuration files involved with NetBeans and GWT, I don't know where to begin to look.

          If Isomorphic could spend the time to show us how to use the current versions of the major Java IDEs (NetBeans 6.7 or 6.8, Eclipse 3.4 or 3.5, IntelliJ 8 or 9) with the current version of SmartGWT (2.0)... then I bet this would really help to increase sales.

          Isomorphic has a great product here. If there were some up-to-date tutorials available, this would really help increase the user base.

          Comment


            #6
            I got something to work

            Well, after messing around with the code for a while, I found something that does work.


            Here's what I did:

            In the source file MainEntryPoint.java I took the two function calls:

            SetWidth100();

            and replaced them with

            SetWidth(600);

            So the source file MainEntryPoint.Java now reads:

            Code:
            package org.yournamehere.client;
            
            import com.google.gwt.core.client.EntryPoint;
            import com.smartgwt.client.data.DataSource;
            import com.smartgwt.client.widgets.IButton;
            import com.smartgwt.client.widgets.Label;
            import com.smartgwt.client.widgets.events.ClickEvent;
            import com.smartgwt.client.widgets.events.ClickHandler;
            import com.smartgwt.client.widgets.form.DynamicForm;
            import com.smartgwt.client.widgets.grid.ListGrid;
            import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
            import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
            import com.smartgwt.client.widgets.layout.VLayout;
            
            public class MainEntryPoint implements EntryPoint {
            
                public void onModuleLoad() {
            
                    VLayout layout = new VLayout(15);
            
                    Label label = new Label();
                    label.setHeight(10);
                    label.setWidth(600);
                    label.setContents("Showing items in Category 'Rollfix Glue'");
                    layout.addMember(label);
            
                    final DataSource dataSource = ItemSupplyLocalDS.getInstance();
            
                    final DynamicForm form = new DynamicForm();
                    form.setIsGroup(true);
                    form.setGroupTitle("Update");
                    form.setNumCols(4);
                    form.setDataSource(dataSource);
            
            
                    final ListGrid listGrid = new ListGrid();
                    listGrid.setWidth(600);
                    listGrid.setHeight(200);
                    listGrid.setDataSource(dataSource);
                    listGrid.setAutoFetchData(true);
                    listGrid.addRecordClickHandler(new RecordClickHandler() {
                        public void onRecordClick(RecordClickEvent event) {
                            form.reset();
                            form.editSelectedData(listGrid);
                        }
                    });
            
                    layout.addMember(listGrid);
                    layout.addMember(form);
            
                    IButton button = new IButton("Save");
                    button.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent event) {
                            form.saveData();
                        }
                    });
                    layout.addMember(button);
            
                    layout.draw();
                }
            
            }
            This does produce decent-looking output: the ListGrid (and the Label above it) are now wide enough to read.

            If anyone knows a better or "more correct" way of doing this, feel free to comment here. I suspect that the call SetWidth100() (which the JavaDoc says is a convenience method, setting the widget's width to be 100% of its parent/container) would be "more correct" here - but looking at the source code (from the Master Detail example in the Featured Samples of the SmartGWT 2.0 Showcase) I am unable figure out what (if anything) is the parent/ container of the ListGrid (and of the Label). Thanks.



            By the way, in the source code shown above, you may notice that the following import is missing:

            import com.smartgwt.sample.showcase.client.data.ItemSupplyXmlDS;

            This is because I placed the source for class ItemSupplyXmlDS.java (and the two classes it in turns depends on: ItemData.java and ItemRecord.java) in the same package (org.yournamehere.client) as the main source file MainEntryPoint.java.

            Since (if I recall correctly) the default visibility in Java is "package visibility", these other classes are visible from the source file MainEntryPoint.java.

            This might not be elegant, but it avoids some error messages I was getting about "inherited modules" - another very confusing topic for a newbie like me.
            Last edited by stefanscottalexx; 23 Feb 2010, 20:18.

            Comment


              #7
              You really really need to read the FAQ. It has setup guides, and would also tell you to use the Developer Console, where the Watch Tab would show you that the parent is the VLayout (also easily determined from the documentation) and that it's size is dictating the size of the other components.

              Comment


                #8
                OK, thanks

                Originally posted by Isomorphic
                You really really need to read the FAQ. It has setup guides, and would also tell you to use the Developer Console, where the Watch Tab would show you that the parent is the VLayout (also easily determined from the documentation) and that it's size is dictating the size of the other components.
                OK, thank you!

                I thought the VLayout was probably the parent but I wasn't sure.

                +++

                Reading the FAQ now. A *lot* of good stuff in there.

                -- The Developer Console and Visual Builder sound absolutely amazing. So because JavaScript is interpreted, I guess there is major value to installing the Developer Console, as I can see live properties about the objects in the DOM. This is a very exciting prospect.

                -- The Visual Builder letting semi-technical users work in XML to "save screen designs in a declarative format" - ie declaratively specify UI (databound?) widgets ... wow!

                +++

                So... sorry I didn't finish reading the FAQ before - I think the NetBeans setup stuff linked from the FAQ was slightly outdated (it contained additional workarounds which apparently are no longer necessary for SmartGWT 2.0 + NetBeans 6.8: - stuff about setting the maxmemory jvmarg in a target which apparently no longer exists, and stuff about changing the gwt output directory) so I probably got distracted from the FAQ.

                Would my initial post in this thread [steps 1 through 6, *except* 6(b)] also serve as a more up-to-date how-to - for installing SmartGWT 2.0 in NetBeans 6.8 and creating and building a simple project?
                Last edited by stefanscottalexx; 24 Feb 2010, 13:18.

                Comment

                Working...
                X