User Picker Usage Example For Create Wizards User

  • Slides: 18
Download presentation
User Picker Usage Example For Create Wizards

User Picker Usage Example For Create Wizards

User Picker Usage • This presentation will show to use a “User Picker” in

User Picker Usage • This presentation will show to use a “User Picker” in the attributes table of a Create wizard. • The User Picker is the ootb picker, so no JSPs were written to search for and return a user object.

Model

Model

Main Create JSP <%@ taglib prefix="jca" uri="http: //www. ptc. com/windchill/taglib/components" %> <%@ taglib uri="http:

Main Create JSP <%@ taglib prefix="jca" uri="http: //www. ptc. com/windchill/taglib/components" %> <%@ taglib uri="http: //java. sun. com/jsp/jstl/core" prefix="c"%> <%@ include file="/netmarkets/jsp/components/begin. Wizard. jspf"%> <%@ include file="/netmarkets/jsp/components/include. Wiz. Bean. jspf"%> Contains the callback function for the picker. <script language='Java. Script' type="text/javascript" src='com/company/javascript/user. js' ></script> <jca: initialize. Item operation="${create. Bean. create}" base. Type. Name="com. company. test 2. My. Managed"/> <jca: wizard button. List="Default. Wizard. Buttons. No. Apply" title="Create My Managed"> <jca: wizard. Step action="set. Context. Wiz. Step" type="object"/> OOTB <%-- contains the type picker and the org picker --%> <jca: wizard. Step action="define. Item. Wiz. Step" label="Select Org" type="object"/> <jca: wizard. Step action="create. Managed. Set. Attributes. Wiz. Step" label="Set Attributes" type=“My. Managed"/> </jca: wizard> <%@ include file="/netmarkets/jsp/util/end. jspf"%> OOTB Custom

Custom Wizard Step JSP (1) <%@ taglib uri="http: //www. ptc. com/windchill/taglib/components" prefix="jca"%> <%@ taglib

Custom Wizard Step JSP (1) <%@ taglib uri="http: //www. ptc. com/windchill/taglib/components" prefix="jca"%> <%@ taglib uri="http: //java. sun. com/jsp/jstl/core" prefix="c"%> <%@ include file="/netmarkets/jsp/util/begin. jspf"%> <%@ include file="/netmarkets/jsp/components/create. Edit. UIText. jspf"%> <%@ include file="/netmarkets/jsp/components/include. Wiz. Bean. jspf"%> Standard Includes And taglibs <% Sets up create. Type String create. Type = "WCTYPE|com. company. test 2. My. Managed"; attribute request. set. Attribute("create. Type", create. Type); %> <% String user. Oid. Str = "", user. Name = ""; // set the default principal value to current logged in principal (this can be overridden if needed by the end user) wt. org. WTPrincipal curr. Principal = wt. session. Session. Helper. get. Principal(); if (curr. Principal != null) { user. Oid. Str = curr. Principal. get. Persist. Info(). get. Object. Identifier(). to. String(); Found in txt file user. Name = curr. Principal. get. Principal. Display. Identifier(); } & customized %> <c: set var="user. Name" value="<%=user. Name%>"/> <c: set var="user. UFID" value="<%=user. Oid. Str%>"/> <c: set var="user. Picker. Label" value="Author"/> <c: set var="user. Picker. Prop. Id" value="author"/> <c: set var="user. Picker. Id" value="author. Picker. Id"/> <c: set var="user. Hidden. Id" value="author. Picker"/> <c: set var="user. Input. Required" value="true"/> Codebase/company/jsp/components/user. Picker. Describe. Property. txt

Custom Wizard Step JSP (2) <%-- displays type and id attributes --%> <% Object

