Insert a Custom Picker in Pdmlink Wizard

barristerbedroomSoftware and s/w Development

Oct 28, 2013 (3 years and 5 months ago)

1,368 views


saracco@stnet.it

Insert a Custom Pi cker in Pdmlink

Wi zard

1

Insert a Custom

Picker
in
Pdmlink
Wizard

Use Case
:
user

wants to get some attributes values from a
n
external

RDBMS table while creating a new
object in pdmlink.

A typical example should be getting
customer_code

and
company_name

(normally those
values reside in ERP table)
in creating a Problem Report.



figure
1
:
In this example
:

a new Problem Report is

going to be created with a

wizard (left window)



attributes [CODICE
and Requester]

are fed by the picker (right window), the picker searchs all records where CODICE starts with ‘10’ in
external RDBMS table, the picked row values are returned to the calli
ng wizard step


Solution
:



Define a new attribute
[ie.
customer_code

]
for a Problem report SubType



Develop a

custom
pi
cker
for fetching data
[
ie.
c
ustomer
_c
ode
,
company_name
]



Creating a DataUtility for new attribute
. This class is the most important
piece, it drives and
manages almost the underline component.



Creating a table definition for display
ing
data



Creating jsp pages: for searching data and picked data



Creating an InfoEngine task who will execute the “real” search



Creating a
NmObjectUtility

fo
r manage a not persistable object (the rows data returned)

C
ustom picker

development

Becouse pdmlink user interface use
s

the
object type

to “resolve

&
build


all necessary components we will
use as reference object type the class being creating


here a subtype of the problem report (ie.
WCTYPE|wt.change2.WTChangeIssue|locale.
org
.CLAIM
) , but you are free to use whatever object you
prefer.


First of all we def
ine a custom wizard step for display only those wanted attributes for our object subtype
see
A1: Custom wizard attribute step

in Appendix.

1

2

3


saracco@stnet.it

Insert a Custom Pi cker in Pdmlink

Wi zard

2

Step 1:
Search fields definition

In this step we define wich attributes we want

to search from the external table

(
see

f
igure

).
Insert
following line in
<
W
INDCHILL>
\
codebase
\
pickerAttributes.xml
:

<ComponentID id="
projDBPickerId
">


<ObjectType id="
WCTYPE|wt.change2.WTChangeIssue|locale.org.CLAIM
">



<SearchCriteriaAttributes>




<Attributes>





<Name>
CODICE
</Name>





<DisplayName>
Codice Cliente
</DisplayName>





<IsSearchable>true</IsSearchable>




</Attributes>




<Attributes>





<Name>
DESCRIZIONE
</Name>





<DisplayName>
Ragione Soc
iale
</DisplayName>





<IsSearchable>true</IsSearchable>




</Attributes>



</SearchCriteriaAttributes>


</ObjectType>

</ComponentID>



f
igure

2
:
picker input



attribute
s

are defined in

pickerAttributes.xml

for the
componentID =
projDBPickerId



Note:
this id will used in DataUtility class


Step

2:
Define the table view for resulting data

1.

Write a new class (ie.

DbPickerResultView
)
to define the display of
table results
.
(
see

Append
ix

A
2
)
.
This table view will be shown after clicking the search button
(
see

figure
1
)


2.

C
onfigure this table vew

in

SearchResultsTable.properties.xconf

in
<WINDCHILL>
\
cod
ebase
\
com
\
ptc
\
netmarkets
\
search

copying following statement in the tag

<
Service context="default" name="com.ptc.core.htmlcomp.tableview.
ConfigurableTable
">

<Option
serviceClass="ext.softech.search.views.DbPickerResultView"
requestor="java.lang.Object" selector="
CLAIM.PickerSearchView
"/>


Note
:
This tabe view will be storeb in DB,
you must

delete the correspon
d
ing rows in tables: TableViewDescriptor e ActiveViewLink
if any
modifications occur to this class.

Step

3:
Searching data

1.

Write a jsp page to execute the search
(
i.e.
projDataFetcher.jsp
)

(
Appendix

A3
)
, the “real” search
will be done by an Info*Engine task. Copying th
e
file in
<WINDCHILL>
\
codebase
\
netmarkets
\
jsp
\
search
\



