Announcement

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

    content of HTMLpane reloads everytime the browserwindow gets resized

    Hi everybody,

    I try to build an application using GWT-Platform and SmartGWT.

    The application has a nested view where only the mainpart gets new content (after calling a #place).
    Simplified: There is a VLayout with HLayout (menu bar with some buttons) and another VLayout for the content (the content-slot).
    The VLayout for the content changes if another place gets called (e.g. #page2).

    The code for the view of page2 is:
    Code:
    public class Page2View extends ViewImpl implements
    		Page2Presenter.MyView {
    
    	  private VLayout panel; 
    	  private HTMLPane htmlPane2;
    	  
    	  @Inject
    	public page2View() {
    		GWT.log("init page2-view", null);
    		
    	    panel = new VLayout();
    	    panel.setRedrawOnResize(false);
    	    
    	    // initialize the HighlightsView layout container
    	    panel.setStyleName("Page2");
     	    
            htmlPane2 = new HTMLPane();  
            htmlPane2.setShowEdges(true);  
            htmlPane2.setContentsURL("http://www.wikipedia.com/");  
            htmlPane2.setContentsType(ContentsType.PAGE);
            htmlPane2.setRedrawOnResize(false);
    
    	    panel.setRedrawOnResize(false);
    	    panel.addMember(htmlPane2);
    	}
    	    
    
    	@Override
    	public Widget asWidget() {
    		return panel;
    	}
    }

    My problem:
    When the place "page2" gets called for the first time everything gets loaded correctly (wikipedia shows up in my application).
    But if I navigate on the site which is shown in the htmlPane (in this case wikipedia) and the Browser window gets resized (+/-) the htmlPane reloads the content and jumps back to the entrypage of wikipedia.
    In my future application that shouldn't happen because in the loaded html-page there should be made important settings which shouldn't get thrown away if the user "touches the browser".

    I'm using SmartClient Version: 8.2/LGPL Development Only (built 2011-12-05)
    I've tested it with Google Chrome, IE, and FF.

    Can somebody tell me why my page behaves like this?
    Is there a solution for my problem?

    I've read that the use of RootPanel should be avoided and draw() should be used... but I think GWTP does that for me.

    Regards

    #2
    Kind of an old thread, but I've been fighting this same problem of the HTMLPane re-fetching the url in SmartClient when the parent container is resized, so I figured that I'd post what worked for me to possibly save others some headache. The redrawOnResize: false setting didn't work for me.

    This is how I fixed it.

    Code:
    isc.HTMLPane.create({
      exists: false,
      redraw: function() {
        if (!this.exists) {
          this.Super('redraw', arguments);
        }
        return this.exists = true;
      },
      contentsURL: "http://www.wikipedia.org",
      contentsType: "page"
    });
    Obviously you would need to translate this to the appropriate SmartGWT calls.

    So far it seems to be working.

    Comment


      #3
      reaper,

      Would you tell me more about how you fixed the problem?

      How should we translate your code to appropriate smartgwt calls?

      Thanks in advance.

      Comment


        #4
        Originally posted by zamfir
        reaper,
        Would you tell me more about how you fixed the problem?
        How should we translate your code to appropriate smartgwt calls?
        Thanks in advance.
        To be honest I'm not sure the best way to translate into smartgwt since I'm not using smartgwt and it's been way too long since I used Java to even want to attempt it.

        As for what I'm doing. I just overrode the redraw method to check to see if the HTMLPane had already been drawn or not. The first time that redraw is called the 'exists' variable will be false so the pane will get drawn as usual. The second time (which occurs when the window is resized) the 'exists' value will be true and so the redraw will be ignored.

        So the basic steps:
        1) create a member variable that can keep track of whether the pane has been redrawn yet or not.
        2) override the redraw method in your instance
        3) before calling Super on the HTMLPane's redraw method check to see if you have already redrawn already.
        4a) if you have already redrawn, then don't call super
        4b) if you haven't redrawn already then redraw (by calling super) and set the member variable so that you will know that you have already drawn the widget for the next time time redraw is called.

        I assume that there are some scenarios where this may not work properly, but it's working great for me and I have a pretty complicated application.

        Hope that helps.

        Comment


          #5
          setRedrawOnResize(false) should solve this problem, and in our testing, it does.

          As far as we can tell, the first poster is having some kind of problem due to mixing GWT widgets with SmartGWT widgets invalidly.

          As far as other problems, if you have explicit calls to redraw() / markForRedraw(), these will redraw the component regardless of the redrawOnResize setting - you can tell the cause of a redraw by enabling the "redraws" log category in the Developer Console.

          If someone can show runnable code demonstrating redrawOnResize behaving incorrectly, we'll take a look.

          Comment


            #6
            I faced similar kind of issue, I've got it fixed using the below custom implementation. I hope you also get it fixed using the same.

            Code:
            class CustomHTMLPane extends HTMLPane
                {
                    protected native void onInit()/*-{
                        this.@CustomHTMLPane::onInitialize()();
                        
                        // Handle redraw case
                        var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                        self.redraw = function() {
                        }
                        
                    }-*/;
                    
                    protected void onInitialize()
                    {
                        super.onInit();
                    }
                }

            Comment


              #7
              Originally posted by Isomorphic View Post
              setRedrawOnResize(false) should solve this problem, and in our testing, it does.

              As far as we can tell, the first poster is having some kind of problem due to mixing GWT widgets with SmartGWT widgets invalidly.

              As far as other problems, if you have explicit calls to redraw() / markForRedraw(), these will redraw the component regardless of the redrawOnResize setting - you can tell the cause of a redraw by enabling the "redraws" log category in the Developer Console.

              If someone can show runnable code demonstrating redrawOnResize behaving incorrectly, we'll take a look.
              There are situations where setRedrawOnResize(false) doesn't seem to work because it is overridden later.
              For example see BaseWidget:getElement(boolean allowPreRender) which does a setProperty("redrawOnResize", true);
              If you do setRedrawOnResize(false) after getElement(), it works as expected.

              Comment


                #8
                redrawOnResize is intentionally modified by necessity if you mix GWT and SmartGWT elements. See the FAQ for when it's appropriate to mix the two set of components.

                If you think there's a circumstance where redrawOnResize is being set incorrectly and the usage is correct, then we need a minimal, ready-to-run test case demonstrating this problem.

                Comment

                Working...
                X