我試圖找到一些使用延遲加載來加載信息的示例,即行。我有一個很好看,但我似乎無法在任何地方找到任何好的例子(我不想使用像Viritin任何添加),我只是想從頭開始。 vaadin網站上的文檔並沒有真正幫助Table,所以我只是想知道是否有人知道有什麼好的教程可以解釋需要完成的工作。也許一個例子可能會更好。所以這裏是一個簡單的表格,顯示5000以下的整數。我將嘗試在這裏實現延遲加載,這是一個非常簡單的應用程序,然後希望我能夠將簡單易用的功能集成到我自己的應用程序中。這是代碼。 我的UI類(MyUI.java):vaadin中的懶惰加載表
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
numberTable theTable = new numberTable();
Button button = new Button("Click Me");
button.addClickListener(new Button.ClickListener()
{
@Override
public void buttonClick(ClickEvent event)
{
System.out.println("test!");
}
});
layout.addComponents(button, theTable);
layout.setMargin(true);
layout.setSpacing(true);
setContent(layout);
}
和表類(numberTable.java):
package my.vaadin.project.tableTest;
import com.vaadin.ui.Table;
public class numberTable extends Table
{
public numberTable(){
/*addContainerProperty("Name", String.class, null);
addContainerProperty("Mag", Float.class, null);
addItem(new Object[]{"Canopus", -0.72f}, 1);
addItem(new Object[]{"Arcturus", -0.04f}, 2);
addItem(new Object[]{"Alpha Centauri", -0.01f}, 3);*/
addContainerProperty("Number", Integer.class, null);
for(int i=1; i<=5000; i++){
Integer itemID = new Integer(i);
addItem(new Object[]{i},itemID);
}
setCaption("Rendering table");
addStyleName("testTable");
setPageLength(size());
System.out.println("table created");
}
}
我讀過,實現延遲加載功能,我必須有一個支持它的容器,除了表格,這是我的理解。
你有什麼樣的數據源? Vaadin中的一些容器支持延遲加載。 –
嗨有一個表(在擴展表的類中創建) – antobbo
表是從容器顯示數據的方式。你如何填充表格? https://vaadin.com/docs/-/part/framework/components/components-table.html。該表根據需要從容器中檢索行 –