cancel
Showing results for 
Search instead for 
Did you mean: 

How can i invoke Workflow Form page From Custom UI Action

mohammed_amr
Champ in-the-making
Champ in-the-making
Dear Guies,

Main Idea:

I'm trying to build custom ui action on alfresco/share mentioned to invoke the start page (First Transition) Directly.

Example For Explanation:

When you Enter to alfresco share main page, you will notice that you have a dashlet named "My Tasks" and there is a link called "Start Workflow"; When you click on this action you will go to the "Start Workflow page" where is there a menu of workflows for select a specific to show the "Workflow Form Page" and start it. When you select a workflow from the menu a "Workflow Form Page" will be displayed to start the workflow.

My Question:

How can i build custom ui on Alfresco (Web/Share) to invoke the "Workflow Form Page" Directly without going through all of the above steps ?

Thanks for help.
7 REPLIES 7

mrogers
Star Contributor
Star Contributor
Please don't cross post.

mohammed_amr
Champ in-the-making
Champ in-the-making
Sorry, but i need different Gurus to see my post from different areas.

Thanks.

mohammed_amr
Champ in-the-making
Champ in-the-making
This problem is solved can you please look at my post under Mohammed Amr name.

mohammed_amr
Champ in-the-making
Champ in-the-making
Look Zakusov,


                     <a:panel id="pooled-panel-0" bgcolor="white"
                        expandedTitleBorder="dotted" titleBgcolor="white"
                        styleClass="mainSubTitle" rendered="#{MersalOutboundWorkflowBean.newOutboundsRendered}">
                        <a:richList initialSortColumn="ApplicationNumber" id="pooled-panel-0-rich-list" value="#{MersalOutboundWorkflowBean.newOutbounds}"
                           pageSize="5" var="w" styleClass="recordSet"
                           headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow"
                           initialSortDescending="true" viewMode="details" refreshOnBind="true"
                           style="width:100%;" rendered="#{MersalOutboundWorkflowBean.newOutboundsRendered}">
                           <a:column style="padding:2px;text-align:center">
                              <a:actionLink action="#{MersalOutboundWorkflowBean.addFlavor}"
                                          image="/mersal/images/star/1.png" value="Not Monitored"
                                          actionListener="#{MersalOutboundWorkflowBean.preFlavor}"
                                          showLink="false" rendered="#{!w.Marked || w.Marked == null}">
                                 <f:param name="ApplicationNumber" value="#{w.ApplicationNumber}"/>
                                 <f:param name="id" value="#{w.id}"/>
                              </a:actionLink>
                              <a:actionLink action="#{MersalOutboundWorkflowBean.addFlavor}" 
                                          image="/mersal/images/star/2.png" value="Monitored"
                                          actionListener="#{MersalOutboundWorkflowBean.preFlavor}"
                                          showLink="false" rendered="#{w.Marked}">
                                 <f:param name="ApplicationNumber" value="#{w.ApplicationNumber}"/>
                                 <f:param name="id" value="#{w.id}"/>
                              </a:actionLink>
                           </a:column>                           
                           <a:column style="padding:2px;text-align:center">
                              <a:graphicImageExprEnable url="#{w.applicationPriorityIcon}" rendered="#{w.applicationPriorityIcon != null}"/>
                              <h:outputText value=" " escape="false"/>
                              <a:graphicImageExprEnable url="#{w.applicationTypeIcon}" rendered="#{w.applicationTypeIcon != null}"/>
                           </a:column>                           
                           <a:column id="pooled-panel-0-col2" style="padding:2px;text-align:center">
                              <f:facet name="header">
                                 <a:sortLink id="pooled-panel-0-col2-sort" label="#{dsMsg.application_no}"
                                    value="ApplicationNumber" styleClass="header" rendered="#{w.ApplicationNumber != null}"/>
                              </f:facet>
                              <a:actionLink id="pooled-panel-0-col2-txt-1" value="#{w.ApplicationNumber}"
                                 actionListener="#{WorkflowBean.setupTaskDialog}"
                                 action="dialog:manageTask" rendered="#{w.ApplicationNumber != null}">
                                 <f:param name="id" value="#{w.id}" />
                                 <f:param name="type" value="#{w.type}" />
                              </a:actionLink>                                             
                              <h:outputText id="pooled-panel-0-col2-txt-2" rendered="#{w.ApplicationNumber == null}" value="-"/>               
                           </a:column>
                     
                           <a:column id="pooled-panel-0-col3" style="padding:2px;text-align:center">
                              <f:facet name="header">
                                 <a:sortLink id="pooled-panel-0-col3-sort" label="#{dsMsg.creation_date}"
                                    value="CreationDate" styleClass="header" />
                              </f:facet>
                              <a:actionLink id="pooled-panel-0-col3-txt-1" value="#{w.CreationDate}"
                                 actionListener="#{WorkflowBean.setupTaskDialog}"
                                 action="dialog:manageTask">
                                 <f:param name="id" value="#{w.id}" />
                                 <f:param name="type" value="#{w.type}" />
                              </a:actionLink>   
                              <h:outputText id="pooled-panel-0-col3-txt-3" rendered="#{w.CreationDate == null}" value="-"/>                              
                           </a:column>
                     
                           <a:column id="pooled-panel-0-col4" style="padding:2px;text-align:center">
                              <f:facet name="header">
                                 <a:sortLink id="pooled-panel-0-col4-sort" label="#{dsMsg.subject}" value="Subject"
                                    styleClass="header" />
                              </f:facet>
                              <a:actionLink id="pooled-panel-0-col4-txt-1" value="#{w.Subject}"
                                 actionListener="#{WorkflowBean.setupTaskDialog}"
                                 action="dialog:manageTask">
                                 <f:param name="id" value="#{w.id}" />
                                 <f:param name="type" value="#{w.type}" />
                              </a:actionLink>                              
                              <h:outputText id="pooled-panel-0-col4-txt-3" rendered="#{w.Subject == null || w.Subject == ''}" value="-"/>
                           </a:column>
                           
                           <a:column id="pooled-panel-0-col5" style="padding:2px;text-align:center">
                              <f:facet name="header">
                                 <a:sortLink id="pooled-panel-0-col5-sort" label="#{dsMsg.owner}" value="AppOwner"
                                    styleClass="header" />
                              </f:facet>
                              <a:actionLink id="pooled-panel-0-col5-txt-1" value="#{w.AppOwner}"
                                 actionListener="#{WorkflowBean.setupTaskDialog}"
                                 action="dialog:manageTask">
                                 <f:param name="id" value="#{w.id}" />
                                 <f:param name="type" value="#{w.type}" />
                              </a:actionLink>
                              <h:outputText id="pooled-panel-0-col5-txt-3" rendered="#{w.AppOwner == null || w.AppOwner == ''}" value="-"/>
                           </a:column>
                           
                           <a:column id="pooled-panel-0-col7" actions="true" style="padding:3px;text-align:center;text-valign:center">
                              <f:facet name="header">
                                 <h:outputText id="pooled-panel-0-col7-action-template-1" value="#{msg.actions}" />
                              </f:facet>
                              <h:outputText value=" " escape="false"/>
                              <a:actionLink id="pooled-panel-0-col7-act1" value="#{msg.manage_task}" image="/images/icons/workflow_task.gif" showLink="false"
                                          actionListener="#{WorkflowBean.setupTaskDialog}" action="dialog:manageTask">
                                       <f:param name="id" value="#{w.id}" />
                                       <f:param name="type" value="#{w.type}" />
                              </a:actionLink>
                              <h:outputText value=" " escape="false"/>
                              <a:actionLink id="pooled-panel-0-col7-act2" value="#{msg.delete_task}" image="/images/icons/close_panel.gif" showLink="false"
                                          actionListener="#{MersalOutboundWorkflowBean.cancelTask}">
                                       <f:param name="id" value="#{w.id}" />
                              </a:actionLink>   
                              <h:outputText value=" " escape="false"/>                           
                              <r:actions id="pooled-panel-0-col7-act3" value="dashlet_completed_actions" context="#{w}" showLink="false" styleClass="inlineAction" />
                           </a:column>      
                                                
                           <a:dataPager displayInput="Navigate" styleClass="pager" />
                        </a:richList>
                     </a:panel>

