I am trying to create a builder for my form fields and I come with something like:
class Select(name:String) {
object cell extends RequestVar("all")
/* Do some stuff with name and cell */
}
val fruitsField = new Select("fruits")
val drinksField = new Select("drinks")
Now I can do:
fruitsField.cell.set("tomato")
drinksField.cell.get // returns "tomato"
When using those fields I realized that cell was shared by fruits and drinks. I know that it is the normal behavior but is there a way to have this inner object cell to be non-static?
EDIT
I tried the following but it has the same behavior:
class Select(name:String) {
class ReqVar extends RequestVar("all")
val cell = new ReqVar
/* Do some stuff with name and cell */
}
Attention, the Lift documentation (2.4-M4) states about RequestVars (and SessionVars):
So you will have to do something like this:
Of course this will only work if there exists only one instance of Select with a given name per Request.
EDIT
Based on what you just posted