[wc-pdmlink] || [Date Prev] [04-2005 Date Index] [Date Next] || [Thread Prev] [04-2005 Thread Index] [Thread Next] [wc-pdmlink] Re: Drop down list in a workflow task From: "Villanueva, Antonio" To: Date: Tue, 19 Apr 2005 09:10:40 -0700 It works. A bit more testing to be sure. private Enumeration goodrichGetMembers() throws WTException{ WorkItem workitem=3DgetWorkItem(); WfActivity wfactivity =3D (workitem.getSource().getObject() instanceof WfActivity) ? (WfActivity)workitem.getSource().getObject() : null; ContainerTeamManaged containerteammanaged =3D (ContainerTeamManaged)wfactivity.getContainer(); Enumeration enumeration =3D ((ContainerTeam)containerteammanaged.getContainerTeamReference().getObje ct()).getMembers().elements(); ArrayList arraylist =3D new ArrayList(); Object obj =3D null; while(enumeration.hasMoreElements())=20 { WTPrincipalReference wtprincipalreference =3D (WTPrincipalReference)enumeration.nextElement(); WTPrincipal wtprincipal =3D (WTPrincipal)wtprincipalreference.getObject(); if(wtprincipal instanceof WTUser) { WTUser wtuser =3D (WTUser)wtprincipal; arraylist.add(wtuser); } /*} else { explodeGroupToMembers(wtprincipal, arraylist, containerteammanaged); }*/ } Collections.sort(arraylist, new Comparator() { public int compare(Object obj1, Object obj2) { String s =3D ((WTUser)obj1).getFullName(); if(s =3D=3D null) s =3D ""; String s1 =3D ((WTUser)obj2).getFullName(); if(s1 =3D=3D null) s1 =3D ""; return s.compareToIgnoreCase(s1); } }); Vector vector =3D new Vector(arraylist); return convertEnumToSerializableEnum(vector.elements()); } =20 private Enumeration convertEnumToSerializableEnum(Enumeration enumeration) throws WTException { ObjectVector objectvector =3D new ObjectVector(); Object obj; for(; enumeration.hasMoreElements(); objectvector.addElement(obj)) obj =3D enumeration.nextElement(); return new QueryResult(objectvector); } =20 public String principalSelector(String s, WTPrincipal wtprincipal, String s1) throws WTException { Vector vector =3D new Vector(); Vector vector1 =3D new Vector(); if(s.equals("wt.org.WTPrincipal") || s.equals("wt.org.WTUser")) { WTUser wtuser; for(SortedEnumeration sortedenumeration =3D new SortedEnumeration(goodrichGetMembers(), new CollationKeyFactory(WTContext.getContext().getLocale())); sortedenumeration.hasMoreElements(); vector1.addElement(wtuser.getFullName())) { wtuser =3D (WTUser)sortedenumeration.nextElement(); vector.addElement(wtuser.getName()); } } if(s.equals("wt.org.WTPrincipal") || s.equals("wt.org.WTGroup")) { WTGroup wtgroup; for(SortedEnumeration sortedenumeration1 =3D new SortedEnumeration(OrganizationServicesMgr.allGroups(), new CollationKeyFactory(WTContext.getContext().getLocale())); sortedenumeration1.hasMoreElements(); vector1.addElement(wtgroup.getName())) { wtgroup =3D (WTGroup)sortedenumeration1.nextElement(); vector.addElement(wtgroup.getName()); } } int i =3D wtprincipal !=3D null ? vector.indexOf(wtprincipal.getName()) + 1 : 0; return HtmlUtil.createSelectHTML(s1, null, vector, vector1, true, i); } -----Original Message----- From: wc-pdmlink-bounce@xxxxxxxxxxxxx [mailto:wc-pdmlink-bounce@xxxxxxxxxxxxx]=20 Sent: Tuesday, April 19, 2005 11:16 AM To: wc-pdmlink@xxxxxxxxxxxxx Subject: [wc-pdmlink] Re: Drop down list in a workflow task Tony, Sorry about that. All the work I did was in ProjectLink. You may have to move this customization to activityVariables.jsp in 8.0, though. I'll check that out in my beta 8.0 environment if I have a few minutes later today. Best Regards, Bill Palm PDC - CAD Support Group Harley-Davidson Motor Company Phone: 414.465.6604 Fax: 414.465.6948 William.Palm@xxxxxxxxxxxxxxxxxxx =3D20 |-----Original Message----- |From: wc-pdmlink-bounce@xxxxxxxxxxxxx [mailto:wc-pdmlink- |bounce@xxxxxxxxxxxxx] On Behalf Of Villanueva, Antonio |Sent: Tuesday, April 19, 2005 10:07 AM |To: wc-pdmlink@xxxxxxxxxxxxx |Subject: [wc-pdmlink] Re: Drop down list in a workflow task | |Actually, I think the PDMLink side still uses a template processor, |com.ptc.windchill.pdmlink.workflow.worklist.server.processors.WfTaskPro c |essor.class. |I think the JSP is only used by Project Link side. I looked in the cache |and that jsp file was never compiled which means it was never called. |Then I dug into the properties files and found the WfTask action from |the URL. Eventually, I got to this section: | | | |public String principalSelector(String s, WTPrincipal wtprincipal, |String s1) | | throws WTException | | { | | Vector vector =3D3D new Vector(); | | Vector vector1 =3D3D new Vector(); | | if(s.equals("wt.org.WTPrincipal") || s.equals("wt.org.WTUser")) | | { | | WTUser wtuser; | | for(SortedEnumeration sortedenumeration =3D3D new |SortedEnumeration(OrganizationServicesMgr.allUsers(), new |CollationKeyFactory(WTContext.getContext().getLocale())); |sortedenumeration.hasMoreElements(); |vector1.addElement(wtuser.getFullName())) | | { | | wtuser =3D3D (WTUser)sortedenumeration.nextElement(); | | vector.addElement(wtuser.getName()); | | } | | | |That's where the problem is. Well, I could customize this and overwrite |the method. It would be simple. Seeing as it does not use the JSP, I |think the only option would be to extend this class, no? | | | |-----Original Message----- |From: wc-pdmlink-bounce@xxxxxxxxxxxxx |[mailto:wc-pdmlink-bounce@xxxxxxxxxxxxx] |Sent: Tuesday, April 19, 2005 10:48 AM |To: wc-pdmlink@xxxxxxxxxxxxx |Subject: [wc-pdmlink] Re: Drop down list in a workflow task | | | |Tony, | | | |You're correct that when you use a WTUser variable, first | |activityVariables.jsp is called to determine the correct format for the | |html input. This page calls principalVariable.jsp within the | |conditional to check if it's a WTUser variable type. When I was trying | |to use this, there was a bug in principalVariable.jsp, so I was trying | |to do this manually. From what I recall, this page is supposed to | |filter the list so that only the users that are members of the | |workflow's context are displayed. | | | |That brings us back to option 2. If the bug is still there, or if you | |want to filter further (for example, only users of a given role within | |the workflow's context are displayed), then you can just use a String | |variable. You can use java code to gather the list of users you want to | |display, and then display them as a pull down list. That way you don't | |have to worry about user error. When I did this, I had to allow | |multiple users to be selected, so I used javascript to put all users | |that were selected into a StringTokenizer to return them back to the | |workflow where I could parse them and put them into a WTGroup or Role | |variable. If you only need one user, you can just put the return value | |in the option list, and then use that in the workflow to get the WTUser | |using a QuerySpec. | | | |If you go this route, look for the following in activityVariables.jsp... | | | | //Strings -> textarea | | else if (wfvInfo[i].getTypeName().equals("java.lang.String")) | | { | | if (wfvInfo[i].isReadOnly()) | | { | | %><%=3D3D3DNmWorkItemCommands.formatToHtml(activityContext, | |variableName, wfvInfo[i])%><% | | } | | else | | { | | //First replace embedded variables with their values | | displayString =3D3D3D | |WorkflowHelper.service.replaceVariables(displayString, activityContext); | | %><% | | } | | } | | | |Then in the else, you can you can look for your variable name like this | |(the entire block with the customization is shown for clarity)... | | | | //Strings -> textarea | | else if (wfvInfo[i].getTypeName().equals("java.lang.String")) | | { | | if (wfvInfo[i].isReadOnly()) | | { | | %><%=3D3D3DNmWorkItemCommands.formatToHtml(activityContext, | |variableName, wfvInfo[i])%><% | | } | | else | | if (variableName.equals("YOUR VAR NAME FROM WORKFLOW") | | { | | ArrayList userIds =3D3D3D new ArrayList(); | | ArrayList userDisplayNames =3D3D3D new ArrayList(); | | // use jsp code here to create your list of | |users and // populate the ArrayLists. | | | | out.println("<% | | } | | } | | | | | |You can use whatever container you'd like, but I just used ArrayList as | |an example. Just make sure that whatever attribute you use for the | |userIds values is unique and searchable since that will be returned to | |the workflow. | | | |I hope this makes sense. Let me clarify what activityVariables.jsp is | |doing. When a user looks at a task, this page is called and determines | |how to format variables that are defined for that task. For example, | |when a String variable for comments is defined, the block above is | |called because (wfvInfo[i].getTypeName().equals("java.lang.String")) is | |true. If the variable is defined as read only in the workflow, the | |first conditional will be used to display the value of the String, so it | |calls the formatToHtml method to display the value. If the user can | |change the value, the else block is used to determine how to format the | |variable. It outputs the <% | || } | || } | || | ||So, within the else block (since the variable is visible), you would | |add | ||a conditional to check for the name of your variable with the | ||following... | || | ||if (variableName.equals("Next User")) | || | ||where "Next User" is the workflow variable name. Then within the | ||conditional, you can construct your list of users however you'd like | ||using java, then display them in an html