I am playing around with vaadin and activity, and was wondering how to use a variable, in my vaadin code, in my activiti script. For example my vaadin code is as following
TextField field = new TextField("Enter Name: ");
Button button = new Button("Click Me: ");
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("hello_world.bpmn20.xml")
.deploy();
HashMap<String, Object> v = new HashMap<String, Object> ();
v.put("name", field.getValue());
RuntimeService runtimeService = processEngine.getRuntimeService();
runtimeService.startProcessInstanceByKey("myProcess", v);
}
});
and my groovy script in activiti is
System.out.println("Hello " + v);
I tried to use the HashMap
but the script still does not recognize my variable. How do I use my code variables in an activiti script?
It looks like you're setting up a variable called name
v.put("name", field.getValue());
But then printing a variable called v
System.out.println("Hello " + v);
If you change this to (making it a bit more Groovy in the process)
println "Hello $name"
It should work!