GWT uiBinder.createAndBindUi(this) 帮助

发布于 2024-10-10 10:11:59 字数 858 浏览 12 评论 0原文

我是 Java GWT 插件的新手。

在我们的代码中,我们使用如下代码,

在 test1.java 中

public class RowResults extends Composite
{

   @UiField VerticalPanel vpnlWidgets;

   public RowResults()
   {

 uiBinder.createAndBindUi(this)); 
 getRows();
   }

   private void getRows()
   {

      for(RowDetails obj: RowDetailsArray)
      {
         RowWidget row= new RowWidget(obj);
      vpnlWidgets.add(row);
      }
   }
}

,在 test2.java 中,

public RowWidget(RowDetails rowObj)
{

       uiBinder.createAndBindUi(this);  
       this.Row = rowObj;
}

我在这里发布了一些必要的代码。在此代码中,如果 RowDetailsArray 有 10 个元素,则为每个元素调用 createAndBindUi。看起来也有些慢。

有没有办法调用 uiBinder.createAndBindUi(this);函数一次并将其用于所有 10 个元素。

另外,调用 createAndBindUi(this) 时会发生什么。是否将 ui.xml 文件转换为类文件或其他文件。

如果我错了,请纠正我。,

提前致谢。

I am new to Java GWT plugins.

In our code, we are using code like below,

In test1.java

public class RowResults extends Composite
{

   @UiField VerticalPanel vpnlWidgets;

   public RowResults()
   {

 uiBinder.createAndBindUi(this)); 
 getRows();
   }

   private void getRows()
   {

      for(RowDetails obj: RowDetailsArray)
      {
         RowWidget row= new RowWidget(obj);
      vpnlWidgets.add(row);
      }
   }
}

In test2.java

public RowWidget(RowDetails rowObj)
{

       uiBinder.createAndBindUi(this);  
       this.Row = rowObj;
}

I have posted here some necessary code. In this code, if I have 10 elements in RowDetailsArray, then for each elements createAndBindUi is called. It seems somewhat slow also.

Is there any way to call uiBinder.createAndBindUi(this); function one time and use that for all the 10 elements.

Also, what will happen while calling createAndBindUi(this). Whether it convert ui.xml file to class file or some thing else.

Pls Correct me if I am wrong.,

Thanks in Advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葬﹪忆之殇 2024-10-17 10:11:59

我想这取决于您的 RowWidget 的复杂程度。如果它没有特殊的样式,我建议使用 FlexTable 代替,然后在其中插入行。这是相当优化的。

I guess it depends on how complicated your RowWidget is. If it has no special styling, I would suggest to use a FlexTable instead and just insert rows in it. It is quite optimized.

紫瑟鸿黎 2024-10-17 10:11:59

使用此代码格式。

public class RowResults extends Composite{
    private static RowResultsUiBinder uiBinder = GWT.create(RowResultsUiBinder.class);
interface RowResultsUiBinder  extends UiBinder<Widget, RowResults> {}
    public RowResults(){
        initWidget( uiBinder.createAndBindUi( this ) );
        // put all your code here if you do not have any other constructor if you have put
        //the above line in that constructor in the begning.
}

Use This Code Format.

public class RowResults extends Composite{
    private static RowResultsUiBinder uiBinder = GWT.create(RowResultsUiBinder.class);
interface RowResultsUiBinder  extends UiBinder<Widget, RowResults> {}
    public RowResults(){
        initWidget( uiBinder.createAndBindUi( this ) );
        // put all your code here if you do not have any other constructor if you have put
        //the above line in that constructor in the begning.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文