cancel
Showing results for 
Search instead for 
Did you mean: 

Form Validation

agilliam
Champ in-the-making
Champ in-the-making
I'm relatively new to Activiti and I've come across a problem that I haven't been able to figure out yet.

If I have a workflow similar to this…

[IMG]http://i61.tinypic.com/2mm7fpv.jpg[/IMG]

My start task form expects a single field: userId. ValidateUser is business logic to determine if the userId already exists in our system.

I'm starting the task via REST with the following cal which just gives me the handle to a process instance:

ProcessInstance processInstance = formService.submitStartFormData(processDefinition.getId(), startVariables);

What I'm not understanding provide feedback to the user via the rest response without having to continuously query or poll the database to check for a status update of what happens inside of ValidateUser? Is there not a built in way to do Start and Task form server side validation via the Activiti API?

My current workaround is to add a listener to Validate User and have the REST logic respond to an event triggered by the listener.



3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
Activiti executes the process instance until it finds a wait state. So that happens here: until the validate user is done and the next user task is reached, the engine keeps continuing. And at that point the rest call returns.

Not sure what you are looking for here? What would you expect?

agilliam
Champ in-the-making
Champ in-the-making
Thank for your timely response.

I'm looking for a a way to provide instant feedback to the form submitter via REST. Unless I'm missing something I see that I only have 3 options:

1. Move the business logic to validate the user outside of the process. I'd have to perform my form validation BEFORE my call: formService.submitStartFormData(). I'm not a big fan of that idea because I'd like the process to model my actual business process as closely as possible.

2. I could submit the form and write a loop that queries for a specific flag or state and then sleep n number of seconds before polling the database again. After the loop ends I can then return the proper status code indicating if the user validation passed or failed. Again, I'm not a big fan of this solution.

3. I could add a listener to Validate User and have the REST logic respond to complete event triggered by the listener.

Either way, in this case, the goal would be to give instant feedback to the user that the user name was either valid or invalid without having to make subsequent REST calls to check the status of the form validation step. Please advise as to other options if I missed them.

trademak
Star Contributor
Star Contributor
If I understand your requirements correctly, I think the service task should be changed to a async service task. This means that the user will immediately get feedback and then you can query the jobs to see if validation is ready.

Best regards,