cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

POJO-Table with arbitrary Links

ptc-5247429
4-Participant

POJO-Table with arbitrary Links

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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);

View solution in original post

1 REPLY 1

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);
Top Tags