setting the value of variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2011 11:31 AM
Hi,
I have the following problem. In the 'DelegateExecution' I store a 'm' variable which is an object of the class Movie and for instance has a field title of type string. Then I display this value in a form using the following piece of code (user can change the value of the field):
I have the following problem. In the 'DelegateExecution' I store a 'm' variable which is an object of the class Movie and for instance has a field title of type string. Then I display this value in a form using the following piece of code (user can change the value of the field):
<input type="text" value="${m.title}">
Let's make an assumption that I edit this field and change it's value (from "title1" to "title2". Then in the next (next UserTask) step I display the value once again using the following piece of code:<td>${m.title}</td>
and I expect that the value will be changed to this entered in previous step, but the value is the same. How can I handle this?
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2011 03:52 AM
Is it even possible? No ideas?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2011 04:29 AM
Can't reproduce it here locally.
Can you post a simple version of your form + process?
Can you post a simple version of your form + process?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2011 04:49 AM
I will, but need some time to prepare sample.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2011 06:15 AM
Ok, I've prepared simplified version o my process.
Here's the bpmn20.xml:
Here's the bpmn20.xml:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="http://www.bpmnwithactiviti.org/movieOrder">
<process id="movieOrder" name="Order a movie">
<startEvent id="start" />
<sequenceFlow sourceRef="start" targetRef="parseJson" />
<serviceTask id="parseJson" name="Parse JSON" activiti:class="services.ParseJSONService" />
<sequenceFlow sourceRef="parseJson" targetRef="assignTechnician" />
<userTask id="assignTechnician" name="Assign the technician" activiti:candidateGroups="customers" activiti:formKey="assignTechnician.form" />
<sequenceFlow sourceRef="assignTechnician" targetRef="createMovie" />
<userTask id="createMovie" name="Create movie" activiti:formKey="createMovie.form"/>
<sequenceFlow sourceRef="createMovie" targetRef="end" />
<endEvent id="end" />
</process>
</definitions>
In ParseJSONService I parse the incoming request and store m variable in the context.
public class ParseJSONService implements JavaDelegate {
private GsonMapper gm = new GsonMapper();
@Override
public void execute(DelegateExecution de) throws Exception {
String mJson = (String) de.getVariable("movie");
Movie m = gm.fromJson(mJson, Movie.class);
de.setVariable("m", m);
}
}
Movie:
public class Movie implements Serializable {
private Integer id;
private String title;
private String genre;
private String spiCode;
//public getters and setters
}
In assignTechnician.form I can edit some movie properties (the movie's properties are displaying well):
<div>
<h1>Order</h1>
<table>
<tr>
<td>Title</td>
<td><input type="text" value="${m.title}"></td>
<td>Genre</td>
<td><input type="text" value="${m.genre}"></td>
<td>SPI</td>
<td><input type="text" value="${m.spiCode}"></td>
</tr>
</table>
</div>
I expect that on the createMovie.form I will see updated values of movie (changed in assignedTechnician.form) but this doesn't happen. createMovie.form:
<div>
<h1>Order</h1>
<table>
<tr>
<td>Title</td>
<td>${m.title}</td>
<td>Genre</td>
<td>${m.genre}</td>
<td>SPI</td>
<td>${m.spiCode}</td>
</tr>
</table>
</div>
My question is: what should be done to see the updated properties o m object on the following forms in my process.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2011 02:40 AM
Hi,
Any ideas?
Any ideas?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2011 03:13 AM
Hi,
The problem is that your form doesn't really set the values from your movie-pojo, you have:
While the userguide mentions this, using the "name" attribute on the input-tag:
Currently the REST-API (and explorer) doesn't use the formProperties yet. If these are available, you can specify a mapping from a property on your form to a variable (or even an expression). More info on this can be found in the userguide.
As a current workaround, you could add a TaskListener to the userTask on event "end" that invokes setters on your movie-object with properties posted in the form.
The problem is that your form doesn't really set the values from your movie-pojo, you have:
<td><input type="text" value="${m.title}"></td>
While the userguide mentions this, using the "name" attribute on the input-tag:
<input type="text" name="employeeName" value="" />
Currently the REST-API (and explorer) doesn't use the formProperties yet. If these are available, you can specify a mapping from a property on your form to a variable (or even an expression). More info on this can be found in the userguide.
<activiti:formProperty id="title" expression="#{m.title}" required="true" />
As a current workaround, you could add a TaskListener to the userTask on event "end" that invokes setters on your movie-object with properties posted in the form.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2011 04:39 AM
Currently the REST-API (and explorer) doesn't use the formProperties yet.
As far as I understand this functionality isn't supported yet?
The workaround might be good idea. Thanks.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2011 04:45 AM
Indeed.
The engine API supports this. The REST-API doesn't expose this yet.
The engine API supports this. The REST-API doesn't expose this yet.
