配置选取器
解决方案
编写自定义 JSP 页面,并使用项选取器标记来显示选取器。使用 itemPicker 标记上的参数配置要搜索的对象类型和容器。
必备知识
要实现此目标,需要了解以下内容:
涉及 HTML 表单、JSP、XML 的基本开发。
选取器公用组件
表格公用组件
视图创建
过程 - 启动选取器并定义要搜索的对象类型
通过调用 itemPicker 标记,可以从 JSP 启动选取器:
<wctags:itemPicker id="customized_item_picker" objectType="WCTYPE|
wt.part.WTPart|org.r_and_d.mypart" componentId="customizedItemPickerForSoftPart "/>
objectType 参数指示搜索应限制为 org.r_and_d_mypart 类型的对象。
Id 参数的值应为给定页面的唯一标识符。
componentId 参数的值为关键字,用于查找要在选取器中显示的搜索条件。
过程 - 定义要搜索的容器
要将搜索范围限制为特定容器中的对象,请使用选取器标记的 containerRef 参数。对于要搜索的容器,此参数的值应为一个或多个 WTContainerRef 对象的以逗号分隔的列表 (以字符串格式表示)。
容器的 WTContainerRef 可通过查询容器并为 WTContainerRef 对象中的每个容器获取 WTContainer 进行提取。
如果未提供 containerRef 参数,则将搜索所有容器。
<wctags: itemPicker id=" customized_item_picker”
objectType="WCTYPE|wt.part.WTPart|org.r_and_d.mypart"
containerRef=" OR: wt.pdmlink.PDMLinkProduct:33707”
componentId="customizedItemPickerForSoftPart" />
过程 - 自定义搜索结果表格视图
搜索结果表格使用表格公用组件,因此可通过创建新的表格视图来配置列显示。
首先需要创建用于定义表格视图的新 JCAConfigurableTable Java 类。
然后,在 *.properties.xconf 文件中创建服务特性条目,该文件可用于基于您选取的称为 "selector" 的标识符来查找表格视图类。例如,如果您的表格视图类为 CustomizedPartView,则服务特性条目可能如下所示:
<Service context="default"
name="com.ptc.core.htmlcomp.tableview.ConfigurableTable">
<Option
serviceClass="com.ptc.netmarkets.search.views.CustomizedPartView" requestor="java.lang.Object"
selector="wt.part.WTPart.customizedSearchView "/>
</Service>
最后,将 selector 传递给选取器标记 (如下所示),搜索结果表格将在此视图中呈现。
<wctags: itemPicker id=" customized_item_picker"
objectType="WCTYPE|wt.part.WTPart|org.r_and_d.mypart"
containerRef="<OR: wt.pdmlink.PDMLinkProduct:33707”
componentId="customizedItemPickerForSoftPart"
searchResultsViewId="wt.part.WTPart.customizedSearchView"/>
示例代码
<html>
<body>
<table>
<tr>
<%-- launching user picker--%>
<wctags:userPicker id="testUserPicker" label="MyUserPicker"
readOnlyPickerTextBox="false" editable="true" showSuggestion="true"
suggestMinChars="5" />
</tr>
<tr>
<%-- launching organization picker--%>
<wctags: organizationPicker id="orgPicker" label="MyOrgPicker"
readOnlyPickerTextBox="false" editable="true" showSuggestion="true"
suggestMinChars="3"/>
</tr>
<tr>
<%-- launching context picker--%>
<wctags: contextPicker id="contextPicker" label="MyContextPicker"
pickerTitle="ContextPicker" />
</tr>
<tr>
<%-- launching Item picker--%>
<wctags:itemPicker id="itemPicker" label="MyItemPicker"
pickerTitle="ItemPicker"/>
</tr>
<tr>
<%-- launching Item picker with exclude sub types and access
controller --%>
<wctags:itemPicker id="CustomizedItemPicker" label="CustomizedItemPicker"
pickerTitle="CustomizedItemPicker"excludeSubTypes="WCTYPE|wt.doc.WTDocument|
org.rnd.Minutes,WCTYPE|wt.doc.WTDocument|org.rnd.General"
customAccessController="com.ptc.windchill.
enterprise.search.server.LatestVersionAccessController"/>
</tr>
<tr>
<%-- launching Item Masterpicker--%>
<wctags:itemMasterPicker id="itemMasterPicker"
label="MyItemMasterPicker"/>
</tr>
<tr>
<%-- launching Item Masterpicker--%>
<wctags:genericPicker id="genericPicker"objectType="wt.part.WTPart"label
="Part Picker using generic" />
</tr>
<tr>
<%-- launching Item Masterpicker--%>
<wctags:genericPicker id="viewPicker" objectType="wt.vc.views.View" label="
View Picker
using generic" pickerType="tree" />
</tr>
<tr>
<%-- launching Recently Visited Context Picker- Single Select--%>
<wctags:contextPicker id="containerTypeListSingleSelect" label="
Recently Visited Context Picker-
Single Select" pickerTitle="ContextPicker" showRecentlyUsed="true"
displayAttribute="containerInfo.name"/>
</tr>
<tr>
<%-- launching Recently Visited Context Picker- Multi Select--%>
<wctags:contextPicker id="containerTypeListMultiSelect" label="Recently
Visited Context Picker- Multi Select" pickerTitle="ContextPicker"
showRecentlyUsed="true" displayAttribute="containerInfo.name"
showMultiSelectRecentlyUsed="true"/>
</tr>
</table>
</body>
</html>
这对您有帮助吗?