Re: [Lift] Re: multiple forms on a page.

2010-01-06 Thread David Pollak
On Wed, Jan 6, 2010 at 12:13 AM, daiwhea daiw...@gmail.com wrote:

 Thanks David. Here is my repository:

 git://github.com/daiwhea/MapperBBS.git

 In fact, I want to share this simple demo project for the newbies like
 myself when the project completed.


Thanks.  I've committed fixes to http://github.com/dpp/MapperBBS

Basically, rather than doing the var thing and snippet thing, I just loaded
and bound the template.  It gets the job done and I prefer to explicitly
bind things and keeping state on the stack rather than in a var.



 On Jan 6, 11:42 am, David Pollak feeder.of.the.be...@gmail.com
 wrote:
  The easiest thing to do is for you to post your project as a complete
  runnable whole to GitHub (just make a public repository).
 
  I'll clone the repository, fix the issue and you'll see the diff and have
 a
  running project.  Sound good?
 
 
 
  On Tue, Jan 5, 2010 at 6:32 PM, daiwhea daiw...@gmail.com wrote:
 
   On Jan 5, 10:18 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
   Just move var localNote ... to before def doReply() ...
 
   -
 
   Thanks Naftoli. It does save a reply to the db after I move var
   localNote to before def doReply(). But It will only save reply to the
   last note even when I try to reply to the note in the top section.
 
   So, in order to see what happend, I add lift:embed what=/templates-
   hidden/gbook/replyForm / no matter the note was replied or not.
   When the page loaded, I saw all the textareas in each reply form has
   the same reply content of the last note. But both those textareas and
   submit buttons have different names. Seems lift doesn't deal the
   embeded template content in the snippet properly as wished.
 
   I also test to add eager_eval=true to the list template as:
   lift:GuestBook.list eager_eval=true. But this won't help.
 
   Thanks for your time. You're so warmhearted. ^_^
 
def replyNote(html: NodeSeq): NodeSeq = {
 
   val localNote = curListNote
 
  def doReply() = {
localNote.save
   }
 
  bind(note, html,
replyContent - SHtml.textarea(localNote.replyContent,
  localNote.replyContent(_)),
submit - SHtml.submit(Reply, doReply)
  )
}
 
 private def getReplyContent(item: GuestNote) = {
  if (item.repliedByAdmin == 0) {
 divpNot replied by admin/pp{item.replyContent}/
   plift:embed what=/templates-hidden/gbook/replyForm //div
  }
  else
 divp{Replied by admin at: +item.replyTime}/pp
   {item.replyContent}/plift:embed what=/templates-hidden/gbook/
   replyForm //div
}
 
   --
   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
 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com
 
   .
   For more options, visit this group at
  http://groups.google.com/group/liftweb?hl=en.
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Surf the harmonics

 --
 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.






-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
-- 

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.



Re: [Lift] Re: multiple forms on a page.

2010-01-05 Thread Naftoli Gugenheim
Just move var localNote ... to before def doReply() ...

-
daiwheadaiw...@gmail.com wrote:

Thanks David. But this seems not work as wished. It will meet some
error:

[INFO] Compiling 1 source files to /home/daiwhea/myworks/java/
liftonscala/MapperBBS/target/classes
/home/daiwhea/myworks/java/liftonscala/MapperBBS/src/main/scala/com/
vapee/main/snippet/GuestBook.scala:60: error: forward reference
extends over definition of variable localNote
  localNote.save
  ^
one error found
[INFO]

[ERROR] BUILD ERROR



Is there any error I made? Below is part of the GuestBook.scala for
list snippet:

  def list(html: NodeSeq): NodeSeq = {
toShow.flatMap(item = {
curListNote = item
bind(item, html,
  title - item.title,
  email - item.email,
  content - item.content,
  reply - getReplyContent(item)
)
  }
)
  }

  def replyNote(html: NodeSeq): NodeSeq = {
def doReply() = {
  localNote.save
}

var localNote = curListNote

bind(note, html,
  replyContent - SHtml.textarea(localNote.replyContent,
   localNote.replyContent(_)),
  submit - SHtml.submit(Reply, doReply)
)
  }

  private def toShow = GuestNote.findAll()

  var curListNote: GuestNote = _

  private def getReplyContent(item: GuestNote) = {
if (item.repliedByAdmin == 0) {
  divpNot replied by admin/plift:embed what=/templates-
hidden/gbook/replyForm //div
}
else
  divp{Replied by admin at: +item.replyTime}/plift:embed
what=/templates-hidden/gbook/replyForm //div
  }

--

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.


--

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.




Re: [Lift] Re: multiple forms on a page.

2010-01-05 Thread David Pollak
The easiest thing to do is for you to post your project as a complete
runnable whole to GitHub (just make a public repository).

I'll clone the repository, fix the issue and you'll see the diff and have a
running project.  Sound good?

On Tue, Jan 5, 2010 at 6:32 PM, daiwhea daiw...@gmail.com wrote:


 On Jan 5, 10:18 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Just move var localNote ... to before def doReply() ...

 -


 Thanks Naftoli. It does save a reply to the db after I move var
 localNote to before def doReply(). But It will only save reply to the
 last note even when I try to reply to the note in the top section.

 So, in order to see what happend, I add lift:embed what=/templates-
 hidden/gbook/replyForm / no matter the note was replied or not.
 When the page loaded, I saw all the textareas in each reply form has
 the same reply content of the last note. But both those textareas and
 submit buttons have different names. Seems lift doesn't deal the
 embeded template content in the snippet properly as wished.

 I also test to add eager_eval=true to the list template as:
 lift:GuestBook.list eager_eval=true. But this won't help.

 Thanks for your time. You're so warmhearted. ^_^


  def replyNote(html: NodeSeq): NodeSeq = {

 val localNote = curListNote

def doReply() = {
  localNote.save
 }

bind(note, html,
  replyContent - SHtml.textarea(localNote.replyContent,
localNote.replyContent(_)),
  submit - SHtml.submit(Reply, doReply)
)
  }

   private def getReplyContent(item: GuestNote) = {
if (item.repliedByAdmin == 0) {
   divpNot replied by admin/pp{item.replyContent}/
 plift:embed what=/templates-hidden/gbook/replyForm //div
}
else
   divp{Replied by admin at: +item.replyTime}/pp
 {item.replyContent}/plift:embed what=/templates-hidden/gbook/
 replyForm //div
  }

 --
 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.






-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
-- 

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.