Hello, I'm writing a simple page that takes a bunch of input from a user and generates some XML from their responses.
The input is gathered by a simple HTML form, however there is quite a bit of data and I decided to split it into 3 or 4 pages.
I've made a class called FormObject that has fields for ALL the input needed.
The problem is theres no way to pass this object between pages.
I was thinking maybe a service with the scope of session would allow me to keep a reference to a FormObject and just call a method from the service to get it again.
IE:
The service looks like this:Code:<g:set var="formService" value="${new FormService()}" /> //(after page importing it of course)
And the call in the page is like this:Code:class FormService{ static transactional = false static scope = "session" FormObject myObject = new FormObject() def resetForm(){ myObject=new FormObject() } def getForm(){ return myObject } }
However the data doesn't persist between pages.Code:<g:set var="myForm" value="${formService.getForm()}" />
It does persist if I define the myObject property as static, but I'm worried that when this hits production, the myObject will be shared across all users.
Can anyone confirm what would happen if I made it static?
Would each session have a static form object or would there only be one static form object?


Reply With Quote