[Lift] Re: Using Stateful Snippets

2010-01-29 Thread Jay Cain
User[ id=0 email=, username = , created on=Fri Jan 29 10:57:27 MST
2010 role=Basic]

This value I get

On Jan 28, 10:44 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 You didn't answer my question. At the time the closure passed to redirectTo 
 is executed, what is the value of 'user'?

 -

 Jay Caincain@gmail.com wrote:

 it appears that the user still creates a new User.  it is because I
 tell it to do that each time a new request is made.

 // Set up a requestVar to track the user object
 object userVar extends RequestVar(new User())

 So I guess my question is how prevent it from doing that and still
 pass a User object to the RequestVar I tried a RequestVar[User] but no
 bueno

 below is the snippet code for registering a user

  user.password = passwordHashed
  user.activationCode = activationCode
  user.userProfile.user = user
  user.userPreferences.user = user
  Model.mergeAndFlush(user)
  MailUtils.mailConfirmationLetter(user)
  S.redirectTo(thank_you, () = { println(user); userVar(user);}

 In the mean time I'm going to just extract the email and fullname from
 the user and pass it as a request param

 user.password = passwordHashed
 user.activationCode = activationCode
 user.userProfile.user = user
 user.userPreferences.user = user
 Model.mergeAndFlush(user)
 MailUtils.mailConfirmationLetter(user)
 val email = user.email
 val fullName = user.userProfile.fullName
 println(email  + email)
 S.redirectTo(thank_you, () = {S.set(email, email); S.set
 (fullName, fullName);})

 Thanks for helping out

 On Jan 27, 10:20 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:



  Can you put a trace in that closure to see if 'user' has the correct value?
  S.redirectTo(thank_you, () = {println(user); userVar(user);})
  etc.

  On Wed, Jan 27, 2010 at 11:51 PM, Jay Cain cain@gmail.com wrote:
   I think that this would work

   // Set up a requestVar to track the user object
   object userVar extends RequestVar(new User())

   S.redirectTo(thank_you, () = {userVar(user);})

   but no bueno.

   On Jan 27, 4:56 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
When you redirect you start a new request, so RequestVars are fresh.
redirectTo has an overload that take additionally a function to execute
   in the new request. Set the RequestVar there.

-

Jay Caincain@gmail.com wrote:

I am a newbie to Lift and Scala.  I'm registering users and once they
have entered the information in successfully.  I want to redirect to a
thank_you page that will display a snippet

lift:UserOps.thanksMessage
        p
            entry:fullname/ thanks for joining Echo.  The
confirmation
                instructions for completing the signup process have been
   sent to
                your email address, entry:email/
        /p
/lift:UserOps.thanksMessage

I assume that when I redirect it doesn't hold the state of the user
information.

On submit I invoke signup

def signup(xhtml: NodeSeq) : NodeSeq = {
  
  S.redirectTo(thank_you)

}

ThanksMessage function

def thanksMessage(xhtml: NodeSeq) : NodeSeq = {
    print(Username:  + user.username)
    bind(entry, xhtml,
           fullname - Text(user.userProfile.fullName),
           email - Text(user.email))

}

I have declared a RequestVar object

** object userVar extends RequestVar(new User()) **

but I'm sure that it is creating an empty user object in my RequestVar
userVar when I redirect.

Is a StatefulSnippet the solution for this?  I just think that there's
a much simpler solution that I'm overlooking.

Jay

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

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

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

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group

[Lift] Re: Using Stateful Snippets

2010-01-29 Thread Jay Cain
It seems that you are correct. My user object is a JPA entity and when
it enters the closure it has a different identityHash 10749831 vs.
21737589.  This will probably be one of many issues that I will have
to deal with if I'm going to continue with JPA?  It's like the
entityManager loses reference to the entity object I persisted to the
db.  That's no good.  I'm starting this project from scratch and have
a java background is it easier to just pick up with Scala's persistent
architecture then continue with these little bumps in the road.

On Jan 29, 11:06 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
 And user is not a RequestVar, correct? So this is not a RequestVar problem 
 then?
 What is user? A JPA entity? Could this be a JPA issue?
 If you like you can use System.identityHashcode to demonstrate that the same 
 user instance is losing its data.

 -

 Jay Caincain@gmail.com wrote:

 User[ id=0 email=, username = , created on=Fri Jan 29 10:57:27 MST
 2010 role=Basic]

 This value I get

 On Jan 28, 10:44 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:



  You didn't answer my question. At the time the closure passed to redirectTo 
  is executed, what is the value of 'user'?

  -

  Jay Caincain@gmail.com wrote:

  it appears that the user still creates a new User.  it is because I
  tell it to do that each time a new request is made.

  // Set up a requestVar to track the user object
  object userVar extends RequestVar(new User())

  So I guess my question is how prevent it from doing that and still
  pass a User object to the RequestVar I tried a RequestVar[User] but no
  bueno

  below is the snippet code for registering a user

   user.password = passwordHashed
   user.activationCode = activationCode
   user.userProfile.user = user
   user.userPreferences.user = user
   Model.mergeAndFlush(user)
   MailUtils.mailConfirmationLetter(user)
   S.redirectTo(thank_you, () = { println(user); userVar(user);}

  In the mean time I'm going to just extract the email and fullname from
  the user and pass it as a request param

  user.password = passwordHashed
  user.activationCode = activationCode
  user.userProfile.user = user
  user.userPreferences.user = user
  Model.mergeAndFlush(user)
  MailUtils.mailConfirmationLetter(user)
  val email = user.email
  val fullName = user.userProfile.fullName
  println(email  + email)
  S.redirectTo(thank_you, () = {S.set(email, email); S.set
  (fullName, fullName);})

  Thanks for helping out

  On Jan 27, 10:20 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:

   Can you put a trace in that closure to see if 'user' has the correct 
   value?
   S.redirectTo(thank_you, () = {println(user); userVar(user);})
   etc.

   On Wed, Jan 27, 2010 at 11:51 PM, Jay Cain cain@gmail.com wrote:
I think that this would work

// Set up a requestVar to track the user object
object userVar extends RequestVar(new User())

S.redirectTo(thank_you, () = {userVar(user);})

but no bueno.

On Jan 27, 4:56 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 When you redirect you start a new request, so RequestVars are fresh.
 redirectTo has an overload that take additionally a function to 
 execute
in the new request. Set the RequestVar there.

 -

 Jay Caincain@gmail.com wrote:

 I am a newbie to Lift and Scala.  I'm registering users and once they
 have entered the information in successfully.  I want to redirect to a
 thank_you page that will display a snippet

 lift:UserOps.thanksMessage
         p
             entry:fullname/ thanks for joining Echo.  The
 confirmation
                 instructions for completing the signup process have 
 been
sent to
                 your email address, entry:email/
         /p
 /lift:UserOps.thanksMessage

 I assume that when I redirect it doesn't hold the state of the user
 information.

 On submit I invoke signup

 def signup(xhtml: NodeSeq) : NodeSeq = {
   
   S.redirectTo(thank_you)

 }

 ThanksMessage function

 def thanksMessage(xhtml: NodeSeq) : NodeSeq = {
     print(Username:  + user.username)
     bind(entry, xhtml,
            fullname - Text(user.userProfile.fullName),
            email - Text(user.email))

 }

 I have declared a RequestVar object

 ** object userVar extends RequestVar(new User()) **

 but I'm sure that it is creating an empty user object in my RequestVar
 userVar when I redirect.

 Is a StatefulSnippet the solution for this?  I just think that there's
 a much simpler solution that I'm overlooking.

 Jay

 --
 You received this message because you are subscribed to the Google 
 Groups
Lift group.
 To post to this group, send email to lift...@googlegroups.com

[Lift] Re: Using Stateful Snippets

2010-01-28 Thread Jay Cain
it appears that the user still creates a new User.  it is because I
tell it to do that each time a new request is made.

// Set up a requestVar to track the user object
object userVar extends RequestVar(new User())

So I guess my question is how prevent it from doing that and still
pass a User object to the RequestVar I tried a RequestVar[User] but no
bueno

below is the snippet code for registering a user

 user.password = passwordHashed
 user.activationCode = activationCode
 user.userProfile.user = user
 user.userPreferences.user = user
 Model.mergeAndFlush(user)
 MailUtils.mailConfirmationLetter(user)
 S.redirectTo(thank_you, () = { println(user); userVar(user);}

In the mean time I'm going to just extract the email and fullname from
the user and pass it as a request param

user.password = passwordHashed
user.activationCode = activationCode
user.userProfile.user = user
user.userPreferences.user = user
Model.mergeAndFlush(user)
MailUtils.mailConfirmationLetter(user)
val email = user.email
val fullName = user.userProfile.fullName
println(email  + email)
S.redirectTo(thank_you, () = {S.set(email, email); S.set
(fullName, fullName);})


Thanks for helping out

On Jan 27, 10:20 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Can you put a trace in that closure to see if 'user' has the correct value?
 S.redirectTo(thank_you, () = {println(user); userVar(user);})
 etc.

 On Wed, Jan 27, 2010 at 11:51 PM, Jay Cain cain@gmail.com wrote:
  I think that this would work

  // Set up a requestVar to track the user object
  object userVar extends RequestVar(new User())

  S.redirectTo(thank_you, () = {userVar(user);})

  but no bueno.

  On Jan 27, 4:56 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
   When you redirect you start a new request, so RequestVars are fresh.
   redirectTo has an overload that take additionally a function to execute
  in the new request. Set the RequestVar there.

   -

   Jay Caincain@gmail.com wrote:

   I am a newbie to Lift and Scala.  I'm registering users and once they
   have entered the information in successfully.  I want to redirect to a
   thank_you page that will display a snippet

   lift:UserOps.thanksMessage
           p
               entry:fullname/ thanks for joining Echo.  The
   confirmation
                   instructions for completing the signup process have been
  sent to
                   your email address, entry:email/
           /p
   /lift:UserOps.thanksMessage

   I assume that when I redirect it doesn't hold the state of the user
   information.

   On submit I invoke signup

   def signup(xhtml: NodeSeq) : NodeSeq = {
     
     S.redirectTo(thank_you)

   }

   ThanksMessage function

   def thanksMessage(xhtml: NodeSeq) : NodeSeq = {
       print(Username:  + user.username)
       bind(entry, xhtml,
              fullname - Text(user.userProfile.fullName),
              email - Text(user.email))

   }

   I have declared a RequestVar object

   ** object userVar extends RequestVar(new User()) **

   but I'm sure that it is creating an empty user object in my RequestVar
   userVar when I redirect.

   Is a StatefulSnippet the solution for this?  I just think that there's
   a much simpler solution that I'm overlooking.

   Jay

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

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



-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.



[Lift] Using Stateful Snippets

2010-01-27 Thread Jay Cain
I am a newbie to Lift and Scala.  I'm registering users and once they
have entered the information in successfully.  I want to redirect to a
thank_you page that will display a snippet

lift:UserOps.thanksMessage
p
entry:fullname/ thanks for joining Echo.  The
confirmation
instructions for completing the signup process have been sent to
your email address, entry:email/
/p
/lift:UserOps.thanksMessage

I assume that when I redirect it doesn't hold the state of the user
information.

On submit I invoke signup

def signup(xhtml: NodeSeq) : NodeSeq = {
  
  S.redirectTo(thank_you)
}


ThanksMessage function

def thanksMessage(xhtml: NodeSeq) : NodeSeq = {
print(Username:  + user.username)
bind(entry, xhtml,
   fullname - Text(user.userProfile.fullName),
   email - Text(user.email))
}



I have declared a RequestVar object

** object userVar extends RequestVar(new User()) **

but I'm sure that it is creating an empty user object in my RequestVar
userVar when I redirect.

Is a StatefulSnippet the solution for this?  I just think that there's
a much simpler solution that I'm overlooking.

Jay

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.



[Lift] Re: Using Stateful Snippets

2010-01-27 Thread Jay Cain
I think that this would work

// Set up a requestVar to track the user object
object userVar extends RequestVar(new User())

S.redirectTo(thank_you, () = {userVar(user);})

but no bueno.

On Jan 27, 4:56 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 When you redirect you start a new request, so RequestVars are fresh.
 redirectTo has an overload that take additionally a function to execute in 
 the new request. Set the RequestVar there.

 -

 Jay Caincain@gmail.com wrote:

 I am a newbie to Lift and Scala.  I'm registering users and once they
 have entered the information in successfully.  I want to redirect to a
 thank_you page that will display a snippet

 lift:UserOps.thanksMessage
         p
             entry:fullname/ thanks for joining Echo.  The
 confirmation
                 instructions for completing the signup process have been sent 
 to
                 your email address, entry:email/
         /p
 /lift:UserOps.thanksMessage

 I assume that when I redirect it doesn't hold the state of the user
 information.

 On submit I invoke signup

 def signup(xhtml: NodeSeq) : NodeSeq = {
   
   S.redirectTo(thank_you)

 }

 ThanksMessage function

 def thanksMessage(xhtml: NodeSeq) : NodeSeq = {
     print(Username:  + user.username)
     bind(entry, xhtml,
            fullname - Text(user.userProfile.fullName),
            email - Text(user.email))

 }

 I have declared a RequestVar object

 ** object userVar extends RequestVar(new User()) **

 but I'm sure that it is creating an empty user object in my RequestVar
 userVar when I redirect.

 Is a StatefulSnippet the solution for this?  I just think that there's
 a much simpler solution that I'm overlooking.

 Jay

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

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.



[Lift] onkeypress

2010-01-18 Thread Jay Cain
Is there a SHtml.ajaxText equivalent that will perfrom an ajax call
when the onkeyPress is invoked?  I want the ability to query the db to
see if a particular username is available or unavailable each time
the user types in a letter within the input field.  I can only get
this accomplished on blur.

I tried the following:

SHtml.text(user.username, user.username = _)  % (onkeyPress -
ajaxCall(JE.JsRaw($('#username').attr('value')), s =
isUsernameAvailable(s))) }

but no bueno

Jay C.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.




[Lift] Ajax text onKeyPress

2010-01-18 Thread Jay Cain
Is there a SHtml.ajaxText equivalent that will perfrom an ajax call
when the onkeyPress is invoked?  I want the ability to query the db to
see if a particular username is available or unavailable each time
the user types in a letter within the input field.  I can only get
this accomplished on blur.

I tried the following:

SHtml.text(user.username, user.username = _)  % (onkeyPress -
ajaxCall(JE.JsRaw($('#username').attr('value')), s =
isUsernameAvailable(s))) }

but no bueno

Jay C.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.




[Lift] Re: Ajax text onKeyPress

2010-01-18 Thread Jay Cain
Works like a charm.

Gracias.

On Jan 18, 10:46 am, ced docpom...@googlemail.com wrote:
 You may try this:

 def ajaxLiveText(value: String, func: String = JsCmd, attrs: (String,
 String)*): Elem = {
         S.fmapFunc(S.SFuncHolder(func)) {funcName =
             (attrs.foldLeft(input type=text value={value}/)(_ %
 _)) %
                     (onkeyup - makeAjaxCall(JsRaw(' + funcName +
 =' + encodeURIComponent(this.value
         }
     }

 It works like SHtml.ajaxText, but calls the server after each key
 press.

 Cheers,
 Chris

 On 18 Jan., 07:36, Jay Cain cain@gmail.com wrote:

  Is there a SHtml.ajaxText equivalent that will perfrom an ajax call
  when the onkeyPress is invoked?  I want the ability to query the db to
  see if a particular username is available or unavailable each time
  the user types in a letter within the input field.  I can only get
  this accomplished on blur.

  I tried the following:

  SHtml.text(user.username, user.username = _)  % (onkeyPress -
  ajaxCall(JE.JsRaw($('#username').attr('value')), s =
  isUsernameAvailable(s))) }

  but no bueno

  Jay C.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.