Custom Wizard Step JSP (2) <%-- displays type and id attributes --%> <% Object pref. Value = wt. preference. Preference. Helper. service. get. Value( "Display_Org. ID" , command. Bean. get. Container() , (wt. org. WTUser) wt. session. Session. Helper. get. Principal() ); %> <c: set var="display. Org" value="<%= pref. Value%>"/> OOTB <%-- Specifies my Form. Processor. Delegate for handling the Author attribute of my class --%> <input name="Form. Processor. Delegate" value="com. company. test 2. Author. Form. Processor. Delegate" type="hidden"> <jca: describe. Property. Panel var="attributes. Step. Read. Only. Panel" id="attributes. Step. Read. Only. Panel" scope="request" mode="VIEW"> OOTB <%@ include file="/netmarkets/jsp/components/set. Attributes. Read. Only. Properties. jspf"%> </jca: describe. Property. Panel> Defines the hidden form field for my Form. Processor. Delegate class to handle populating the “author” attribute when my object gets instantiated.

Custom Wizard Step JSP (3) <jca: describe. Attributes. Table var="attributes. Table. Descriptor" id="create. Set.

Custom Wizard Step JSP (3) <jca: describe. Attributes. Table var="attributes. Table. Descriptor" id="create. Set. Attributes" mode="CREATE" component. Type="WIZARD_ATTRIBUTES_TABLE" type="WCTYPE|com. company. test 2. My. Managed" label="${attributes. Table. Header}" scope="request"> Includes the User Picker property definition. <%-- Adds a htmlid which makes an id on the name textbox for use by the name defaulting javascript -%> <jca: describe. Property id="name" input. Required="true" html. Id="Name. Input. Id"/> <jca: describe. Property id="alternate. Name"/> <%@ include file="/company/jsp/components/user. Picker. Describe. Property. jspf"%> <jca: describe. Property id="description" input. Required="true"/> <jca: describe. Property id="ALL_SOFT_NON_CLASSIFICATION_SCHEMA_ATTRIBUTES"/> <jca: describe. Property id="folder. id"/> <jca: describe. Property id="life. Cycle. id"/> <jca: describe. Property id="team. Template. id"/> </jca: describe. Attributes. Table> <%-- renders data defined above --%> <%@ include file="/netmarkets/jsp/components/set. Attributes. Wiz. Step. jspf"%> <%@ include file="/netmarkets/jsp/util/end. jspf"%> OOTB

user. Picker. Describe. Property. jspf <jca: describe. Property id="${user. Picker. Prop. Id}" label="${user. Picker.

user. Picker. Describe. Property. jspf <jca: describe. Property id="${user. Picker. Prop. Id}" label="${user. Picker. Label}" data. Utility. Id="picker" input. Required="${user. Input. Required}"> <jca: set. Component. Property key="picker. Id" value="${user. Picker. Id}"/> <jca: set. Component. Property key="hidden. Id" value="${user. Hidden. Id}"/> <jca: set. Component. Property key="component. Id" value="user. Comp. Picker. Id"/> <jca: set. Component. Property key="object. Type" value="wt. org. WTUser"/> <jca: set. Component. Property key="picked. Attributes" value="full. Name, name"/> <jca: set. Component. Property key="default. Value" value="${user. Name}"/> <jca: set. Component. Property key="default. Hidden. Value" value="${user. UFID}"/> <jca: set. Component. Property key="read. Only. Picker. Text. Box" value="false" /> <jca: set. Component. Property key="picker. Callback" value="user. Picker. Call. Back"/> <jca: set. Component. Property key="show. Roles" value="false"/> <jca: set. Component. Property key="show. Suggestion" value="false"/> <jca: set. Component. Property key="suggest. Service. Key" value="user. Picker"/> </jca: describe. Property> This picker uses the variables set up on the previous slides. It uses the callback Javascript define in the user. js Javascript file.

