Skip to main content
12-Amethyst
February 11, 2020
Solved

How to create and render custom table for non persistable object in windchill?

  • February 11, 2020
  • 3 replies
  • 6372 views

Hi,

I am able to create MVC table builder for non persistable object, but records are not displaying in table,

hence can anyone provide solution?

FYI : "extends AbstractConfigurableTableBuilder"

 

Thanks.

3 replies

5-Regular Member
February 11, 2020
mohitenw12-AmethystAuthor
12-Amethyst
February 12, 2020

Thanks Shriram, 

i am able to create table but stuck in populate data.

Rows created but data not display.

17-Peridot
February 12, 2020

This should work

import com.ptc.mvc.components.*;
import wt.util.WTException;

import java.util.ArrayList;
import java.util.List;

public class MyTableBuilderClass extends AbstractComponentBuilder {
 @Override
 public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {
 ComponentConfigFactory factory = getComponentConfigFactory();
 TableConfig table = factory.newTableConfig();
 table.setLabel("User Info..");
 table.setSelectable(true);

 table.addComponent(factory.newColumnConfig("context", "Context", true));
 table.addComponent(factory.newColumnConfig("contextTeamRole", "Context Role", true));
 table.addComponent(factory.newColumnConfig("fromUser", "From User", true));
 table.addComponent(factory.newColumnConfig("toUser", "To User", true));
 
 ColumnConfig columnConfig = factory.newColumnConfig("oid", "oid", false);
 columnConfig.setDataStoreOnly(true);
 table.addComponent(columnConfig);
 return table;
 }
 
 @Override
 public Object buildComponentData(ComponentConfig arg0, ComponentParams arg1) throws Exception {
 List<UserUtil> result = new ArrayList<UserUtil>();
 result.add(new UserUtil("Product1", "Member", "User1", "User2","1"));
 result.add(new UserUtil("Library2", "Member", "User1", "User2","2"));
 result.add(new UserUtil("Project3", "Member", "User1", "User2","3"));
 result.add(new UserUtil("Library4", "Member", "User1", "User2","4"));
 result.add(new UserUtil("Project5", "Member", "User1", "User2","5"));
 for (UserUtil userUtil : result) {
 System.out.println("Context : " + userUtil.getContext());
 }
 return result;
 }
 // POJO : User Utility
 public static final class UserUtil {
 private String context;
 private String contextTeamRole;
 private String fromUser;
 private String toUser;
 private String oid;

 public String getContext() {
 return context;
 }
 public void setContext(String context) {
 this.context = context;
 }
 public String getContextTeamRole() {
 return contextTeamRole;
 }
 public void setContextTeamRole(String contextTeamRole) {
 this.contextTeamRole = contextTeamRole;
 }
 public String getFromUser() {
 return fromUser;
 }
 public void setFromUser(String fromUser) {
 this.fromUser = fromUser;
 }
 public String getToUser() {
 return toUser;
 }
 public void setToUser(String toUser) {
 this.toUser = toUser;
 }
 public String getOid() {
 return oid;
 }
 public void setOid(String oid) {
 this.oid = oid;
 }
 public UserUtil(String context, String contextTeamRole, String fromUser, String toUser, String oid) {
 this.setContext(context);
 this.setContextTeamRole(contextTeamRole);
 this.setFromUser(fromUser);
 this.setToUser(toUser);
 this.setOid(oid);
 }
 public UserUtil() {
 }
 }
}

 

17-Peridot
February 11, 2020

You need to provide an attribute called oid in your java object. Than you will be able to show any object in a table.

 

If you need your own views than you can extend the table as you did, otherwise AbstractComponentBuilder does work also.

17-Peridot
February 12, 2020

Hello, there is a video of training for example from the documentation

https://www.youtube.com/watch?v=-14BSAwteVw&list=PLjm4gmbLQwoeqQSP7xUhCnInGknqTBAZV&index=2