Announcement

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

    Question about debugging with SmartGWT

    From time to time I introduce some new code in an existing project that breaks something, but I can't seem to find out what I've broken. The app builds just fine in Eclipse and starts to execute. The GWT server starts to run and the embedded browser window opens but nothing shows up. The server console in Eclipse shows nothing but the standard INFO messages that always show up. If I have the Developer Console open the Results page shows "INFO:Log:initialized" and "INFO:Log:isc.Page is loaded" and that's it. If I remove the lines of code I just added everything is back to normal. How do I debug?

    #2
    Generally because of null checks not happening.
    Code:
    if (key == null)
        throw new IllegalArgumentException("SCQWizard: key must not be NULL");
    or

    Code:
    if (somecheck)
    SC.logWarn("my debug message")

    Comment


      #3
      But the code I added isn't even executing yet. It is part of a click handler that hasn't been invoked.

      Comment


        #4
        Well then it could be a number of things. Easy way is to add checks though SC.logWarn will print to the debug console, you can also throw the exceptions that are part of the JRE emulation in GWT.

        Comment


          #5
          I added an SC.logWarn as the first line of code in onModuleLoad(). Without my offending code it shows up, but when I add back the code it doesn't.

          Comment


            #6
            Hmm probably best to just post the offending code.

            Comment


              #7
              I've managed to get it down to just one line. If I add this as the first line of onModuleLoad() it stops working. I don't even reference the new dt variable.

              DateTime dt = DateTime();

              Note that the DateTime class is imported from org.joda.time.DateTime;

              PS. Thanks a lot for taking the time to try and help with this.

              Comment


                #8
                Is Joda GWT complaint? My guess is it is not and that would be a big problem. If you are using an external library make sure it is a GWT port, not everything in the JRE is emulated in GWT and so a lot of things will not work directly.

                Comment


                  #9
                  I was hoping to avoid using java.util.Date. Guess I'll have to rethink it. How can I find out what is and is not GWT compliant?

                  Comment


                    #10
                    Start here: http://code.google.com/webtoolkit/do...Emulation.html
                    If it is a 3rd party library it should be pretty clear from their site whether they are or not, mainly if it doesn't say they are, assume they aren't.

                    Comment


                      #11
                      Thanks so much for helping me learn. Unfortunately it doesn't look like the java Calendar class is emulated. I'm trying to simply get today's date, subtract 7 days from it and format it as a string. Can you recommend a technique that would work with GWT?

                      Comment


                        #12
                        Simple way:

                        Date now = new Date();
                        Date lastWeek = new Date(now.getTime() - (7 * msInADay));

                        It is dealing with time from the epoch so msInADay is 24 * 60 * 60 * 1000, milliseconds in a 24 hour period. You can also use the older Date(year, month, day - 7) depreciated constructors and the .getMonth(), .getYear(), etc... accessors, and then just convert to string.

                        Comment


                          #13
                          Thank you again. This board has to be one of the most helpful I've ever seen!

                          Comment

                          Working...
                          X