best way to externalize HTML in GWT apps?

前端 未结 14 1181
执念已碎
执念已碎 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 03:57

    You can use some templating mechanism. Try FreeMarker or Velocity templates. You'll be having your HTML in files that will be retrieved by templating libraries. These files can be named with proper extensions, e.g. .html, .css, .js obsearvable on their own.

    0 讨论(0)
  • 2020-12-08 03:58

    Take a look at http://code.google.com/intl/es-ES/webtoolkit/doc/latest/DevGuideClientBundle.html

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

    You could try implementing a Generator to load external HTML from a file at compile time and build a class that emits it. There doesn't seem to be too much help online for creating generators but here's a post to the GWT group that might get you started: GWT group on groups.google.com.

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

    Why not to use good-old IFRAME? Just create an iFrame where you wish to put a hint and change its location when GWT 'page' changes.

    Advantages:

    • Hits are stored in separate maintainable HTML files of any structure
    • AJAX-style loading with no coding at all on server side
    • If needed, application could still interact with loaded info

    Disadvantages:

    • Each hint file should have link to shared CSS for common look-and-feel
    • Hard to internationalize

    To make this approach a bit better, you might handle loading errors and redirect to default language/topic on 404 errors. So, search priority will be like that:

    1. Current topic for current language
    2. Current topic for default language
    3. Default topic for current language
    4. Default error page

    I think it's quite easy to create such GWT component to incorporate iFrame interactions

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

    I'm not sure I understand your question, but I'm going to assume you've factored out this common summary into it's own widget. If so, the problem is that you don't like the ugly way of embedding HTML into the Java code.

    GWT 2.0 has UiBinder, which allows you to define the GUI in raw HTMLish template, and you can inject values into the template from the Java world. Read through the dev guide and it gives a pretty good outline.

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

    GWT 2.0, when released, should have a ClientBundle, which probably tackles this need.

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