Below is some xpress code I wrote once, used to dynamically lauch workflows from within a workflow. Since it basically uses java classes, you reuse these in your java program or jsp:
- create a new generic object
- call the setId, put, ... methods on it
- set the input variables for the workflow by putting them into the generic object
- call the checkinView method on a LighthouseContext object which launches your workflow.
If all you need is starting a workflow from a jsp, you might also want to take a look at the tasks/taskLaunch.jsp jsp. This is an out of the box jsp which allows launching of tasks. If I remember correctly you have to give an url parameter which specificies the name of task you want to start: tasks/taskLaunch.jsp?id=<workflow-name>
- Robin
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE TaskDefinition PUBLIC 'waveset.dtd' 'waveset.dtd'>
<TaskDefinition name="MVG_TD_LaunchWorkflow" taskType="Workflow" executor="com.waveset.workflow.WorkflowExecutor" suspendable="true" syncControlAllowed="true" execMode="sync" execLimit="0" resultLimit="0" resultOption="delete" visibility="runschedule" progressInterval="0">
<Extension>
<WFProcess name="MVG_TD_LaunchWorkflow">
<Variable name="workflowName" input="true"/>
<Variable name="taskInstanceName" input="true"/>
<Variable name="inputs" input="true"/>
<Variable name="processView"/>
<Activity name="start">
<Transition to="createProcessView"/>
</Activity>
<Activity name="createProcessView">
<Action>
<block trace="true">
<set name="processView">
<new class="com.waveset.object.GenericObject"/>
</set>
<invoke name="setId">
<ref>processView</ref>
<s>ProcessViewer</s>
</invoke>
<invoke name="put">
<ref>processView</ref>
<s>task.process</s>
<ref>workflowName</ref>
</invoke>
<invoke name="put">
<ref>processView</ref>
<s>task.taskName</s>
<ref>taskInstanceName</ref>
</invoke>
<if>
<notnull>
<ref>inputs</ref>
</notnull>
<then>
<invoke name="assimilate">
<ref>processView</ref>
<ref>inputs</ref>
</invoke>
</then>
</if>
</block>
</Action>
<Transition to="checkInProcessView"/>
</Activity>
<Activity name="checkInProcessView">
<Action>
<block trace="true">
<invoke name="checkinView">
<invoke name="getLighthouseContext">
<ref>WF_CONTEXT</ref>
</invoke>
<ref>processView</ref>
<new class="java.util.HashMap"/>
</invoke>
</block>
</Action>
<Transition to="end"/>
</Activity>
<Activity name="end"/>
</WFProcess>
</Extension>
<MemberObjectGroups>
<ObjectRef type="ObjectGroup" id="#ID#Top" name="Top"/>
</MemberObjectGroups>
</TaskDefinition>