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

ComponentConfigBuilder and ComponentDataBuilder

aachanta
13-Aquamarine

ComponentConfigBuilder and ComponentDataBuilder

Hi All,

I had seen like what ComponentConfigBuilder and ComponentDataBuilder Interfaces in Windchill Customization Guide and the method that are in that interface.

However can anyone share one sample program with an example on how to implement these interfaces. As I had seen in the customization guide there was an example on how to set the values etc. But can any one share any other code or an example like where we can implement ComponentConfigBuilder and ComponentDataBuilder Interfaces.

Thanks in advance.

Best Regards,

Aditya Achanta

1 ACCEPTED SOLUTION

Accepted Solutions

Aditya

below is one example of extending AbstractComponentBuilder class which implements  ComponentConfigBuilder and ComponentDataBuilder Interfaces

Hope it helps !!!

package ext.sra.mvc;

@ComponentBuilder("ext.sra.PartSearchBuilder")

public class PartSearchBuilder extends AbstractComponentBuilder {

  private static int level = 1;

  @SuppressWarnings("deprecation")

  @Override

  public Object buildComponentData(ComponentConfig config, ComponentParams params) throws Exception {

  ObjectVector result = new ObjectVector();

  String topLevelPartCriteria = (String) params.getParameter("oid");

  String name = (String) params.getParameter("name");

  JcaComponentParams localJcaComponentParams = (JcaComponentParams) params;

  HashMap<String, Object> map = localJcaComponentParams.getHelperBean().getNmCommandBean().getText();

  for (Iterator<String> itr = set.iterator(); itr.hasNext();) {

  String n = itr.next();

  System.out.println(n + "----" + map.get(n));

  }

  System.out.println("--AAA--" + localJcaComponentParams.getHelperBean().getNmCommandBean().getPageOid());

  System.out.println("--" + topLevelPartCriteria);

  System.out.println("--" + params.getAttribute("oid"));

  System.out.println("--" + params.getContextObject());

  wt.fc.ReferenceFactory oid = new wt.fc.ReferenceFactory();

  wt.fc.WTReference ref = oid.getReference(localJcaComponentParams.getHelperBean().getNmCommandBean().getPageOid().toString().split("~")[0]);

  NavigationCriteria nc = new NavigationCriteria();

  nc.setConfigSpecs(Arrays.asList(new LatestConfigSpec()));

  WTPart part = (WTPart) ref.getObject();

  QueryResult qr = new QueryResult();

  getStructure(part, nc, 1, qr);

  return qr;

  }

  @Override

  public ComponentConfig buildComponentConfig(ComponentParams params) throws WTException {

  ComponentConfigFactory factory = getComponentConfigFactory();

  TableConfig table = factory.newTableConfig();

  table.setLabel("MBOM");

  table.setType("wt.part.WTPart");

  // make row indd the table selectable

  table.setSelectable(true);

  table.setActionModel("shreyas_toolbar");

  ColumnConfig col = factory.newColumnConfig("Name", false);

  table.addComponent(col);

  table.addComponent(factory.newColumnConfig("Level", false));

  table.addComponent(factory.newColumnConfig(INFO_ACTION, false));

  table.addComponent(factory.newColumnConfig("Quantity", false));

  return table;

  }

}

Thanks

Shreyas

View solution in original post

1 REPLY 1

Aditya

below is one example of extending AbstractComponentBuilder class which implements  ComponentConfigBuilder and ComponentDataBuilder Interfaces

Hope it helps !!!

package ext.sra.mvc;

@ComponentBuilder("ext.sra.PartSearchBuilder")

public class PartSearchBuilder extends AbstractComponentBuilder {

  private static int level = 1;

  @SuppressWarnings("deprecation")

  @Override

  public Object buildComponentData(ComponentConfig config, ComponentParams params) throws Exception {

  ObjectVector result = new ObjectVector();

  String topLevelPartCriteria = (String) params.getParameter("oid");

  String name = (String) params.getParameter("name");

  JcaComponentParams localJcaComponentParams = (JcaComponentParams) params;

  HashMap<String, Object> map = localJcaComponentParams.getHelperBean().getNmCommandBean().getText();

  for (Iterator<String> itr = set.iterator(); itr.hasNext();) {

  String n = itr.next();

  System.out.println(n + "----" + map.get(n));

  }

  System.out.println("--AAA--" + localJcaComponentParams.getHelperBean().getNmCommandBean().getPageOid());

  System.out.println("--" + topLevelPartCriteria);

  System.out.println("--" + params.getAttribute("oid"));

  System.out.println("--" + params.getContextObject());

  wt.fc.ReferenceFactory oid = new wt.fc.ReferenceFactory();

  wt.fc.WTReference ref = oid.getReference(localJcaComponentParams.getHelperBean().getNmCommandBean().getPageOid().toString().split("~")[0]);

  NavigationCriteria nc = new NavigationCriteria();

  nc.setConfigSpecs(Arrays.asList(new LatestConfigSpec()));

  WTPart part = (WTPart) ref.getObject();

  QueryResult qr = new QueryResult();

  getStructure(part, nc, 1, qr);

  return qr;

  }

  @Override

  public ComponentConfig buildComponentConfig(ComponentParams params) throws WTException {

  ComponentConfigFactory factory = getComponentConfigFactory();

  TableConfig table = factory.newTableConfig();

  table.setLabel("MBOM");

  table.setType("wt.part.WTPart");

  // make row indd the table selectable

  table.setSelectable(true);

  table.setActionModel("shreyas_toolbar");

  ColumnConfig col = factory.newColumnConfig("Name", false);

  table.addComponent(col);

  table.addComponent(factory.newColumnConfig("Level", false));

  table.addComponent(factory.newColumnConfig(INFO_ACTION, false));

  table.addComponent(factory.newColumnConfig("Quantity", false));

  return table;

  }

}

Thanks

Shreyas

Top Tags