cancel
Showing results for 
Search instead for 
Did you mean: 

Suspending the workflow at particlalar condition

rockycres
Champ in-the-making
Champ in-the-making
Hi,

I am currently customizing the submit_processdefinition.xml to our needs.I need to have a validation java hook(action or decision  handlers) at a specific point in the workflow process which will validate the condition and if returns success the  submit process will continue normally.If it fails,we don't want the user to submit the content, so we need to disable the OK button & display some error message in the UI to the user which will be passed from the handler class.

   The problem we face here is that,we are able to pass the control to the validation handler which will do the validation &able to  pass the error message to the UI,

   1.But we are able to the disable the ok button,any idea how we can do this.
   2.Since the ok button is not disabled , the flow  goes to the next page and the  error message is  printing in the next page.

From the container.jsp,we understand the Wizardmanager is doint al the html renderings we tried use the wizart manger inside the ftl to disable the OK button ,but it's not working..

Plz find the following the snap shots which will define our process flow..

http://sivagurunath.com/images/alfresco/submit.png]
http://sivagurunath.com/images/alfresco/after_submit.png


Any help appreciated..
6 REPLIES 6

mrogers
Star Contributor
Star Contributor
One possible approach would be to put some sort of "validation failed" state into your workflow.

rockycres
Champ in-the-making
Champ in-the-making
hI,

Can u explain me a bit more or can u suggest me some examples..?

rockycres
Champ in-the-making
Champ in-the-making
Hi rogers,

Can u tell me how can i use validation in state instead of using it in transition..?


<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wcmwf:CRsubmitNew">

    <swimlane name="initiator"/>

    <start-state name="start"> 
       <task name="wcmwf:submitReviewTask" swimlane="initiator"/>
      <transition name="" to="Validation">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                 <script>
                       var mail = actions.create("mail");
                                mail.parameters.to = 'santhosh.sekar@yahoo.com';
                       mail.parameters.subject = "Adhoc Task 123";
                       mail.parameters.from = 'santhosh.sekar@gmail.com';                 
                       mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/new.ftl");    
                       mail.parameters.text = "It's done end ";                              
                       mail.execute(bpm_package);
                </script>             
            </action>     
      </transition> 
   </start-state>
       
  <decision name="Validation">            
       <handler class="com.sample.action.MessageActionHandler"></handler>  
         <transition name="trEnd" to="end"></transition> 
         <transition name="trInitialize" to="somenewTask"></transition>
  </decision> 

    <end-state name="end"/>
   
    <event type="process-end">
         <action class="org.alfresco.repo.avm.wf.AVMRemoveAllSrcWebappsHandler"/>
        <action class="org.alfresco.repo.avm.wf.AVMReleaseTestServerHandler"/>
        <action class="org.alfresco.repo.avm.wf.AVMRemoveWFStoreHandler"/>
    </event>

</process-definition>

rockycres
Champ in-the-making
Champ in-the-making
Hi all,IT WORKED..

               
    FacesContext fc =FacesContext.getCurrentInstance();                           
                   fc.getApplication().getNavigationHandler().handleNavigation(fc,null, "dialog:submitSandboxItems");
                   Utils.addErrorMessage("DOing SomeThing WronG");

I was able to print the error message in thesame page..Thanks,,,

fbehfar
Champ on-the-rise
Champ on-the-rise
Hey rockycres,
I've read your case, and a question came into my mind!
Where have you added the following code?

        FacesContext fc =FacesContext.getCurrentInstance();                          
                       fc.getApplication().getNavigationHandler().handleNavigation(fc,null, "dialog:submitSandboxItems");
                       Utils.addErrorMessage("DOing SomeThing WronG");

and in your workflow what do these lines do?

    <event type="process-end">
         <action class="org.alfresco.repo.avm.wf.AVMRemoveAllSrcWebappsHandler"/>
        <action class="org.alfresco.repo.avm.wf.AVMReleaseTestServerHandler"/>
        <action class="org.alfresco.repo.avm.wf.AVMRemoveWFStoreHandler"/>
    </event>

would you explain me a little more about how to print the error message in the same page?
thanks,

FSB

rockycres
Champ in-the-making
Champ in-the-making
Hi,
Good question…
#1.         FacesContext fc =FacesContext.getCurrentInstance();                        
             fc.getApplication().getNavigationHandler().handleNavigation(fc,null, "dialog:submitSandboxItems");
             Utils.addErrorMessage("DOing SomeThing WronG");

These lines are added in my custom action handler class .In my case ,when user submits the content,this handler class will validate few things and if fails it goes to end state & throws this error message in the same page…

    <event type="process-end">
         <action class="org.alfresco.repo.avm.wf.AVMRemoveAllSrcWebappsHandler"/>
        <action class="org.alfresco.repo.avm.wf.AVMReleaseTestServerHandler"/>
        <action class="org.alfresco.repo.avm.wf.AVMRemoveWFStoreHandler"/>
    </event>
These lines just removes & release all the handles to the current WF instance .

And  if u want to display the error message in the same page ,get current facecontext,and just call handlenavigation method and pass the 3 args(currentfacecontext,[not mandatory],outcome)…Here outcome is the same page…In this case ,"dialog:submitSandboxItems" is the page name(dialog name)…

So it wll display the same page again and adderrorMessage("    ") will just add the errormessage to the UI..Hope this clears ur doubt…Thanks