Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt 将小部件插入纯HTML代码_Gwt_Web Applications_Servlets - Fatal编程技术网

Gwt 将小部件插入纯HTML代码

Gwt 将小部件插入纯HTML代码,gwt,web-applications,servlets,Gwt,Web Applications,Servlets,由于我将要显示的页面包含大量文本,我希望在它们自己的文本文件中预先格式化这些文本,因此我执行以下操作: execute: onModuleLoad() - make an Async call to the server and load the text files which are html-formatted 代码如下所示: homeAsync.load(new AsyncCallback<String>() { public

由于我将要显示的页面包含大量文本,我希望在它们自己的文本文件中预先格式化这些文本,因此我执行以下操作:

execute: onModuleLoad()
         - make an Async call to the server and load 
           the text files which are html-formatted
代码如下所示:

homeAsync.load(new AsyncCallback<String>() {
  public void onFailure(Throwable caught) {
    contentHome.add(new HTML("<h1>FAIL</h1>something went wrong"));
    caught.printStackTrace();
  }

  public void onSuccess(String result) {
    contentHome.getElement().setId("inner");
    contentHome.add(new HTML(result));
    //RootPanel.get("content").add(new HTML(result));
  }
});
我甚至不知道这是否有效,但老实说。。那简直太难看了^^


对我有什么建议吗?

了解
第1部分和
第2部分可以让事情变得更清楚

是的,您可以将所有
HTML
内容呈现到
小部件
(但是,在安全的方式下,可以谈论)

并避免两次调用
RPC
从数据库获取字符串。如果您知道
part1
part2
一次加载字符串(使用标识符并在
客户端将其拆分)。

用作模板

例如:

String html = "<div id='one' style='border:3px dotted blue;'></div>"
    + "<div id='two' style='border:3px dotted green;'></div>";
HTMLPanel panel = new HTMLPanel(html);
panel.setSize("200px", "120px");
panel.addStyleName("demo-panel");
panel.add(new Button("Do Nothing"), "one");
panel.add(new TextBox(), "two");
RootPanel.get("demo").add(panel);
String html=“”
+ "";
HTMLPanel=新的HTMLPanel(html);
面板设置尺寸(“200px”、“120px”);
panel.addStyleName(“演示面板”);
面板。添加(新按钮(“不做”)和“一”);
panel.add(新文本框(),“两个”);
RootPanel.get(“demo”).add(panel);

您也可以使用以下方法:

Label w = new Label();
w.getElement().setInnerHTML(html);
w.getElement().setInnerSafeHtml(safeHtml);

使用ui活页夹?不,我认为这与我的问题无关^^
String html = "<div id='one' style='border:3px dotted blue;'></div>"
    + "<div id='two' style='border:3px dotted green;'></div>";
HTMLPanel panel = new HTMLPanel(html);
panel.setSize("200px", "120px");
panel.addStyleName("demo-panel");
panel.add(new Button("Do Nothing"), "one");
panel.add(new TextBox(), "two");
RootPanel.get("demo").add(panel);
Label w = new Label();
w.getElement().setInnerHTML(html);
w.getElement().setInnerSafeHtml(safeHtml);