Announcement

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

    Question on HTMLFlow/transformHTML usage

    I have log files that are stored in the database.
    This was done by another app using php/gzcompress.
    I had to add a gzip header to the content because it appears IE8 does not recognize deflate (but that's another story).

    Anyway, the browser unzips the content and I'm using an HTMLPane to display it as a fragment and CSS to style the "pre" tag.

    This all works great in FireFox.
    A bug in IE8 (really?) on the other hand does not recognize carriage returns unless there are pre tags present when the content is rendered.

    I looked at transformHTML and thought this would be just what I needed.
    I couldn't find any usage examples of it so I assume this is how to use it...
    Code:
        this.addContentLoadedHandler(new ContentLoadedHandler() {
          @Override
          public void onContentLoaded(ContentLoadedEvent event) {
            
            if (htmlTagApplied) return;
            
    //        transformHTML("<PRE>" + getContents() + "</PRE>");
            htmlTagApplied = true;
            setContents("<PRE>" + getContents() + "</PRE>");
          }
        });
    Unfortunately, nothing seems to happen.
    The workaround was using get/set Contents and the switch to prevent infinite recursion on the set.

    If I'm not using transformHTML correctly, would it be possible to give an example usage snippet or point me somewhere that shows how to use it?

    Thanks

    #2
    Sorry.

    SmartGWT version: 4.0d 5/18 build
    GWT: 2.5.0
    Java: 7.0 Update 21
    Browsers: FF 20.0.1, IE8
    OS: Windows XP SP3

    Comment


      #3
      SmartGWT version: LGPL 4.0d 5/22 build
      GWT: 2.5.1
      Java: 7.0 Update 21
      Browsers: FF 21.0, IE8
      OS: Windows XP SP3

      After reading the help on the transformHTML method, I think I figured out what was needed but I'm still getting nothing so I'm obviously still not getting it.
      Code:
       transformHTML
      
      public void transformHTML(String html)
      
          Override to modify the loaded HTML before it is rendered.
      
          Parameters:
              html - the html as loaded from the server return (HTML) html to be rendered
      It sounds like the server should provide the html to my override. At that point, I can modify it and hand it back the the parent (super) method but when I run it, the method never gets invoked.
      I even tried force feeding it with a getContents from an onContentLoaded section and it still doesn't render the page with my changes...
      Code:
      import com.smartgwt.client.types.ContentsType;
      import com.smartgwt.client.widgets.HTMLPane;
      
      final public class LogHtmlPane extends HTMLPane
      {
      
        private String logId;
        
        public LogHtmlPane(String id)
        {
          super();
          //
          this.logId = id;
          
          this.setStyleName("logview");
          this.setContentsType(ContentsType.FRAGMENT);
          this.setContentsURL("rest/html/log/" + logId);
          this.setWidth100();
          this.setHeight100();
        }
      
        @Override
        public void transformHTML(String html)
        {
          System.out.println("In transformHTML");
          super.transformHTML("<PRE>" + html + "</PRE>");
          System.out.println("Done transformHTML");
        }
      
      }
      I think this is right but I'm not getting what's expected, so...
      Any help here would be appreciated.

      Comment


        #4
        transformHTML is actually intended to be an override point - you should be passed the original HTML and should return the modified HTML - but the API is currently not functional as an override point in SmartGWT (it works in SmartClient).

        This will be fixed, however, your approach with a call to setContents() is fine, and using transformHTML() (once its functional) would really just be a minor optimization.

        Comment


          #5
          So the Override method I is correct?
          I just wanted to make sure I was implementing it correctly.

          While I agree that the get/set Contents in an onContentLoaded is a viable workaround, it's definitely not as clean. Or as pretty. ;-)
          There's that whole prevent infinite recursion flag thing.

          I was wondering if there was any way to check when this gets fixed?
          I'm thinking this isn't going to be way up there on your "must fix" list.
          i.e. Is there a list of the nightly builds fixes published somewhere?

          Anyway. Thanks.

          Comment

          Working...
          X