Pet Table
1. Create the PetTable class
a. File > New > Class
b. Set Package to com.acme.mvc.builders
c. Set Name to PetTable
d. Set Superclass to AbstractComponentBuilder (from com.ptc.mvc.components)
e. Click Finish
2. AbstractComponentBuilder requires that two methods be implemented (Eclipse will generate method stubs for each). The first, buildComponentData, should return the objects (rows) to display in the table. Replace the method’s body with the following code to simply query all pets:
return PersistenceHelper.manager.find(new QuerySpec(Pet.class));
3. The second, buildComponentConfig, returns a table, complete with the columns to display. First, create a convenience method to get individual columns (ColumnConfig and ComponentConfigFactory are imported from com.ptc.mvc.components):
ColumnConfig getColumn(final String id, final ComponentConfigFactory
factory) {
final ColumnConfig column = factory.newColumnConfig(id, true);
column.setSortable(false);
return column;
}
4. Next, create a new class, acmeManagerResource, to manage the localized display name of the table. The complete listing follows:
package com.acme.jca;

import wt.util.resource.*;

@RBUUID("com.acme.jca.acmeActionResource")
public final class acmeManagerResource extends WTListResourceBundle {
@RBEntry("Pets")
public static final String PET_TABLE_LABEL = "pet_table_label";
}
5. Next, replace buildComponentConfig’s generated body with ():
final ComponentConfigFactory factory = getComponentConfigFactory();

final TableConfig table; {
table = factory.newTableConfig();
table.setType(Pet.class.getName());
table.setLabel(WTMessage.getLocalizedMessage(RESOURCE,
acmeManagerResource.PET_TABLE_LABEL, null));
table.setSelectable(true);
table.setShowCount(true);
table.setShowCustomViewLink(false);

final ColumnConfig name; {
name = factory.newColumnConfig(Pet.NAME, true);
name.setInfoPageLink(true);
name.setSortable(true);
}
table.addComponent(name);
table.addComponent(getColumn(ColumnIdentifiers.INFO_ACTION, factory));
table.addComponent(getColumn(ColumnIdentifiers.NM_ACTIONS, factory));
table.addComponent(getColumn(ColumnIdentifiers.LAST_MODIFIED, factory));
table.addComponent(getColumn(Pet.KIND, factory));
table.addComponent(getColumn(Pet.DATE_OF_BIRTH, factory));
table.addComponent(getColumn(Pet.FIXED, factory));
}
return table;
Use Control-L to resolve classes as follows: com.acme.jca.acmeManagerResource, com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers, com.ptc.mvc.components.TableConfig, and wt.util.WTMessage. Also, assign RESOURCE as a field:
static final String RESOURCE = acmeManagerResource.class.getName();
6. Register PetTable as a bean
a. Annotate the PetTable class declaration as follows: @ComponentBuilder("acme.pet.table")
b. Alter the project’s exclusions:
i. Make the project’s .classpath (eclipse/cust_Windchill_src/.classpath) writeable
ii. Project > Properties
iii. Select Java Build Path and the Source tab.
iv. Select Excluded under cust_Windchil_src/src and select Edit.
v. Select config/** and select Edit.
vi. Replace config/** with config/logicrepository/** and click OK
vii. Click Finish and OK
7. Create a new file named Pet-configs.xml.
a. File ... > Other > Other
b. Select XML > XML File, then Next (if XML/XML File are not available, install Eclipse XML Editors and Tools, which is available under the Web, XML, and Java EE Development category when working with the Helios software site -or- simply create a General -> File)
c. Assign parent folder to cust_Windchill_src/src/config/mvc and file name to Pet-configs.xml and click Finish
d. Content is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.ptc.com/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.ptc.com/schema/mvc http://www.ptc.com/schema/mvc/mvc-10.0.xsd">
<!-- Define the builders -->
<bean class="com.acme.mvc.builders.PetTable"/>
</beans>
8. Validate that the table works by starting/restarting Windchill and appending to the base Windchill URL /app/#ptc1/comp/acme.pet.table. The following table should appear:
도움이 되셨나요?