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

We are happy to announce the new Windchill Customization board! Learn more.

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

mohitenw
11-Garnet

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

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.

1 ACCEPTED SOLUTION
9 REPLIES 9

Thanks Shriram, 

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

Rows created but data not display.

Have you added the oid column?

 

columnConfig = componentConfigFactory.newColumnConfig("oid", "oid", false);
columnConfig.setDataStoreOnly(true);
tableConfig.addComponent(columnConfig);

Yes, i have added like this way 

@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", true));
table.addComponent(factory.newColumnConfig("Role", true));

return table;
}

 

You really need to have a oid attribute, otherwise it will not work.

 

@Getter
@Setter
public class ObjectToDisplay {
private String context;
private String role;
private String oid;
...

 And to display the objects:

@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", true));
table.addComponent(factory.newColumnConfig("role", true));

ColumnConfig columnConfig = factory.newColumnConfig("oid", "oid", false);
columnConfig.setDataStoreOnly(true);
table.addComponent(columnConfig);

return table;
}

@Override
public Object buildComponentData(ComponentConfig var1, ComponentParams var2) throws WTException {
//get all the objects
List<ObjectToDisplay> list = new ArrayList<>();
return list;
}

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() {
        }
    }
}

 

Thanks.

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.

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

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

Basic Customization Getting Started With Windchill Customization https://support.ptc.com/help/wnc/r11.2.0.0/en/index.html#page/Windchill_Help_Center%2FWCCG_Oview_GetStartCust_Intro.html%23
Top Tags