Hi,

I seem to have a problem with SessionVars which I try to initialize in
a LocRewrite.

This is an entry point url to the app. It receives some parameters from
the url, picks out the parameters and puts them in SessionVars and
rewrites the request.

I have problems setting the SessionVar when I hit the url in a clean
browser (ie with no session)

This is the code:
  private object curAccountId extends SessionVar[Box[Long]](Empty)
  
  private object curAccount extends RequestVar[Box[Account]] ({
    println("read:"+curAccountId);
    val found = currentAccountId.flatMap(id => getSingleton.find(id));
    println("Found: "+found);
    found})  with CleanRequestVarOnSessionTransition
 
  def currentAccountId: Box[Long] = curAccountId.is
  def currentAccount: Box[Account] = curAccount.is
  def currentAccount_=(account: Box[Account]) {
    println("set account: "+account);
    curAccount.remove
    curAccountId.remove
    curAccountId.set({val s = account.map{a => a.id.is}; println("set: "+s);s});
    curAccount.set(account); 
    println("read2:"+curAccountId.is)
  }
 
In the LocRewrite I call Account.setCurrentAccount = someAccount

When the URL is hit in a clean browser, this is logged:

set account: Full(dk.fleetzone.model.Account={name=Demo Account,id=1})
set: Full(1)
read2:Empty

If I hit the login page first (and nothing else, but I believe it triggers the
creation of a http session), and the exact same url, this is logged:

set account: Full(dk.fleetzone.model.Account={name=Demo Account,id=1})
set: Full(1)
read2:Full(1)

Any clues?? 

/Jeppe





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to