private Container getDS() { IndexedContainer idx = new IndexedContainer() { @Override public Object nextItemId(Object itemId) { Integer id = (Integer) super.nextItemId(itemId); return id == null ? null : new Integer(id); } }; for (int i = 0; i < 10; i++) { idx.addItem(); } idx.addContainerProperty("Property", String.class, "foo"); return idx; }
@SuppressWarnings("unchecked") public void addNewRow() { IndexedContainer idc = (IndexedContainer) getContainerDataSource(); int size = idc.size(); Object itemId = idc.addItemAt(size - 1); Item newItem = idc.getItem(itemId); TextField tf = new TextField(); if (inputPrompt != null && inputPrompt.length() > 0) { tf.setInputPrompt(inputPrompt); } tf.setWidth("100%"); newItem.getItemProperty("id").setValue(nextItemIndex); nextItemIndex++; newItem.getItemProperty("text").setValue(tf); setValue(itemId); itemId = idc.addItemAt(size); newItem = idc.getItem(itemId); tf = new TextField(); if (inputPromptChild != null && inputPromptChild.length() > 0) { tf.setInputPrompt(inputPromptChild); } tf.setWidth("100%"); tf.addStyleName("childtf"); newItem.getItemProperty("text").setValue(tf); }