GWT embeds plain HTML pages

Source: Internet
Author: User

As we all know, the GWT page is written in Java code, and there is no HTML page directly acting on the GWT panel. But GWT also provides a number of features available, such as frame, this is a UI, the internal can set the URL, but after I test found that the frame after the build, in the nested panel around a box, the effect of beautiful, specifically can not be modified by CSS, I did not test more. Have time to try it later.

I'm here to illustrate another way, GWT provides an HTML UI that has a method, sethtml (String str). Well, it's almost clear that you put some strings in the HTML UI, and then you can show the HTML on the page. But it is impractical to make all the code of an HTML page into a string. The Clientbundle in GWT provides a way to reference external resources. The detailed code is as follows:

  

1 ImportCom.google.gwt.core.shared.GWT;2 ImportCom.google.gwt.resources.client.ClientBundle;3 ImportCom.google.gwt.resources.client.TextResource;4 5  Public InterfaceHtmlresourcesextendsClientbundle {6 7      Public Static FinalHtmlresources INSTANCE = Gwt.create (htmlresources.class);8     9@Source ("page.html")Ten      PublicTextresource gethtml (); One}

It uses the deferred binding method of Gwt.create (), which binds itself here.

Here's how to use it:

New=HtmlResources.INSTANCE.getHtml (). GetText (); html.sethtml (str); Panel.add (HTML);

The use is also simple, so that the HTML page code into a string.

GWT embeds plain HTML pages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.