user. js function user. Picker. Call. Back(objects, picker. ID, attr, display. Field. Id) {

user. js function user. Picker. Call. Back(objects, picker. ID, attr, display. Field. Id) { var picked. Objs = objects. picked. Object; if (picked. Objs != null) { var update. Hidden. Field = document. get. Elements. By. Name(picker. ID)[0]; var update. Display. Field = document. get. Elements. By. Name(display. Field. Id)[0]; for (var i = 0; i < picked. Objs. length; i++) { if (picked. Objs[i] != null) { var user. Oid = picked. Objs[i]. oid; var display. Attr = eval("picked. Objs[i]. full. Name"); update. Hidden. Field. value=user. Oid; update. Display. Field. value=display. Attr; } }

Author. Form. Processor. Delegate. java public class Author. Form. Processor. Delegate extends Default. Object.

Author. Form. Processor. Delegate. java public class Author. Form. Processor. Delegate extends Default. Object. Form. Processor. Delegate { Matches the public Form. Result do. Operation(Nm. Command. Bean cb, List list) “user. Hidden. Id” variable throws WTException defined earlier. { WTPrincipal. Reference author. Ref = null; String author. UID = cb. get. Text. Parameter("author. Picker"); author. Ref = Form. Processor. Helper. get. Reference. From. String(author. UID); if (list. size() == 1) { Object obj = ((Object. Bean)list. get(0)). get. Object(); if (obj instanceof My. Managed) { My. Managed my. Managed = (My. Managed)obj; try { gmd. Managed. set. Author(author. Ref); } catch (WTProperty. Veto. Exception wtpve) { throw new WTException(wtpve, "Unable to set Author on object"); } } else { System. out. println("Object was not a My. Managed object"); } } else { System. out. println("There is more than one object in the list"); } return new Form. Result(Form. Processing. Status. SUCCESS); } } Set the attribute.

Form. Processor. Helper. get. Reference. From. String public static WTPrincipal. Reference get. Reference. From.

Form. Processor. Helper. get. Reference. From. String public static WTPrincipal. Reference get. Reference. From. String( String user. IDStr ) throws WTException { WTPrincipal user. Principal = null; WTPrincipal. Reference user. Ref = null; if (user. IDStr. last. Index. Of("uid") == 0) { /* user. IDStr is the DN string */ user. IDStr = user. IDStr. substring(0, user. IDStr. last. Index. Of(": ")); user. Principal = Organization. Services. Helper. manager. get. Principal. By. DN(user. IDStr); user. Ref = WTPrincipal. Reference. new. WTPrincipal. Reference(user. Principal); } else { /* user. IDStr is the object reference string: wt. org. WTUser: ####*/ Object. Identifier oi = Object. Identifier. new. Object. Identifier(user. IDStr); user. Principal = Organization. Services. Helper. manager. get. Principal(oi); user. Ref = WTPrincipal. Reference. new. WTPrincipal. Reference(user. Principal); } return user. Ref; }

Action Definition <objecttype name=“My. Managed" class="com. company. test 2. My. Managed" resource. Bundle="com. company.

Action Definition <objecttype name=“My. Managed" class="com. company. test 2. My. Managed" resource. Bundle="com. company. test 2 Resource"> <!-- Create --> <action name="create_My. Managed" ajax="row"> <command class="com. ptc. core. components. forms. Create. Object. Form. Processor" method="execute" url="com/company/jsp/ids/test 2/create. My. Managed. jsp" window. Type="popup" on. Click="validate. Create. Location(event)"/> </action> <!-- Action definition for a custom wizard step. --> <action name="create. My. Managed. Set. Attributes. Wiz. Step" id="create. My. Managed. Set. Attributes. Wiz. Step" preload. Wizard. Page="false" required="true" > <command window. Type="wizard_step" url="com/company/jsp/ids/test 2/create. My. Managed. Set. Attributes. Wiz. Step. jsp"/> </action>. . .

Resource Bundle My. Managed. create_My. Managed. description. value=My Managed Object My. Managed. create_My. Managed.

Resource Bundle My. Managed. create_My. Managed. description. value=My Managed Object My. Managed. create_My. Managed. description. comment=label for create My. Managed under menubar's File>New menu. My. Managed. create_My. Managed. icon. value=com/company/test 2/My. Managed. gif

Folder Display Property <Property name="com. ptc. windchill. enterprise. folder. pdm. Folder. Browser. additional. Classes"

Folder Display Property <Property name="com. ptc. windchill. enterprise. folder. pdm. Folder. Browser. additional. Classes" overridable="true" target. File="codebase/wt. properties" value="com. company. my. Test. My. Managed, company. test 2. My. Managed"/> As “wcadmin”, edit the “All” folder view from any Library view to add classes to the view filter.