开发Windchill 开发 修改部件软类型 记一次前台按钮开发
如题,目标是在部件的操作菜单上开发一个按钮,用于修改部件软类型,这里只记录我自己探索前台按钮开发的过程,没有做逻辑分析,有疏漏的地方欢迎指出。概要的开发步骤参考目录,先后顺序可以适当调整。
开发环境:windchill 11.0 M030
文章目录
下面正片开始:
1、custom-actions.xml 中添加按钮的action请求。
文件路径在 windchill_home/codebase/config/actions/custom-actions.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>
<objecttype name="custPart" resourceBundle="ext.aaa.part.resource.CustomRB">
<!-- 修改部件软类型 -->
<action name="modifyPartType">
<command class="ext.aaa.part.processors.ModifyPartTypeProcessor" method="execute" url="/netmarkets/jsp/ext/aaa/part/modifyPartType.jsp" windowType="popup" />
<includeFilter name="PartButtonFilter1" />
</action>
<action name="modifyPartTypeStep" afterJS="checkPartNewType">
<command url="/netmarkets/jsp/ext/aaa/part/modifyPartTypeStep.jsp" windowType="wizard_step" />
</action>
</objecttype>
</listofactions>
其中 resourceBundle 指向资源文件路径,第二个action为Step页面的请求。
afterJS 中指向的js函数,用于在页面提交前执行校验。
2、custom-actionModels.xml 中将按钮添加到部件的操作菜单中。
文件路径同上。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE actionmodels SYSTEM "actionmodels.dtd">
<actionmodels>
<!-- 部件操作model -->
<model name="more parts actions" menufor="wt.part.WTPart">
<action name="modifyPartType" type="custPart" /> <!-- 修改部件软类型 -->
</model>
</actionmodels>
3、编写资源文件,包括报错信息的国际化资源。
package ext.aaa.part.resource;
import wt.util.resource.RBEntry;
import wt.util.resource.RBUUID;
import wt.util.resource.WTListResourceBundle;
@RBUUID("ext.lfs.part.resource.CustomRB")
public class CustomRB extends WTListResourceBundle {
@RBEntry("Change Part Type")
public static final String ACTION_CONSTANT_22 = "custPart.modifyPartType.description";
@RBEntry("Change Part Type")
public static final String ACTION_CONSTANT_23 = "custPart.modifyPartType.title";
@RBEntry("Change Part Type")
public static final String ACTION_CONSTANT_24 = "custPart.modifyPartType.tooltip";
@RBEntry("Change Part Type")
public static final String MODIFY_PART_TYPE_TITLE = "MODIFY_PART_TYPE_TITLE";
@RBEntry("New Type")
public static final String NEW_TYPE = "NEW_TYPE";
@RBEntry("No Modification")
public static final String MODIFY_PART_TYPE_MSG1 = "MODIFY_PART_TYPE_MSG1";
@RBEntry("successms, oldType:{0}, newType:{1}")
public static final String MODIFY_PART_TYPE_MSG2 = "MODIFY_PART_TYPE_MSG2";
@RBEntry("Failure, Please try again.")
public static final String MODIFY_PART_TYPE_MSG3 = "MODIFY_PART_TYPE_MSG3";
}
4、编写按钮点击后弹出的JSP页面和Step页面。
第一个jsp /netmarkets/jsp/ext/aaa/part/modifyPartType.jsp
<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/components" prefix="wca"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/fmt" prefix="fmt"%>
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf"%>
<%@ include file="/netmarkets/jsp/components/includeWizBean.jspf"%>
<fmt:setLocale value