saracco@stnet.it

Insert a Custom Pi cker in Pdmlink

Wi zard

3

2.

Write a I*E Task
Search
-
ProjDbResults.xml
(Appendix
A4
)


copy this file in

<WINDCHILL>
\
tasks
\
ext
\
search
\
searchExtDbResults.xml


3.

Write a Delegate
SelectDbTableDelegate
.java

that will read the input parameters from the task
,
execute the SELECT

and generate the output grou
p with data for desired columns

(
Appendix

A5
).
Copy (compile) this file in

the path
<Windchill>
\
DevModules
\
WindchillAdapter
\
src
\
com
\
ptc
\
core
\
adapter
\
server
\
impl


4.

Configure Task Delegate


Copy following line in
<WINDCHILL>
\
codebase
\
wt.adapter.delegates.properties.xconf

<Property default="
com.ptc.core.adapter.server.impl.SelectDbTableDelegate"
name="SELECTDBTABLE.WCTYPE|java.lang.Object"/>


Step 4
: Configurare DataUtility per il campo da recuperare

1.

Write DataUtility (ie.
A6: DataUtility
)t
his step it is th
e most important
because

this class will define
all links with all preceding steps
(or components)

as
:



Reference to the object type


to retrieve table view

PickerRenderConfigs.setDefaultPickerProperty(map, PickerRenderConfigs.OBJECT_TYPE,
"WCTYPE|wt.chang
e2.WTChangeIssue|locale.buonaparte51.CLAIM");




Reference to data

fetcher jsp page

PickerRenderConfigs.setDefaultPickerProperty(map, "searchResultsFetcherURL",
"/netmarkets/jsp/search/projDataFetcher.jsp");




Reference to jsp
page to

manage picked row (table

record)

PickerRenderConfigs.setDefaultPickerProperty(map,
PickerRenderConfigs.PICKED_DATAFETCHER,
"/Windchill/netmarkets/jsp/search/projDbPickedData.jsp");




Reference to attributes (componentID)

PickerRenderConfigs.setDefaultPickerProperty(map,
PickerRenderConfigs.COMPONENT_ID, "projDBPickerId");




Reference to javascript function to handle picked row and put values in calling form (wizard
step)

PickerRenderConfigs.setDefaultPickerProperty(map, "pickerCallback", "myCallback");

The javascript funct
ion should be defined inside wizard step (for custom step wizard) or in
appropriated

position
for OOTB wizard step
.

2.

Register
DataUtility
in file

SearchResultsTable.properties.xconf in
<WINDCHILL>
\
codebase
\
com
\
ptc
\
netmarkets
\
search
\

in
side

tag <
Service context="default"
name=" com.ptc.core.components.descriptor.DataUtility">

adding following statement


saracco@stnet.it

Insert a Custom Pi cker in Pdmlink

Wi zard

4

<Option serviceClass="ext.softech.search.views.
PickerDataUtilityCodice
"


requestor="java.lang.Object"


selector="
PickerCodi
ceDU
"


cardinality="singleton"/>


The selector should be referenced inside custom
attribute
wizard

step

<jca:describePropertyPanel var="attributesTableDescriptor"









id="createReclamo"









mode="CREATE"









scope="request"









componentType="WIZARD_ATTRIBUTES_TABLE"









>


<jca:describeProperty id="number" inputFieldType="singleLine" />


<jca:describeProperty id="CODICE" inputFieldType="singleLine"
dataUtilityId="
PickerCodiceDU
" />


<jca:describeProperty id="name"
inputFieldType="singleLine" />


<jca:describeProperty id="Test" inputRequired="true"/>


<%
--

richiedente
--
%>


<jca:describeProperty id="requester" inputRequired="false"
inputFieldType="singleLine" >


</jca:describeProperty>




<jca:describeProperty id="de
scription" inputFieldType="multiLine" />


<jca:describeProperty id="needDate"/>

</jca:describePropertyPanel>

Or using OOTB wizard in type manager (create
new
layout for the attribute)

Step 5
:
NmObjectUtility

to handle non persistable object

Because our records do not belong to any pdmlink object we hav
e to write a class to handle tho
s
e

object
s
,
it means to provide a unique “oid” for ea
ch record found
.

1.

Write
NmObjectUtility

class

to handle

record
s (as
NmSimpleOid)

in
A
7

is provided
a
n example
. We
build the unique oid as [CODICE]@[DESCRIZIONE] so we can easily retrieve the values for all
attribute we want to feed (
CODICE

and
Requester

in our example)


2.

Registrer

the class
:
Inser
t in

file
SearchResultsTable.properties.xconf in
<WINDCHILL>
\
codebase
\
com
\
ptc
\
netmarkets
\
search
\

the
following statement

inside

tag
<Service
context="default" name="

com.ptc.core.components.descriptor.NmObjectUtility">

<Option serviceClass="ext.softech.search.views.
AnagraficaNmObject"



selector="
CLAIM.PickerSearchView
"




requestor="java.lang.Object"



cardinality="singleton"/>

Step 6:
Return picked data to calling wizard step

These page manage the picked row (it returns an jsonObjectString ), this string will

be used by our callback
javascrip
t function to
feed attributes value in the wizard form.



Write a

jsp

page

(
see
A8: projDbPickedData.jsp

)
-

co
py this file
in
\
Windchill
\
codebase
\
netmarkets
\
jsp
\
search
\

Test the
picker

To test the picker we choose to have a new wizard for creating the object type


saracco@stnet.it

Insert a Custom Pi cker in Pdmlink

Wi zard

5

D
efine new
wizard
for the object (using custom attribute wizard step)

<jca:wizard title="Nuovo Reclamo/Chiarimento"
buttonList="DefaultWizardButtonsWithSubmitPrompt"
form
ProcessorController="com.ptc.windchill.enterprise.change2.forms.controllers.ChangeItemFo
rmProcessorController" wizardSelectedOnly="true">



<jca:wizardStep action="setChangeContextWizStep" type="change"/>


<jca:wizardStep action="AttributiReclamo" type="pr
oblemReport"/>



<jca:wizardStep action="securityLabelStep" type="securityLabels"/>


<jca:wizardStep action="affectedEndItemsStep" type="change" />


<jca:wizardStep action="affectedDataStep" type="change" />


<jca:wizardStep action="attachments_step"
type="attachments" />

</jca:wizard>


D
efine a new action for objectType

(ie. custom
-
action.xml)

<objecttype name="problemReport" class="wt.change2.WTChangeIssue"
resourceBundle="com.ptc.windchill.enterprise.change2.changeManagementActionsRB">


<
action

name="
createCustomCLAIM
" uicomponent="CREATE_PROBLEMREPORT" ajax="component">


<description>Creazione reclamo con attributo ricercato su tabella RDBMS</description>


<label>Prototipo reclamo</label>



<command
class="com.ptc.windchi
ll.enterprise.change2.forms.processors.CreateProblemReportFormProcessor"
method="execute" windowType="popup"/>


<includeFilter name="restrictGuestMembers"/>


<includeFilter name="sandboxSharingValidationSimple"/>


</action>


<acti
on name="
AttributiReclamo
" afterVK="setAttributesWizStep"
id="defineItemAttributesWizStep" preloadWizardPage="false" required="true"
resourceBundle="com.ptc.core.ui.componentRB" afterJS="forceCodice">


<command url="netmarkets/jsp/problemReport/
cus
tomAttributesCLAIM
.jsp
"
windowType="wizard_step"/>


<label>Attributi</label>


</action>

</objecttype>

D
efine a new action model (ie.
custom
-
actionModels.xml
)

<model name="folderbrowser_toolbar_actions">


<description>Folder browser toolba
r actions menu for all Folders.</description>






<
action

name="
createCustomCLAIM
"



type="problemReport"/>

<model>


Propaga
te C
onfigurations

and Test Picker

1.

From a windchill shell execute <
xconfmanager

p
>
command

to propagate

the configuration
added
:



SearchResultsTable.properties.xconf



wt.adapter.delegates.properties.xconf


2.

Stop and Run windchill service




saracco@stnet.it

Insert a Custom Pi cker in Pdmlink

Wi zard

6

Appendix


THIS SECTION IT IS INTENTIONALLY BLANK