I have trouble with vaadin 6 table:
@Configurable(preConstruction=true)
public class Stock implements WindowComponent {
@Autowired
StockService service;
WareSystemsDisplay display;
public Stock(WareSystemsDisplay wareSystemsDisplay) {
display = wareSystemsDisplay;
}
private Table categorySelector;
private IndexedContainer icCat = new IndexedContainer();
private Table stockTable;
@SuppressWarnings("serial")
@Override
public AbstractComponent create(AbstractComponent parent) {
GridLayout mainLayout = new GridLayout();
mainLayout.setMargin(false);
mainLayout.setWidth("99%");
mainLayout.setHeight("99%");
mainLayout.setColumns(6);
mainLayout.setColumnExpandRatio(0, 5f);
mainLayout.setColumnExpandRatio(1, 10f);
mainLayout.setColumnExpandRatio(2, 5f);
mainLayout.setColumnExpandRatio(3, 10f);
mainLayout.setColumnExpandRatio(4, 5f);
mainLayout.setColumnExpandRatio(5, 200f);
mainLayout.setSpacing(true);
for (int i=0; i<10; i++)
mainLayout.insertRow(i);
categorySelector = new Table();
categorySelector.addStyleName("components-inside1");
categorySelector.setSizeFull();
categorySelector.setImmediate(true);
categorySelector.setEnabled(true);
categorySelector.setSelectable(true);
categorySelector.setMultiSelect(false);
icCat.addContainerProperty("Category name", Label.class, null);
categorySelector.setContainerDataSource(icCat);
categorySelector.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
loadCategory((Long) ((AbstractComponent)event.getProperty().getValue()).getData());
}
});
mainLayout.addComponent(new Label("Category:"), 0, 0, 4, 0);
mainLayout.addComponent(categorySelector, 0, 1, 4, 7);
Button addCategoryButton = new Button("Add category");
Button deleteCategoryButton = new Button("Delete category");
mainLayout.addComponent(addCategoryButton, 1, 8, 1, 8);
mainLayout.addComponent(deleteCategoryButton, 3, 8, 3, 8);
Button addItemButton = new Button("Add Item");
mainLayout.addComponent(addItemButton, 1, 9, 3, 9);
stockTable = new Table();
stockTable.setSizeFull();
stockTable.setSelectable(false);
stockTable.setImmediate(true);
mainLayout.addComponent(new Label("Stock:"), 5, 0, 5, 0);
mainLayout.addComponent(stockTable, 5, 1, 5, 9);
return mainLayout;
}
@Override
public String getWComponentName() {
return "Stock";
}
private ThreadLocal<StockCategory> selectedCategory = new ThreadLocal<StockCategory>();
protected void loadCategory(Long id) {
selectedCategory.set(service.find(id));
}
@Override
public void refresh() {
stockTable.removeAllItems();
categorySelector.removeAllItems();
List<StockCategory> cids = service.getAllCategories();
for (StockCategory c : cids){
Label l = new Label(c.getName());
l.setData(c.getId());
icCat.addItem(l);
}
}
}
I add label with text into container but table is empty, with clickable empty space. I do not know what to do at this point…