Skip to main content
1-Visitor
September 11, 2019
Solved

POJO-Table with arbitrary Links

  • September 11, 2019
  • 1 reply
  • 1345 views

I'm creating a table which doesn't have business objects in it but custom POJOs.

This is how the table is configured and filled with data:

	@Override
	public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {

		ComponentConfigFactory factory = getComponentConfigFactory();
		TableConfig table = factory.newTableConfig();
		table.setLabel("Test-Table");
		table.setSelectable(true);
		table.setShowCustomViewLink(true);
		table.addComponent(factory.newColumnConfig("firstName", "First Name", true));
		table.addComponent(factory.newColumnConfig("lastName", "Last Name", true));
		table.addComponent(factory.newColumnConfig("link", "Arbitrary Link", true));

		return table;
	}

 @Override
	public Object buildComponentData(ComponentConfig arg0, ComponentParams arg1) throws Exception {

		Vector<Object> list = new Vector<>();
		Person person1 = new Person();
		person1.setFirstName("Homer");
		person1.setLastName("Simpson");
		person1.setLink("http://www.homersimpson.com");
		Person person2 = new Person();
		person2.setFirstName("Hans");
		person2.setLastName("Moleman");
		person2.setLink("http://www.hansmoleman.com");
		list.add(person1);
		list.add(person2);

		return list;
	}

Now as can be seen the third column is a link. Is there any possibility to show this third column as a hyperlink - ideally with a label? The only thing I saw in the customization guide is .setInfoPageLink(true) but this of course only works for business objects and only links to the Info Page of course.

Best answer by BjoernRueegg

There is no possiblity I know of to create a link in the table builder. You need to write a data utility and return a UrlDisplayComponent. 

To set the data utility you need to set the name of it to the same as the attribute (pay attention that you don't overwrite the default) or you define it in the column:

ColumnConfig column = factory.newColumnConfig("firstName", "First Name", true);
column.setDataUtilityId("yourcustomdatautility");
table.addComponent(column);

1 reply

17-Peridot
September 12, 2019

There is no possiblity I know of to create a link in the table builder. You need to write a data utility and return a UrlDisplayComponent. 

To set the data utility you need to set the name of it to the same as the attribute (pay attention that you don't overwrite the default) or you define it in the column:

ColumnConfig column = factory.newColumnConfig("firstName", "First Name", true);
column.setDataUtilityId("yourcustomdatautility");
table.addComponent(column);