notice that WorkflowBean.setupTaskDialog is very important method, already you can write your own method.


   public void setupTaskDialog(String id, String type)
   {
      ParameterCheck.mandatoryString("Task ID", id);
      ParameterCheck.mandatoryString("Task Type", type);
     
      // setup the dispatch context with the task we're opening a dialog for
      TransientNode node = new TransientNode(QName.createQName(type), id, null);
      this.navigationBean.setupDispatchContext(node);
     
      // pass on parameters for the dialog
      Map<String, String> params = new HashMap<String, String>(2, 1.0f);
      params.put("id", id);
      params.put("type", type);
      Application.getDialogManager().setupParameters(params);
   }

All of above will serve you about manage task, but what if you need to initiate a workflow.


         <a:actionLink
                  id="create_new_outbound" value="#{msg.new_sader}"
                  showLink="false"
                  rendered="#{PermissionUtilDecorator.authorizedToCreateOutbounds && !NavigationBean.mersalAdmin}"
                  actionListener="#{MersalMenuWorkflowBean.initiateMersalWorkflow}"
                  action="dialog:manageTask">
            <f:param name="workflowName" value="activiti$CS-Outbound-WFPD"/>
            <f:param name="isReply" value="false"/>
         </a:actionLink>   

look at the simple action link and then look at the initiateMersalWorkflow


   /**
    * @AUTHOR MOHAMMED AMR
    * @DESCRIPTION THIS METHOD AIMED TO START AN OUTBOUND WORKFLOW AND SKIP THE FIRST STEP (START STEP) FORWARD
    * TOWARD THE CREATE OUTBOUND TASK
    * @PARAM EVENT IS AN ACTION EVENT CONTAINS THE OUTBOUND WOKFLOW DEFINITION
    * */
   public void initiateMersalWorkflow(ActionEvent event) {
      LOG.debug("INITIATE MERSAL WORKFLOW …");
      // ACQUIRE THE ACTION LINNK
      UIActionLink action = (UIActionLink) event.getSource();
      // ACQUIRE THE PARAMS
      Map<String, String> params = action.getParameterMap();
      // PREPARE THE WORKFLOW NAME
      String definition = params.get(BeanUtil.WORKFLOW_DEFINITION_PARAMETER);
      // ACQUIRE THE WORKFLOW DEFINITION
      WorkflowDefinition workflowDefinition = this.getWorkflowService().getDefinitionByName(definition);
      // START WORKFLOW BY USING WORKFLOW DEFINITION AND EMPTY PARAMETERES
      WorkflowPath workflowPath = this.getWorkflowService().startWorkflow(workflowDefinition.getId(), prepareWorkflowParamters());
      // END THE START PATH TASK TO ALLOW THE WORKFLOW ENGINE TO PASS FORWARD
      // TOWARD THE SECOND PATH, WE ASSUME THAT THIS WORKFLOW INSTANCE HAVE A PATH AT INDEX 0
      WorkflowTask workflowTask = this.getWorkflowService().endTask(this.getWorkflowService().
            getTasksForWorkflowPath(workflowPath.getId()).get(0).getId(), MersalMenuWorkflowBean.NEXT_TRANSITION);
      // ACQUIRE THE TASK FOR THE CURRENT PATH, WE ASSUME THAT THE WORKLOFW INSTANCE HAVE A PATH AT INDEX 0
      workflowTask = this.getWorkflowService().getTaskById(this.getWorkflowService().getTasksForWorkflowPath(workflowPath.getId()).get(0).getId());
      // I WILL USE CREATE TASK TO RENDER TASK PROPERTIES ON THE DIALOG
      // MAP NODE WILL BE USED IN THE DIALOG
      TransientMapNode transientMapNode = createTask(workflowTask);
      // CREATE A NODE OF TRANSIENT NODE
      TransientMapNode node = new TransientMapNode(QName.createQName(transientMapNode.getType().toString()),workflowTask.getId(), null);
      // PUT THE NODE INTO THE DISPATCHER CAUSE THE DIALOG WILL ACT UPON NODE
      // EXIST ON THE CONTEXT DISPATCHER
      this.navigationBean.setupDispatchContext(node);
      // PREPARE THE PARAMTERES THAT WILL BE USED BY THE RENDERED PAGE
      Map<String, String> dialogParameters = new HashMap<String, String>(2, 1.0f);
      // ADD ID PARAMETER
      dialogParameters.put("id", workflowTask.getId());
      // ADD TYPE PARAMTER
      dialogParameters.put("type", transientMapNode.getType().toString());
      // SETUP DIALOG PARAMTERES
      Application.getDialogManager().setupParameters(dialogParameters);
   }

I hope that will serve you, please tell me if you are satisfied or not.

hgao
Champ in-the-making
Champ in-the-making
Hi mohammed,
I saw your posted code. where should I add those codes?
which file in alfresco that I should modify to add my new workflow link?

Thanks,

vinodkumarn
Champ in-the-making
Champ in-the-making
Hi mohammad,
I found your explanation is quite explanatory and i wish you could help me out in start workflow functionality, where user selects a workflow option and the corresponding workflow form get displayed.Please send me the steps and files . Smiley Happy

Thanks In Advance.

mohammed_amr
Champ in-the-making
Champ in-the-making
I pass the workflow definition as parameter, you can look at the previous example to see that at the param named "workflowName" Smiley Happy.