如何更改HTMLPanel的html [英] How to change the html of a HTMLPanel
本文介绍了如何更改HTMLPanel的html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要声明一个HTMLPanel的子类。
在构造函数中,我想给它几个参数来构造包含html。
因为我必须将超级构造函数作为第一个语句,所以我必须在构造函数中稍后更改html。
我该如何做?
public class MyHTMLPanel extends HTMLPanel
{
public MyHTMLPanel(String id,int anotherParameter)
{super();
String html =
// ...一些代码构造html
// ??? this.setHtml(HTML);
$ div $解析方案
你不需要子类化HTMLPanel。您可以创建一个简单的Composite组件:
public class myPanel extends Composite {
private HTMLPanel panel =新的HTMLPanel();
$ b $ public myPanel(String id,int anotherParameter){
//根据您的参数将HTML设置为面板
initWidget(panel);
}
}
I want do declare a Subclass of an HTMLPanel. In its constructor I want to give it a few paramters to construct the containing html.
Because I have to call the super-constructor as first statement, I have to change the html later in the constructor.
How can I do this?
public class MyHTMLPanel extends HTMLPanel
{
public MyHTMLPanel(String id, int anotherParameter)
{ super("");
String html=""
// ... some code th construct the html
//??? this.setHtml(html);
}
}
解决方案
You don't need to subclass HTMLPanel. You can create a simple Composite widget:
public class myPanel extends Composite {
private HTMLPanel panel = new HTMLPanel();
public myPanel(String id, int anotherParameter) {
// set HTML to panel based on your parameters
initWidget(panel);
}
}
这篇关于如何更改HTMLPanel的html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文