Day 3 Customization R1
Day 3 Customization R1
Day 03
1
Takeaway
At the end of this session you should be able to
Data Utilities
UI Validation
Wizards
Pickers
Configurable Links
22
Data Utilities
Data utilities are java classes that can be used for customizations that cannot be accomplished
using the available configuration points.
A data utility is used to get the data and meta-data of an attribute and create the UI component
which will be used to render the attribute in the UI. If the data returned by a core API is not
sufficient for creating the UI component, data utilities can be used to augment this data with
additional information. The additional information can be fetched by an additional query, a call to a
service, or whatever else you can get at via Java code.
The OOTB implementations of data utilities provide the behavior defined for Windchill OOTB
applications in accordance with Windchill UI standards.
You can configure a data utility for any attribute id.
33
GUI Components
This component will generally be constructed in the Method Server and then returned to the Servlet Container for rendering.
The GUI Component interface has one method that needs to be implemented:
public void draw (Writer out, RenderingContext renderContext) throws RenderingException;
It just needs to be understand, we will not touch OOTB function.
44
Implementation : Create Custom DataUtility Class
The data utility interface (com.ptc.core.components.descriptor.DataUtility) has three core methods:
The getDataValue method gets the value that should be placed within a particular table cell. Typically, the object that
is returned by this method should be an instance of GUIComponent. This interface has been retrofitted with NmString,
NmDate.
Object getDataValue(String component_id, Object datum, ModelContext mc) throws WTException;
The setModelData method enables the data utility to prefetch data for all the row objects for a particular column that
will be rendered. The method is called before getDataValue is called for any row, and is supplied with a List of all the
objects that will be processed.
void setModelData(String component_id, List objects, ModelContext mc) throws WTException;
The getLabel method enables the data utility to populate the descriptor with the correct label. There is a default
implementation in the AbstractDataUtility for getting a label from a common UI rbinfo file.
String getLabel(String component_id, ModelContext mc) throws WTException;
When using DataUtility, we have to use an abstract super class named AbstractDataUtility generally.
AbstractDataUtility is the child class of DataUtility.
55
Implementation : Sample DataUtility Class
public class CSCLifeCycleDataUtility extends AbstractDataUtility {
public Object getDataValue(String component_id, Object datum, ModelContext mc) throws WTException {
...
// Initialize ComboBox UI Component
ComboBox comboBox = new ComboBox();
comboBox.setName(component_id);
comboBox.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc));
…
ComponentMode mode = mc.getDescriptorMode();
String selectClassName = CreateAndEditWizBean.getTypeNameFromTypePicker(mc.getNmCommandBean());
…
Class aClass = Class.forName(selectClassName);
Vector vecLCTemplate = LifeCycleHelper.service.findCandidateTemplates(aClass,
mc.getNmCommandBean().getContainerRef());
for(int k=0; k<vecLCTemplate.size(); k++){
lcTemplate = (LifeCycleTemplate)((LifeCycleTemplateReference)vecLCTemplate.get(k)).getObject();
requstValue.add(lcTemplate.getName());
displayValue.add(lcTemplate.getName());
}
…
comboBox.setInternalValues(requstValue); //Key
comboBox.setValues(displayValue); // display
return comboBox;
}
private String getValue(String component_id, Object datum, ModelContext mc) throws WTException {
return UtilityHelper.getStringValue(component_id, datum, mc);
}
66
Implementation : Register Data Utility
Customized data utility class cannot be used directly on GUI Component. All GUI Components can
read service identification which is registered in Method Server services cache – generally registered in
“service.properties.”
Example: service.properties.xconf
<Service name="com.ptc.core.components.descriptor.DataUtility">
<Option
serviceClass="com.ptc.windchill.enterprise.classification.dataUtilities.DefaultClfPickerUtil ity"
requestor="java.lang.Object"
selector="classification.id"
cardinality="duplicate"/>
</Service>
77
Implementation : How to Set Data Utility on the GUI Component
GUI Component will be rendered by using several methodologies, so we have to understand how to
set custom data utility on each of GUI components.
MVC designed – all MVC component has default function for setting data utility. (Tree/Table/Attribute Panel)
JcaTreeConfig treeConfig = (JcaTreeConfig) factory.newTreeConfig();
ColumnConfig col = factory.newColumnConfig("number", true);
col.setDataUtilityId(“registered.data.utility.id.in.services");
treeConfig.addComponent(col);
88
Exercise 1 — Change Part Attribute Field (Layout)
On the info page of WTPart, primary attribute group has a name value. We will
change the value using DataUtility. After gluing DataUtility, part name field will be
shown name and number.
99
Exercise 1 — Create Data Utility
1 . Create DataUtility class
This class will get instance object from parameter for change label, and reset value using “Label” Component.
– Class name: CSCPartNameDataUtility
– Super Class: AbstractDataUtility
– Override: getDataValue
package ext.training.datautility;
Import wt.part.WTPart;
public class TrainPartNameDataUtility extends AbstractDataUtility {
@Override
public Object getDataValue(String component_id, Object datum, ModelContext mc) throws WTException {
Label nameComponent = new Label("");
nameComponent.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc));
nameComponent.setId(component_id);
WTPart part = (WTPart)datum;
nameComponent.setValue(part.getName() + " ( " + part.getNumber() + " )" );
return nameComponent;
}
}
10
10
Register Data Utility on Method Server Service
2. Update “service.properties.xconf” for registering custom data utility
Open “$WT_HOME/codebase/service.properties.xconf” and add the following block at the end of the file. Actually, it must be
located in the front of the “</Configuration>” tag.
<Service context="default" name="com.ptc.core.components.descriptor.DataUtility">
<Option serviceClass="ext.training.datautility.TrainPartNameDataUtility"
selector=“myPartNameDataUtility"
requestor="java.lang.Object" DataUtility class
cardinality="duplicate" /> DataUtility Id
</Service>
3. Register service on system configuration
Open Windchill shell and execute “xconfmanger –p”
11
11
Set Data Utility ID on Part Primary Attributes Layout
4. Open type manager and select part object. Finally, set data utility ID on name attribute
A. Open Site > Utilities > Type and Attribute Management
B. Select Manage Types tab and select Part object
C. Select action menu on part detail page and select Edit menu
D. Select Layout tab and select “Primary Attributes Info Page Layout” of Layouts menu.
E. Select detail button of name attributes
F. Set data utility ID named “myPartNameDataUtility” on the editing window of name
12
12
Test Result
6. Restart Method Server and Test
Open part information and check name attribute
13
13
UI Validation
The UI Component Validation Service was created to give Windchill clients a central service to call to perform validation for
actions and other components appearing in the Windchill UI.
The following categories of validation are available :
Pre-Validation
The first category of UI Validation is referred to as Pre-Validation. This is the category of validation that most people will first associate with UI
Validation. Pre- Validation is a term that describes the process of determining whether or not a UI Component should be available in the UI. An
example of Pre-Validation would be disabling the “check-in” action for an object that is not checked-out. Pre-Validation can be applied to both actions
and attributes in the UI. Of the three types of UI Validation, this type is the most often-used.
Post-Select Validation
A second category of UI Validation is Post-Select Validation. Post-Select Validation is the process of determining whether or not an action should be
allowed to proceed once it is selected in the UI. An example of post-select validation would be displaying an error message and not allowing the
checkout to proceed if a user tries to perform a checkout on an object that is already checked out. Post-Select Validation applies only to actions.
Post-Submit Validation
The final category of UI Validation is Post-Submit Validation. This type of validation is used exclusively in wizards or other forms where users enter
data. An example of Post-Submit Validation would be stopping a user from moving to the next step in a wizard because the data they’ve entered in
the current step is invalid. Post-Submit Validation applies only to wizard steps and wizard submissions.
14
14
UI Validation
To create a Validator, you’ll need to create a subclass of com.ptc.core.ui.validation.
DefaultUIComponentValidator.java. There are currently five public methods defined in
DefaultUIComponentValidator. java which can be overriden:
performFullPreValidation()
performLimitedPreValidation()
validateFormSubmission()
validateSelectedAction()
validateSelectedMultiSelectAction()
For those methods which you do not override, the default behavior (always enable/ permit) will be
inherited from the DefaultUIComponentValidator class Validator classes must be registered via
xconfmanager in service.properties. The validation service uses the service entries to find the correct
Validator for a specific validation key, (action). The format of the entry should be as shown below :
wt.services/rsc/default/com.ptc.core.ui.UIComponentValidator/<validationKey>/
null/0=com.ptc.my.validators.MyValidator
15
15
UI Validation
validateSelectedAction
This method is called by a client application to determine if an action selected by the user from the UI can be performed. For example, if a user selects
the Revise action from the UI, the validateSelectedAction method is used to determine if the Revise action should proceed.
public UIValidationResult validateSelectedAction (String validationKey, UIValidationCriteria validationCriteria, Locale locale)
validationKey
Identifies the action being validated as defined in actions.xml
UIValidationCriteria
Bean to hold the data that has been set by the client and passed to the validation service The return type is UIValidationResult whose attributes include a
status field indicating if the requested action is permitted. UIValidationResult should be set up as shown in the code snippet below
UIValidationStatus status = null;
UIValidationFeedbackMsg msg = null;
if (we can allow this action to proceed){status = UIValidationStatus.PERMITTED; }
else{ status = UIValidationStatus.DENIED;
msg = new UIValidationMsg(localized text, UIValidationMsgType.INFO) }
return new UIValidationResult(a_key, contextObject, status, msg);
16
16
UI Validation
validateSelectedMultiSelectAction
This method is similar to the validateSelectedAction method, but in this case a different object, UIValidationResultSet is returned.
public UIValidationResultSet validateSelectedMultiSelectAction (String validationKey,UIValidationCriteria validationCriteria, Locale locale)
validateFormSubmission
This method is called by the client to validate user entered form data.
public UIValidationResult validateFormSubmission (String validationKey, UIValidationCriteria validationCriteria, Locale locale)
performFullPreValidation
This method is called by the client to check if an action should be displayed in the UI
public UIValidationResult performFullPreValidation (String validationKey, UIValidationCriteria validationCriteria, Locale locale)
performLimitedPreValidation
This method is called by the client to check if an action should be displayed in the UI, behaves in a similar way as
performFullPreValidation. The intention is that the limited validation is less thorough than full validation, but will perform quicker
public UIValidationResult performLimitedPreValidation (String validationKey, UIValidationCriteria validationCriteria, Locale locale)
17
17
Exercise 2
A form validator is required to check the value of the NAME attribute when creating
a new Part.Yhe value entered should be checked to ensure that the name does not
not contain the "!" character
1. Check if any validator is already implemented against the "New Part" action
2. Create validator class, ext.train.part.validators.NameValidator
3. Implment a custom methods to extract name field from form data and validate
4. Register the validator
18
18
Exercise 2 - Code
package com.ptc.training.mvc.validator;
import com.ptc.core.ui.validation.UIComponentValidator;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationResult;
import com.ptc.core.ui.validation.UIValidationResultSet;
import com.ptc.core.ui.validation.UIValidationStatus;
import com.ptc.core.ui.validation.UIValidationFeedbackMsg;
import java.util.*;
import com.ptc.core.ui.resources.FeedbackType;
import java.util.Locale;
import org.apache.log4j.Logger;
import wt.inf.container.WTContainerHelper;
import wt.log4j.LogR;
import wt.preference.PreferenceClient;
import wt.util.WTException;
import com.ptc.windchill.enterprise.part.validators.CreatePartActionValidator;
public class partNameValidator extends CreatePartActionValidator implements UIComponentValidator {
private static final Logger log = LogR.getLogger(partNameValidator.class.getName());
19
19
Exercise 2 - Code
@Override
public UIValidationResult validateFormSubmission(UIValidationKey validationKey,UIValidationCriteria validationCriteria, Locale locale) throws WTException {
UIValidationResult defaultResult = super.validateFormSubmission(validationKey,validationCriteria,locale);
System.out.println("validationCriteria====> :: "+validationCriteria);
UIValidationStatus defaultStatus = defaultResult.getStatus();
System.out.println("defaultStatus.getStringValue====> :: "+ defaultStatus.getStringValue());
if(!(defaultStatus.getStringValue().equals("com.ptc.core.ui.validation.UIValidationStatus.PERMITTED")))
return defaultResult;
UIValidationStatus status = null;
UIValidationFeedbackMsg feedbackMsg = null;
String SuppliedName = getNameFromForm(validationCriteria);
System.out.println("SuppliedName====> :: "+SuppliedName);
if(validName(SuppliedName)){
status = UIValidationStatus.PERMITTED;
}else{
status = UIValidationStatus.DENIED;
feedbackMsg = UIValidationFeedbackMsg.newInstance("Name Contains Invalid Character",FeedbackType.ERROR);
}
return UIValidationResult.newInstance(validationKey,status,feedbackMsg);
}
20
20
Exercise 2 - Code
private String getNameFromForm(UIValidationCriteria validationCriteria) throws WTException {
String name = null;
Map fromDataMap = validationCriteria.getText();
Iterator it = fromDataMap.keySet().iterator();
while(it.hasNext()){
String key = (String)it.next();
System.out.println("key====> :: "+key);
if(key.contains("MBA|name")){
name = (String)fromDataMap.get(key);
}
}
System.out.println("getNameFromForm====> :: "+name);
return name;
}
21
21
Exercise 2 – Compile and Register
ant -f bin/tools.xml class -Dclass.includes=partNameValidator.java -Dclass.source=%wt_home%/src/com/ptc/training/mvc/validator
customServices.xconf
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Configuration
SYSTEM "xconf.dtd">
<Configuration>
<Service context="default" name="com.ptc.core.ui.validation.UIComponentValidator">
<Option serviceClass="com.ptc.training.mvc.validator.partNameValidator"
requestor="null"
selector="createPartWizard"
cardinality="duplicate"
targetFile="codebase/service.properties"
/>
</Service>
</Configuration>
xconfmanager -i %wt_home%/codebase/com/ptc/training/customServices.xconf
xconfmanager –p
22
22
Wizard
Wizards are popup windows that are used to
guide you step by step through the process of
creating an object, or performing an operation
on an object. A wizard is a user interface
consisting of a sequence of steps that lead the
user through a specific task one step at a time,
the user clicks next to move through the steps.
All wizard JSP pages must be located at
“$WT_HOME/codebase/netmarkets/jsp”
because wizard is controlled and calls several
EXT-JS functions and the JavaScript located on
the netmarkets directory. (IMPORTANT)
23
23
Architecture of Wizard
Base Wizard
• <%@ taglib prefix="jca" uri="http://www.ptc.com/windchill/taglib/components"%>
Tag declaration is required for using the JCA component. (Required)
• <%@ include file="/netmarkets/jsp/components/beginWizard.jspf"%>
• <%@ include file="/netmarkets/jsp/components/includeWizBean.jspf"%>
It is similar to “begin.jspf” of the general JCA page, but you have to use the above JSPF
for wizard.
• %@include file="/netmarkets/jsp/util/end.jspf"%
If it includes the latest file, it is the same JSPF with a general JCA declaration.
24
24
Architecture of Wizard
After completing basic environment configuration, you should design a detailed wizard page which includes wizard page design and
step design. The following are details of basic understanding of wizard .
1. First of all, you have to design all steps on the base wizard and decide which wizard steps should be called JSPs.
2. Basically all step pages will be loaded on the session when loading basic wizard page. It seems like all step pages
include pages of basic wizard, although all step pages have independent JSP pages. When loading wizard page, if one
step page has an error, the system will not be able to load all wizard pages.
3. If the step is to show the page base on the previous page’s information, we can set a preload flag using
“preloadWizardPage” on step configuration which exists on the “<action>” tag in “action.xml.” However, it can be used only
for one time loading. After loading this page, it can’t be reloaded although you can return to the previous page and
change information.
4. Each wizard step is an independent JCA page.
5. Each wizard step configuration is set on “action.xml.” Base wizard will just call the action name.
25
25
Architecture of Wizard
Generally wizard form process will be extended from the “DefaultObjectFormProcess” class.
26
26
Exercise 3 — Creating a Simple Wizard
Design of Wizard Customization
Add a new toolbar button for calling the wizard. The button
also includes FormProcessor. (Add one action and modify
the toolbar action.)
Create one wizard page (JSP page).
Create two step pages (JSP or MVC page).
Add two actions for step page (add actions) – because
wizard page calls action name for adding step page on
wizard.
Customization Action
1. Add action for button.
2. Add action for step.
3. Create Resource Bundle.
4. Modify folder toolbar actionModel.
5. Create wizard body JSP.
6. Create wizard step MVC & JSP.
7. Create Form Processor.
27
27
Configure Step and Base Wizard
1. Design actions for step and button
On the wizard configuration, you have to set the execution class. And you also have to take an action for each
step, and configure which JSP or MVC page needs to call from step action.
$WT_HOME/codebase/config/actions/custom-actions.xml
• <action name="wizardSamples”>
– Button action for calling wizard. This action should be set for calling back form processor.
$WT_HOME/codebase/config/actions/custom-actionModels.xml
<model name="folderbrowser_toolbar_actions">
<description>Folder browser toolbar actions menu for all Folders.</description>
<action name="wizardSamples" type="cscwizard" shortcut="true"/>
<action name="separator" type="separator"/>
<submodel name="folderbrowser_toolbar_open_submenu" />
<action name="separator" type="separator" />
<submodel name="folderbrowser_toolbar_new_submenu" />
<action name="separator" type="separator" />
<action name="list_cut" type="object" />
……
</model>
Copy the whole block named “folderbrowser_toolbar_actions” from “FolderManagement-actionModels.xml”
Add custom action on the folder browser toolbar for calling the wizard.
<action name=“wizardSamples” type=“cscwizard” shortcut=“true”/>
<action name=“seperator” type=“seperator”/>
Don’t touch other existing actions.
29
29
Create Wizard Page
3. Create wizard page
The wizard page includes step page configuration, and also the wizard page and the step page will be merged on a same one page
internally. So if you have constants or whole environment, you can set those on wizard page design. The following is just a simple
wizard source. If you want to add more complexity, you can make your source code. However, you should keep this format at least.
$WT_HOME/codebase/netmarkets/jsp/csc/wizardSample.jsp
<%@ taglib prefix="jca" uri="http://www.ptc.com/windchill/taglib/components"%>
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf"%>
<%@ include file="/netmarkets/jsp/components/includeWizBean.jspf"%>
30
30
Create a Wizard Step
4. Create a wizard step
This sample has two wizard steps. One will call MVC. Another will call a JSP page. In action configuration, we already set “netmarkets.project.list.table.” It
is OOTB MVC function, so it doesn’t need to create a new MVC. If you want to add your MVC in the step, you have to design and create for your step.
$WT_HOME/codebase/config/actions/custom-actios.xml
<action name="show_mvc_content">
<component windowType="wizard_step" name=“netmarkets.project.list.table"/>
</action>
It is OOTB. No need
<action name="show_jsp_content" preloadWizardPage="false"> new create
<command windowType="wizard_step" url="netmarkets/jsp/csc/showJspContent.jsp"/>
</action>
$WT_HOME/codebase/netmarkets/jsp/csc/showJspContent.jsp
<%@ taglib prefix="jca" uri="http://www.ptc.com/windchill/taglib/components"%>
<%@ include file="/netmarkets/jsp/components/beginWizard.jspf" %>
<%@ include file="/netmarkets/jsp/components/includeWizBean.jspf" %>
<%@include file="/netmarkets/jsp/util/end.jspf"%>
Note: Although a step page is included in the wizard body, the step also has same architecture like a wizard body.
31
31
Create a Resource Bundle
5. Create a Resource Bundle
We set the custom resource bundle for displaying action name, so we have to make a resource bundle file.
$WT_HOME/codebase/config/actions/custom-actions.xml
<objecttype name="cscwizard" class="" resourceBundle="ext.csc.training.resource.CSCTrainingRB">
$WT_HOME/codebase/ext/csc/training/resource/CSCTrainingRB.java
package ext.csc.training.resource;
import wt.util.resource.RBComment;
import wt.util.resource.RBEntry;
import wt.util.resource.RBUUID;
import wt.util.resource.WTListResourceBundle;
@RBUUID("ext.csc.training.resource.CSCTrainingRB")
public final class CSCTrainingRB extends WTListResourceBundle {
@RBEntry("Wizard Sample")
public static final String PRIVATE_CONSTANT_7 = "cscwizard.wizardSamples.description";
@RBEntry("Wizard-current_step.gif")
public static final String PRIVATE_CONSTANT_8 = "cscwizard.wizardSamples.icon“;
@RBEntry("Show MVC Content")
public static final String PRIVATE_CONSTANT_9 = "cscwizard.show_mvc_content.description";
@RBEntry("Show JSP Content")
public static final String PRIVATE_CONSTANT_10 = "cscwizard.show_jsp_content.description";
}
32
32
Test Wizard
6. Restart the Service and check the result.
33
33
Picker
1. Picker is not exactly customization. It is mostly about configuration.
2. Windchill core has several picker components. You just choose a usable picker for correct requirement. (If you
want to make a special picker component, it is a very complex customization. If possible, avoid that
customization.)
3. The following is the readied system component generally used.
User Picker
Organization Picker
Context Picker
Item Picker
Type Picker
Participant Picker
34
34
User Picker
<wctags:userPicker id="testUserPicker" label="MyUserPicker"/>
The user picker is used when you have a requirement to select specific user(s) depending upon certain criteria and use them in
your application. Typical use case could be that you may want to find parts which are created by a certain user. In this case, you
can have a user picker and then through this you can select the user and pass it onto the search criteria to perform search for
parts.
35
35
Organization Picker
<wctags:organizationPicker id="orgPicker" label="MyOrgPicker"/>
The organization picker is used when you have a requirement to select specific organization(s) depending upon certain criteria and use
them in your application. Typical use case could be that you may want to find parts that are available in a particular organization. In this
case, you can have an organization picker and then through this you can select the organization and pass it onto the search criteria to
perform search for parts.
36
36
Context Picker
<wctags:contextPicker id="contextPicker" label="MyContextPicker"
pickerTitle="ContextPicker" />
The context picker is used when you have a requirement to perform an operation that is based on a certain context.
37
37
Item Picker
<wctags:itemPicker id="itemPicker" label="MyItemPicker" pickerTitle="ItemPicker"/>
The item picker is used when you have a requirement to select specific business object(s) depending upon certain criteria and use
them in your application.
38
38
Type Picker
Type Picker Common Component is to be used either for display or for assignment of type-able items. For example, in a search application to select
the type of objects that you are interested to do a search on or in a create application to create an item of a specific type. It can be used to display the
type in case of edit or view applications. The component can be used in the context/mode of CREATE, EDIT, SEARCH, or VIEW.
39
39
Format of Type Picker
Type Picker has several types of format like the following: Tree Type, Table Type, and Drop-Down
40
40
Participant Picker
The current way of picking of participants is limited to Users and Groups and is not consistent across Windchill. The new Participant Picker Common
Component gives a consistent behavior across Windchill. Participant Picker gives you the ability to search Participants of type User, Group, and
Organization. It provides a wide variety of search scope criteria which can be used to narrow down the search.
<jca:participantPickeractionClass="com.ptc.netmarkets.principal.CustomPrincipalCommands" actionMethod="addPrincipal"
participantType="<%= PrincipalBean.GROUP %>"> > </jca:participantPicker>
41
41
Item Master Picker
Item Master picker just tries to find the mastered object.
42
42
Picker Process
43
43
Exercise 4 — Item Picker
Design of Item Picker
Item Picker can be designed by the customer in cases
such as:
Search Criteria
Target Search Object
Other pickers are designed by the system, so you just call
target picker using tags.
44
44
Exercise 4 — Item Picker
Create a Search Criteria Set – Item Picker
Before you create a picker pop-up window, you should set search attribute set.
The Set file is located in “$WT_HOME/codebase” and the file name is “pickerAttributes.xml.”
We will use the following sample for searching WTPart, so the objectType is set as “wt.part.WTPart.”
The attribute name should be used for object’s model or IBA logical name. The name can be checked in the Property Report.
Each Display name is registered in ResourceBundle, so the file name is the bundle’s key.
45
45
Exercise 4 — Item Picker
Create a Picker Page
Previously you made a picker component, so you will make the picker base (parent page) using this component.
Creating a Picker base (parent page) is same as creating a JCA page, so you should set and include all taglib.
Additionally, you should set “wctags” taglib.
46
46
Exercise 4 — Item Picker
Previously you made picker component, so you will make the picker base (parent page) using this component.
Picker base (parent page) is of same architecture as a JCA page, so you should set and include all taglib.
Additionally, you should set “wctags” taglib.
47
47
Exercise 4 — Item Picker
Picker Resource Bundle
The resource bundle is located at “$WT_HOME/src/com/ptc/windchill/enterprise/search/client.” Resource Bundle file name is “searchClientResource.java.”
Copy all java codes to eclipse compiled directory.
If you are not using the existing locale, add the locale java code which is copied from “searchClientResource.java.”
Finally add custom resource on java code.
package com.ptc.windchill.enterprise.search.client;
import wt.util.resource.*;
@RBUUID("com.ptc.windchill.enterprise.search.client.searchClientResource")
public final class searchClientResource extends WTListResourceBundle {
…….
@RBEntry("Custom Number")
@RBComment("Custom Number")
public static final String CUSTOM_NUMBER_LABEL = "CUSTOM_NUMBER_LABEL";
@RBEntry("Custom Name:")
@RBComment("Custom Name")
public static final String CUSTOM_NAME_LABEL = "CUSTOM_NAME_LABEL";
}
48
48
Exercise 4 — Item Picker
Picker Callback Function
The previous JSP page should include the JavaScript function for a picker callback. The picker pop-up page will return to parent page’s JS function about
selected object information. The picker will call the function when you create the picker tag within pickerCallBack’s name.
<script>
function partPickerCallback (objects, pickerID)
{
document.getElementById(pickerID
+"$label$").setAttribute("value",objects.pickedObject[0].name);
document.getElementById(pickerID
+"$label$___old").setAttribute("value",objects.pickedObject[0].name);
}
</script>
<wctags:itemPicker id="cscPickerForPart" label="Custom Part Picker"
pickerTitle="Demo Part Search" showVersion="false"
objectType="wt.part.WTPart" showTypePicker="false"
componentId="cscPartPicker" pickerCallback="partPickerCallback“
/>
49
49
Exercise 4 — Item Picker
result
50
50
Configurable Link
Special link types, known as configurable links, are provided which can be used to
configure and display additional relationship tables on document and part
information pages. JSP files have been provided to allow sites to implement and
display these configurable link tables. The tables then display in the navigation link
menus on the information page.
An example has been provided out-of-the-box for each of the configurable link
types, including tables for both the parent type and child type information pages.
The following files are delivered for the example:
<Windchill>/loadfiles/configurableLinks/ConfigurableLinkExamples.xml
The load file loads both the link types and the association constraints
51
51
Installing the Configurable Links Example
Use the following procedure to install the configurable links example.
1. Open a windchill shell.
2. Enter the following command:
xconfmanager -i
<Windchill>/codebase/com/ptc/windchill/enterprise/ConfigurableLinkExamples.xconf -p
3. Restart your method server.
4. Load the loadfile:
windchill wt.load.LoadFromFile -d
<Windchill>/loadfiles/configurableLinks/ConfigurableLinkExamples.xml
52
52