best way to externalize HTML in GWT apps?

前端 未结 14 1204
执念已碎
执念已碎 2020-12-08 03:33

What\'s the best way to externalize large quantities of HTML in a GWT app? We have a rather complicated GWT app of about 30 \"pages\"; each page has a sort

14条回答
  •  感动是毒
    2020-12-08 04:09

    I've used ClientBundle in a similar setting. I've created a package my.resources and put my HTML document and the following class there:

    package my.resources;
    
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.resources.client.ClientBundle;
    import com.google.gwt.resources.client.TextResource;
    
    public interface MyHtmlResources extends ClientBundle {
     public static final MyHtmlResources INSTANCE = GWT.create(MyHtmlResources.class);
    
     @Source("intro.html")
     public TextResource getIntroHtml();
    
    }
    

    Then I get the content of that file by calling the following from my GWT client code:

    HTML htmlPanel = new HTML();
    String html = MyHtmlResources.INSTANCE.getIntroHtml().getText();
    htmlPanel.setHTML(html);
    

    See http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html for further information.

提交回复
热议问题