A completely stateless way could consist in storing all data in the URLs of steps, where the step n + 1
contains all data from step n
:
GET /step1 controllers.Application.step1
GET /step2 controllers.Application.step2(dataFromStep1)
GET /step3 controllers.Application.step3(dataFromStep1, dataFromStep2)
POST /finish controllers.Application.finish
The advantages of this solution are its simplicity and the fact that checking that all required steps have been completed before the next step is performed for free by the Play! router.
However, if you have a lot of data your URLs will be huge, making this solution less applicable. In such a case, you need to:
- save data of each step to a persistent storage (using the session is yet another option, but limited in size to 4KB) ;
- identify your users so e.g. the
/step2
URL won’t return the same thing for different users ;
- set a timeout to discard an incomplete submission and clean your persistent storage ;
- manually check in your business code that all steps have been completed for the final submission.