1.添加搜索用户.java类
PartRelationDocBuilderTest.java编写
package com.catl.part.relation;
import com.ptc.mvc.components.*;
import com.ptc.mvc.util.ClientMessageSource;
import wt.fc.PersistenceServerHelper;
import wt.fc.QueryResult;
import wt.org.WTUser;
import wt.query.ClassAttribute;
import wt.query.ConstantExpression;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.util.WTException;
import java.util.ArrayList;
@ComponentBuilder("com.catl.part.relation.PartRelationDocBuilderTest")
public class PartRelationDocBuilderTest extends AbstractComponentBuilder {
private ClientMessageSource msgSource;
@Override
public Object buildComponentData(ComponentConfig arg0, ComponentParams params) throws Exception {
String wtUserFullName = (String) params.getParameter("null___wtUserValue___textbox");
QueryResult queryResult = null;
if (wtUserFullName != null && wtUserFullName != "") {
queryResult = SelectUsersTest001(wtUserFullName);
} else {
queryResult = SelectUsersTest001("");
}
return queryResult;
}
@Override
public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {
ComponentConfigFactory factory = getComponentConfigFactory();
TableConfig config = factory.newTableConfig();
config.setConfigurable(false);
config.setType("wt.fc.WTObject");
config.setLabel("RelatedDocument");
config.setSelectable(true);
config.setSingleSelect(true);
ColumnConfig oidColumn = factory.newColumnConfig("oid", true);
config.addComponent(oidColumn);
oidColumn.setHidden(true);
oidColumn.setSortable(true);
ColumnConfig nameColumn = factory.newColumnConfig("name", true);
nameColumn.setLabel("NAME");
config.addComponent(nameColumn);
Object fullNameColumn = factory.newColumnConfig("fullName", true);
config.addComponent((ComponentConfig) fullNameColumn);
Object eMailColumn = factory.newColumnConfig("eMail", true);
config.addComponent((ComponentConfig) eMailColumn);
// ColumnConfig infoPageColumn = factory.newColumnConfig("attributes", false);
// infoPageColumn.setDataUtilityId("infoPageAction");
// config.addComponent(infoPageColumn);
return config;
}
private static QueryResult SelectUsersTest001(String wtUserFullName) throws WTException {
int[] ints = new int[]{0};
QuerySpec qs = new QuerySpec(WTUser.class);
ClassAttribute ca = new ClassAttribute(WTUser.class, WTUser.FULL_NAME);
ConstantExpression ce = new ConstantExpression("%" + wtUserFullName + "%");
ce.setUseEscape(true);
SearchCondition sc = new SearchCondition(ca, SearchCondition.LIKE, ce);
qs.appendWhere(sc, ints);
System.out.println("===qs=" + qs);
QueryResult qr = PersistenceServerHelper.manager.query(qs);
return qr;
}
}
看不懂的可以看我第一篇文件PartRelationDocBuilderTest.java类部分代码解释
2、添加搜索用户按钮
custom-actions.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>
<include href="config/custom/actions/customPart-actions.xml"/>
</listofactions>
custom-actionModels.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE actionmodels SYSTEM "actionmodels.dtd">
<actionmodels>
<include href="config/custom/actions/customPart-actionModels.xml"/>
</actionmodels>
customPart-acionModels.xml
<?xml version="1.0"?>
<!DOCTYPE actionmodels SYSTEM 'actionmodels.dtd'>
<actionmodels resourceBundle="com.ptc.windchill.enterprise.part.partResource">
<!-- *************************************************** -->
<!-- *** Information Page Actions Lists *** -->
<!-- *************************************************** -->
<!-- Part information page Actions list -->
<model name="more parts actions" menufor="wt.part.WTPart">
<action name="testSelect" type="custom"/>
<action name="view" type="object"/> <!-- View Information -->
<action name="separator" type="separator"/> <!-- ===================================== -->
<submodel name="thingworxActionsMenu"/>
<action name="separator" type="separator"/> <!-- ===================&