Question

Okay, so I have been looking around on the internet for any examples of incorporating a pop-up window into an activiti/alfresco workflow, but have come up with no results. I was just wondering if anyone had any prior experience doing this, or even knew if it was possible to do such a thing?

Was it helpful?

Solution

What do you want to trigger the popup? I can see two things you may be trying to accomplish here, each with very different implementations.

If you want to create a popup in the task-edit page for some particular task of a workflow, you can add a control with javascript to produce that (I am guessing you already know the basics of workflow design, if not, Jeff Potts' tutorial is great -> http://ecmarchitect.com/images/articles/alfresco-workflow/advanced-workflow-article-2ed.pdf). To do this, create a file in tomcat/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/form/controls, for instance: tomcat/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/form/controls/myWorkflowPopup.ftl. Set up the file using freemarker syntax including javascript to create a popup how you like in the event you like - I am not sure from your post whether you want a pop-up browser window, a little javascript alert or a YUI dialog, but you could do any of these. Similarly I am not sure how you want to trigger this - from a button, when someone chooses 'Approve' in a form field, whatever. Once you have setup the control, you can add it to the workflow task. To add the control, edit tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml; find the following element and add a field element as shown ([values like this] should be replaced by proper values from your setup):

<config evaluator="task-type" condition="[workflowNS]:[someTask]">
    <forms>
        <form>
            <field-visibility>
                ...
            </field-visibility>
            <appearance>
                ...
                <field id="[workflowNS]:[someField]">
                    <control template="/org/alfresco/components/form/controls/[myWorkflowPopup].ftl" />
                </field>
            </appearance>
        </form>
    </forms>
</config>

In case you need to use it in your popup, the value of [workflowNS]:[someField] will be available to you in the template as field.value. These steps are a little high level, but I don't even know if this is the solution you are looking for so I can give more detail if you need.

The other possibility is that you are looking for a popup that is TRIGGERED by a workflow, but appears independent of any of the workflow UI. In this case we split down into another two possibilities-

a) You wish to have a popup appear on the users desktop when workflow finishes or reaches x state. I would do this with a java notification area app. I actually looked into doing this previously and opted to use emails instead when I realized how much work would be required. Good luck if you decide to try this - you're a less lazy man than I.

b) You wish to have a popup appear in browser (again this might be another browser window, a yui dialog or a jscript/vbscript alert/msgbox). This could be done with AJAX. If it were me I would keep an xml file in each user home folder. I would set this to have permissions too high for user's to view, but use the run-as option in your workflow definition to run script tasks as an admin user to update these files. For instance, you may have a financial approval workflow which needs to notify everyone in the Finance group when a new request is filed. The script task would loop through the finance group, pick each user, and append an element to the xml file in their user home.

For the popup logic I would add a javascript dependency in share-config-custom.xml so that you can have an external script file included with every page. In that script file use setInterval to GET to a uri every x seconds (the correct value of x is up to you to decide - balance performance/bandwidth usage with functionality).

At the uri being hit by your script, set up a repo webscript to pull the data out of the current user's user home xml file. Use an attribute on each element to keep the viewed state of the message. when the webscript runs it should return any unviewed messages (probably via json) and set them to viewed.

Again - very high level instruction which still expect a lot of work from you, but if you have problems post back with which of these (if any) you are trying to accomplish and I may be able to help you in more detail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top