best way to externalize HTML in GWT apps?

前端 未结 14 1182
执念已碎
执念已碎 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:19

    In GWT 2.0, you can do this using the UiBinder.

    <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'>
      <div>
        Hello, <span ui:field='nameSpan’/>, this is just good ‘ol HTML.
      </div>
    </ui:UiBinder>
    

    These files are kept separate from your Java code and can be edited as HTML. They are also provide integration with GWT widgets, so that you can easily access elements within the HTML from your GWT code.

    0 讨论(0)
  • 2020-12-08 04:20

    I'd say you load the external html through a Frame.

    Frame frame = new Frame();
    frame.setUrl(GWT.getModuleBase() + getCurrentPageHelp());
    add(frame);
    

    You can arrange some convention or lookup for the getCurrentPageHelp() to return the appropriate path (eg: /manuals/myPage/help.html)

    Here's an example of frame in action.

    0 讨论(0)
提交回复
热议问题