[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" <Antonio.Villanueva@xxxxxxxxxxxx> 
To: <wc-pdmlink@xxxxxxxxxxxxx> 
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);
|
|           %><TEXTAREA wrap=3D3D3D"soft"
|
|name=3D3D3D"<%=3D3D3DNmWorkItemCommands.ACTIVITY_VAR%><%=3D3D3DvariableN=
ame%>
"=3D

|
|rows=3D3D3D"<%=3D3D3Drows%>" =3D
cols=3D3D3D"<%=3D3D3Dcolumns%>"><%=3D3D3D(displayString =3D3D3D=3D3D3D
|=3D3D
|
|null ? "" :
|
|displayString)%></TEXTAREA><%
|
|        }
|
|    }
|
|
|
|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("<select
|
|name=3D3D3D"<%=3D3D3DNmWorkItemCommands.ACTIVITY_VAR%><%=3D3D3DvariableN=
ame%>
"=3D
>");
|
|                  for (int x=3D3D3D0; x<userIds.size(); x++) {
|
|                  out.println("<option value=3D3D3D'" + userIds.get(x) =
+
|
|"'>" +                  userDisplayNames.get(x) + "</option>");
|
|            }=3D3D09
|
|            else=3D3D20
|
|            {
|
|                  //First replace embedded variables with their
|
|values
|
|                  displayString =3D3D3D
|
|WorkflowHelper.service.replaceVariables(displayString,
activityContext);
|
|                  %><TEXTAREA wrap=3D3D3D"soft"
|
|name=3D3D3D"<%=3D3D3DNmWorkItemCommands.ACTIVITY_VAR%><%=3D3D3DvariableN=
ame%>
"=3D

|
|rows=3D3D3D"<%=3D3D3Drows%>" =3D
cols=3D3D3D"<%=3D3D3Dcolumns%>"><%=3D3D3D(displayString =3D3D3D=3D3D3D
|=3D3D
|
|null ? "" :
|
|displayString)%></TEXTAREA><%
|
|            }
|
|      }
|
|
|
|
|
|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 <TEXTAREA> for entry.
|
|
|
|If this list of users will change based on the context of the workflow,
|
|the following variable is defined toward the beginning of this page...
|
|
|
|ProcessData activityContext=3D3D3D =3D3D
|
|activityVariablesBean.getActivityContext();
|
|
|
|You can use this to get to the role for the appropriate context.
|
|
|
|Best Regards,
|
|Bill Palm
|
|PDC - CAD Support Group
|
|Harley-Davidson Motor Company
|
|Phone: 414.465.6604
|
|Fax: 414.465.6948
|
|William.Palm@xxxxxxxxxxxxxxxxxxx
|
|=3D3D20
|
|
|
||-----Original Message-----
|
||From: wc-pdmlink-bounce@xxxxxxxxxxxxx [mailto:wc-pdmlink-
|
||bounce@xxxxxxxxxxxxx] On Behalf Of Villanueva, Antonio
|
||Sent: Tuesday, April 19, 2005 8:26 AM
|
||To: wc-pdmlink@xxxxxxxxxxxxx
|
||Subject: [wc-pdmlink] Re: Drop down list in a workflow task
|
||
|
||Do you know what principalVariable.jsp is doing?  Is looks like when I
|
||add a WTUser as an attribute, it calls this.  It looks like it
creating
|
||the drop down list but what is strange is that it looks like its
|
|calling
|
||some team and project stuff.  Do you think I should put the
|
||customization here?  That way I can limit the users to the team
members
|
||only.
|
||
|
||-----Original Message-----
|
||From: wc-pdmlink-bounce@xxxxxxxxxxxxx
|
||[mailto:wc-pdmlink-bounce@xxxxxxxxxxxxx]=3D3D3D20
|
||Sent: Monday, April 18, 2005 3:56 PM
|
||To: wc-pdmlink@xxxxxxxxxxxxx; Villanueva, Antonio
|
||Subject: [wc-pdmlink] Re: Drop down list in a workflow task
|
||
|
||Tony,
|
||
|
||You have a couple directions you could go.
|
||
|
||First, you could create a workflow variable of type "WTUser".  You
just
|
||need to make it visible and give it write permissions for the task,
and
|
||the user can select a user from the drop down list.  The downside is
|
||that you get the complete list of users in the system which, in most
|
||cases, is too long.  Also, there was a bug with the
|
||principalVariables.jsp page which generates this list in M020.  I'm
not
|
||sure if it's fixed yet.  The upside is that this is not a
customization
|
||and will migrate to future releases with no extra work.
|
||
|
||Second, you can create a String workflow variable in the workflow and
|
||customize activityVariables.jsp to format it how you want it.  This
jsp
|
||page formats displayed variables based on type.  You can see in the
|
|file
|
||that there is a section for String.  Here is the conditional that
|
|checks
|
||for String...
|
||
|
||    else if (wfvInfo[i].getTypeName().equals("java.lang.String"))
|
||    {
|
||        if (wfvInfo[i].isReadOnly())
|
||        {
|
||
%><%=3D3D3D3D3DNmWorkItemCommands.formatToHtml(activityContext,
|
||variableName, wfvInfo[i])%><%
|
||        }
|
||        else
|
||        {
|
||           //First replace embedded variables with their values
|
||           displayString =3D3D3D3D3D
|
||WorkflowHelper.service.replaceVariables(displayString,
|
|activityContext);
|
||           %><TEXTAREA wrap=3D3D3D3D3D"soft"
|
||name=3D3D3D3D3D"<%=3D3D3D3D3DNmWorkItemCommands.ACTIVITY_VAR%><%=3D3D3D=
3D3Dv
a=3D
riabl
e
|N=3D3D
|
|ame%>
|
|"
|
||rows=3D3D3D3D3D"<%=3D3D3D3D3Drows%>" =3D3D3D
|
||cols=3D3D3D3D3D"<%=3D3D3D3D3Dcolumns%>"><%=3D3D3D3D3D(displayString =
=3D
=3D3D3D3D3D=3D3D3D3D3D
|
||=3D3D3D3D
|
||null ? "" :
|
||displayString)%></TEXTAREA><%
|
||        }
|
||    }
|
||
|
||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 <select> for a pull down
list.
|
||Since the value returned by this will return a String, you'll also
have
|
||to write some code in the workflow to get the WTUser.  Assigning the
|
||subsequent task to the WTUser variable is easy.  Just pick variables
on
|
||the participants tab and you should see the WTUser variable you
|
|created.
|
||
|
||The advantage of this method is you have total control.  The downside
|
|is
|
||that it's a customization that needs to be maintained.
|
||
|
||Let me know if you have any questions.
|
||
|
||Best Regards,
|
||Bill Palm
|
||PDC - CAD Support Group
|
||Harley-Davidson Motor Company
|
||Phone: 414.465.6604
|
||Fax: 414.465.6948
|
||William.Palm@xxxxxxxxxxxxxxxxxxx
|
||=3D3D3D3D20
|
|||-----Original Message-----
|
|||From: wc-pdmlink-bounce@xxxxxxxxxxxxx [mailto:wc-pdmlink-
|
|||bounce@xxxxxxxxxxxxx] On Behalf Of Villanueva, Antonio
|
|||Sent: Monday, April 18, 2005 2:04 PM
|
|||To: wc-pdmlink@xxxxxxxxxxxxx
|
|||Subject: [wc-pdmlink] Drop down list in a workflow task
|
|||
|
|||Just got the word from TS that this is not possible. What I would
like
|
|||to do is have the user choose who the next task should go to at the
|
||same
|
|||time as choosing a disposition for the task.  If approved, the chosen
|
|||user would get the task.  I would have like to see a drop down list
of
|
|||users that are members of the Program.  Seems that this is not
|
|possible
|
|||so what the alternative.  I have the Setup Participants task since it
|
|||does not restrict the just the program users.  Delegating tasks is
|
|okay
|
|||but is a cumbersome (you get a task that asks you to send somewhere
|
|||else). I had though about listing the users as a HTML list in the
|
|||instructions and then providing a number choice as a variable.  Is
|
||there
|
|||a way to validate the choice (say within a range value) on the
|
|workflow
|
|||and not let them complete if it fails (or resend back to them if they
|
|||enter a bad number)?
|
|||
|
||
|
||
|
|
|
|
|
|




 
 

 


[ Home | Signup | Help | Login | Archives | Lists ] 
All trademarks and copyrights within the FreeLists archives are owned by their respective owners. 
Everything else 2007 Avenir Technologies, LLC. 
 
 
 

 
 
