Filling the form fields by values from external system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 09:37 AM
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 09:45 AM
What you can do with the out-of-the-box explorer is have a task-listener on the task which does the webservice-call and fills in some variables on the task/process. Your formProperties can use the "variable" attribute to point the the variable, holding the value looked up in your web service. However, this is done ONLY ONCE, when the process flow reaches the user-task and waits there.
The form-property mechanism is pluggable, so you could have a property of type "custom" that does the webservice-call. This will require somme plugging in your explorer-configuration but is quite simple. Alternatively, you can also alter the UI based on the special types, this is also pluggable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 10:08 AM
Do you know any example of task listener, how to implement it? some tutorial or maybe some project example which I could download?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 10:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 10:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 10:42 AM
If you want the combo-boxes populated with values that are not defined in the process, you'll have to plug in your own FormProperty:
Example of this is in explorer itself:
- org.activiti.explorer.form.UserFormType
- UI for it: org.activiti.explorer.ui.form.UserFormPropertyRenderer
- Both classes plugged in into context-file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2012 12:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2012 02:20 AM
if (modelValue != null) {
if (variableName != null) {
execution.setVariable(variableName, modelValue);
} else if (variableExpression != null) {
variableExpression.setValue(modelValue, execution);
} else {
execution.setVariable(id, modelValue);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2012 04:18 AM
I've read some posts to handle it and I found that jar must be exported using normal Eclipse Export method but still I have a problem.
I got following exception during starting of the process after deployment.
Cause: org.activiti.engine.ActivitiException: Exception while invoking TaskListener: couldn't instantiate class mhcc.app.incidentservice.app.internal.Listener
This is how my Task definition looks like (just part of the xml file)
<userTask id="usertask1" name="Describe the accident" activiti:assignee="kermit">
<extensionElements>
<activiti:taskListener event="create" class="mhcc.app.incidentservice.app.internal.Listener" />
</extensionElements>
</userTask>
This is my class of listener:
package mhcc.app.incidentservice.app.internal;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
/**
* Listener for Task
*/
public class Listener implements TaskListener {
/**
* @see org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate.DelegateTask)
*/
@Override
public void notify( DelegateTask delegateTask ) {
delegateTask.setVariable( "Vehicle", "Funkerss" );
}
}
I copied this jar to directory in the Activiti-Explorer:
setup\build\webapps\activiti-explorer.war\WEB-INF\lib
In the attachments I present the steps I made during export.
After I copied the Listener.jar I restarted Activiti-Explorer by:
ant demo.stop
ant demo.start
Have someone idea what I'm doing wrong? I'm quite new in java, maybe I missed something obvious in the xport process of jar or restarting of activiti-explorer??
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2012 05:16 AM
Ronald, you can. However, this only works when the form-property is read-only. If that's not the case, when submitting the values, the expression will be used to "set" (which will fail).
if (modelValue != null) {
if (variableName != null) {
execution.setVariable(variableName, modelValue);
} else if (variableExpression != null) {
variableExpression.setValue(modelValue, execution);
} else {
execution.setVariable(id, modelValue);
}
}
Why would calling a setter fail? If you have a getter and setter (and no 'actual' db work should not be done in the getter) and the setter stores things?
(Still glad we do not use the formproperties for actual form stuff, more in a way of having 'task parameters' :-))
