I have create a java class with string properties, i have get the dynamic data from database
and added this class to BeanItemContainer and attach to table data source.
here is the following code I have used to display the data in table.
public class Sample implements Serializable {
private String billOfladingNo;
private String containerNo;
//setters and getters
}
List result = executionPlanDelegate.getDatbleData();
Table table = new Table();
final BeanItemContainer container = new BeanItemContainer(ExecutionPlanVO.class, executionPlanVOs);
container.addBean(new Sample());
table.setContainerDataSource(container);
}
here table with two columns as strings displayed in UI,
here I would like to change the first column (billOfladingNo) as Link in table and populate the dynamic data which is coming from data base.
and when I click this link I want to search with same billOfladingNo name in the table like filters.
could someone help me how can I achieve this with vaadin ?
I have tried with other way like
table.addGeneratedColumn(“BillOfLading”, new Table.ColumnGenerator() {
public Component generateCell(Table source, Object itemId,
Object columnId) {
if (columnId.equals(“BillOfLading”)) {
Link bol = new Link(container.getItem(itemId).getBean().getBillOfladingNo(),null);
container.addItem(bol);
return bol;
}
return null;
}
});
but it is added another new column in table, and is there a way to replacethe column type as link?
for (ExecutionPlanVO ep: executionPlanVOs) { Item newItem = container.getItem(container.addItem()); newItem.getItemProperty(“billOfladingNo”).setValue(ep.getBillOfladingNo()); newItem.getItemProperty(“containerNo”).setValue(ep.getContainerNo()); } Table table = new Table();
//BeanItemContainer container = new BeanItemContainer(ExecutionPlanVO.class, executionPlanVOs); //container.addBean(new ExecutionPlanVO());
table.setContainerDataSource(container);
table.setStyleName(“ep-list-table”);
ERROR:
java.lang.IllegalArgumentException: Value is of invalid type, got java.lang.String but com.vaadin.ui.Link was expected
so could you expaina bit further, how can i place a link in table, the data im getting from java bean dynamically.
and the link will work like filter. with the same string value.
Thanks
Kiran.
Yes, i have placed Link.class then only i got this error.
and I have tried in differend way to place the link in table and
public Component getMainContent(ViewChangeListener.ViewChangeEvent event) {
List<ExecutionPlanVO> executionPlanVOs = executionPlanDelegate.getExecutionPlans(getSearchVO());
Table table = new Table();
table.addContainerProperty("Bill Of Leading", Link.class, null);
table.addContainerProperty("Container No.", String.class, null);
for (int i = 0 ; i < executionPlanVOs.size() ; i++) {
table.addItem(new Object[] {
new Link(executionPlanVOs.get(i).getBillOfladingNo(), null) ,
new String(executionPlanVOs.get(i).getContainerNo())
}, new Integer(i));
}
return table;
and now I am trying to implement the filter on the BillOfLading column, to show the same billof lading name rows like search functionality, is it possible to implement ?
and for other column im implmenting tooltip which should shoe the dynamic data?
I doubt how to add the listners and tooltip data to this columns? because the objects are created in array like
table.addItem(new Object[] {
new Link(executionPlanVOs.get(i).getBillOfladingNo(), null) ,
new String(executionPlanVOs.get(i).getContainerNo())
}, new Integer(i));
please share some ideas how can we do it in efficetive way.
but I would want to populate the data from the bean (ExecutionPlanVO object), which is specific for each row item.
listner in thhe sence,I am looking for a filter functionality in biilof ladingNo Column, like if i click billOf lading number column value ‘abd’ i shoud be able to display the rows which has the billofLading number abc. that is i wanted to try.
and small question, I saw some forums for filter they have used a text field in the header, when we type there it will show the filterd result, so wich is the best way to use filters?