[Lift] Re: can a Snippet call a Snippet?

2009-07-03 Thread Alexander Azarov

I vote for this! Personally I do not completely understand all the
possibilities Failure gives and how to achieve these. BTW, I found
recently the appendix about Boxes disappeared from the printed Lift
book :(

On Jul 2, 5:55 pm, Timothy Perrett timo...@getintheloop.eu wrote:
 We really ought to get around to writing a ³guides for boxes² - its easily
 one of the most confusing concepts in lift (a magnitude less confusing
 than when it was called Can[T])

 Cheers, Tim

 On 02/07/2009 14:46, David Pollak feeder.of.the.be...@gmail.com wrote:





  On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote:

  I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
  (todos).open_!

  Don't use open_!  It's dangerous.

  That's why Boxes exist.  They contain (or don't) something that may or may 
  not
  exist.  If you use open_! in your code, it is a major mistake (a logic 
  error)
  unless the line before the open contains if (thing.isDefined) {

  Thanks,

  David
   

  Here's my layout:

  todo.html template 

  lift:TD.listTodos todos=todos
  --- Todo list table stuff ---
  lift:TD.listTags tags=tags
  --- Tag list table stuff (where the selection to filter comes from)
  ---

  TD.scala snippet =

  // this arity is for the default 'show all Todos' condition
  def list(html: NodeSeq) = {
      val id = S.attr(todos).open_!

  // this arity is for the 'filter by Tag' case
  def list(filterTag: Long)(html: NodeSeq) = {
      val id = S.attr(todos).open_!

  The two snippet methods could probably be combined with a (param:
  Long*) signature, but Scala does not seem to care right now. The
  default works perfectly, but when a Tag is selected to filter by, the
  'todos' id Box cannot be seen when attempting to open.

  Is this because it is probably out of scope? I am using an ajaxbutton
  to make the call and pass in the tag.id http://tag.id , but it is hard to
  see how an
  S.attr could exist for one request, then be gone for the next, unless
  I am confusing this with a stateful attribute.

  On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
   On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:

I will look into the nested snippets.

For expediency, I folded all the snippets that interact with my
template into one file, so I can concentrate on the business logic.

For my Todo app enhancement, I need to pass the id of my selected Tag
(which I have confirmed is correctly gathered from the page request)
in to the TD.list method, so that the filtered Todos (those bearing
the required Tag) will be found and rendered.

My problem is that if I try to pass an additional argument (tagId:
Long), the TD.list method is not happy and will not even render the
template.

I have tried both paired (html: NodeSeq, tagId: Long) as well as
curried style (html: NodeSeq)(tagId: Long), but neither works.

   Try:

   list(tagId: Long)(html: NodeSeq): NodeSeq

   That way list(44L) _ becomes a NodeSeq = NodeSeq

There must be a simple way to accomplish such a common task!

Thanks to all the members for commenting...

On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
 Or you can use S.locateMappedSnippet ... but first try to see if
 nested snippet won't do the trick for you ...

 On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:

  Can you paste some code?

  Essentially we support nested snippets so your snippet can 
  simply
  return a markup containing another snippet and it will be
  invoked. If
  you really want to manually invoke a snippet from another 
  snippet
 and
  if you are not using StatefulSnippets you can just instantiate
 the
  class and call your function and pass it the right NodeSeq.

  Br's,
  Marius

  On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:

   I am enhancing the Todo app by adding tags.

   I have retained the TD.scala snippet to manage the Todos on 
   my
 page,
   and added a TG.scala snippet to handle tags on the same 
   page,
 which
   works well for creating new and listing in both cases.

   Now I want to filter my Todos list by a Tag instance I 
   select
 from my
   list, and therefore need to pass the id of the selected tag
 over from
   the TG snippet to the TD snippet, where it can be used as a
 filter
   argument for a find method.

   The problem is that scala says it cannot find snippet TD,
 whose
method
   I am calling as TD.list from the TG.scala snippet. I have
 tried all
   kinds of explicit importing, but no luck.

   So,  can a snippet call a snippet, or is that controlled 
   only
 from
the
   web page?- Hide quoted text -

 - Show quoted text -

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
  http://liftweb.net
   Beginning 

[Lift] Re: can a Snippet call a Snippet?

2009-07-03 Thread Derek Chen-Becker
Yes, it's available on the APress website. It was omitted due to an issue
with the APress workflow :(

http://www.apress.com/book/view/1430224215

Derek

On Fri, Jul 3, 2009 at 8:22 AM, Alexander Azarov alaz...@gmail.com wrote:


 I vote for this! Personally I do not completely understand all the
 possibilities Failure gives and how to achieve these. BTW, I found
 recently the appendix about Boxes disappeared from the printed Lift
 book :(

 On Jul 2, 5:55 pm, Timothy Perrett timo...@getintheloop.eu wrote:
  We really ought to get around to writing a ³guides for boxes² - its
 easily
  one of the most confusing concepts in lift (a magnitude less
 confusing
  than when it was called Can[T])
 
  Cheers, Tim
 
  On 02/07/2009 14:46, David Pollak feeder.of.the.be...@gmail.com
 wrote:
 
 
 
 
 
   On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote:
 
   I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
   (todos).open_!
 
   Don't use open_!  It's dangerous.
 
   That's why Boxes exist.  They contain (or don't) something that may or
 may not
   exist.  If you use open_! in your code, it is a major mistake (a logic
 error)
   unless the line before the open contains if (thing.isDefined) {
 
   Thanks,
 
   David
  
 
   Here's my layout:
 
   todo.html template 
 
   lift:TD.listTodos todos=todos
   --- Todo list table stuff ---
   lift:TD.listTags tags=tags
   --- Tag list table stuff (where the selection to filter comes from)
   ---
 
   TD.scala snippet =
 
   // this arity is for the default 'show all Todos' condition
   def list(html: NodeSeq) = {
   val id = S.attr(todos).open_!
 
   // this arity is for the 'filter by Tag' case
   def list(filterTag: Long)(html: NodeSeq) = {
   val id = S.attr(todos).open_!
 
   The two snippet methods could probably be combined with a (param:
   Long*) signature, but Scala does not seem to care right now. The
   default works perfectly, but when a Tag is selected to filter by, the
   'todos' id Box cannot be seen when attempting to open.
 
   Is this because it is probably out of scope? I am using an ajaxbutton
   to make the call and pass in the tag.id http://tag.id , but it is
 hard to
   see how an
   S.attr could exist for one request, then be gone for the next, unless
   I am confusing this with a stateful attribute.
 
   On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com
 wrote:
On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:
 
 I will look into the nested snippets.
 
 For expediency, I folded all the snippets that interact with my
 template into one file, so I can concentrate on the business
 logic.
 
 For my Todo app enhancement, I need to pass the id of my
 selected Tag
 (which I have confirmed is correctly gathered from the page
 request)
 in to the TD.list method, so that the filtered Todos (those
 bearing
 the required Tag) will be found and rendered.
 
 My problem is that if I try to pass an additional argument
 (tagId:
 Long), the TD.list method is not happy and will not even render
 the
 template.
 
 I have tried both paired (html: NodeSeq, tagId: Long) as well as
 curried style (html: NodeSeq)(tagId: Long), but neither works.
 
Try:
 
list(tagId: Long)(html: NodeSeq): NodeSeq
 
That way list(44L) _ becomes a NodeSeq = NodeSeq
 
 There must be a simple way to accomplish such a common task!
 
 Thanks to all the members for commenting...
 
 On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com
 wrote:
  Or you can use S.locateMappedSnippet ... but first try to see
 if
  nested snippet won't do the trick for you ...
 
  On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com
 wrote:
 
   Can you paste some code?
 
   Essentially we support nested snippets so your snippet can
 simply
   return a markup containing another snippet and it will be
   invoked. If
   you really want to manually invoke a snippet from another
 snippet
  and
   if you are not using StatefulSnippets you can just
 instantiate
  the
   class and call your function and pass it the right
 NodeSeq.
 
   Br's,
   Marius
 
   On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:
 
I am enhancing the Todo app by adding tags.
 
I have retained the TD.scala snippet to manage the
 Todos on my
  page,
and added a TG.scala snippet to handle tags on the same
 page,
  which
works well for creating new and listing in both cases.
 
Now I want to filter my Todos list by a Tag instance I
 select
  from my
list, and therefore need to pass the id of the selected
 tag
  over from
the TG snippet to the TD snippet, where it can be used
 as a
  filter
argument for a find method.
 
The problem is that scala says it cannot find snippet
 TD,
  whose
 method
I am calling as TD.list from the TG.scala 

[Lift] Re: can a Snippet call a Snippet?

2009-07-02 Thread David Pollak
On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote:


 I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
 (todos).open_!


Don't use open_!  It's dangerous.

That's why Boxes exist.  They contain (or don't) something that may or may
not exist.  If you use open_! in your code, it is a major mistake (a logic
error) unless the line before the open contains if (thing.isDefined) {

Thanks,

David




 Here's my layout:

 todo.html template 

 lift:TD.listTodos todos=todos
 --- Todo list table stuff ---
 lift:TD.listTags tags=tags
 --- Tag list table stuff (where the selection to filter comes from)
 ---

 TD.scala snippet =

 // this arity is for the default 'show all Todos' condition
 def list(html: NodeSeq) = {
val id = S.attr(todos).open_!

 // this arity is for the 'filter by Tag' case
 def list(filterTag: Long)(html: NodeSeq) = {
val id = S.attr(todos).open_!

 The two snippet methods could probably be combined with a (param:
 Long*) signature, but Scala does not seem to care right now. The
 default works perfectly, but when a Tag is selected to filter by, the
 'todos' id Box cannot be seen when attempting to open.

 Is this because it is probably out of scope? I am using an ajaxbutton
 to make the call and pass in the tag.id, but it is hard to see how an
 S.attr could exist for one request, then be gone for the next, unless
 I am confusing this with a stateful attribute.


 On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
  On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:
 
   I will look into the nested snippets.
 
   For expediency, I folded all the snippets that interact with my
   template into one file, so I can concentrate on the business logic.
 
   For my Todo app enhancement, I need to pass the id of my selected Tag
   (which I have confirmed is correctly gathered from the page request)
   in to the TD.list method, so that the filtered Todos (those bearing
   the required Tag) will be found and rendered.
 
   My problem is that if I try to pass an additional argument (tagId:
   Long), the TD.list method is not happy and will not even render the
   template.
 
   I have tried both paired (html: NodeSeq, tagId: Long) as well as
   curried style (html: NodeSeq)(tagId: Long), but neither works.
 
  Try:
 
  list(tagId: Long)(html: NodeSeq): NodeSeq
 
  That way list(44L) _ becomes a NodeSeq = NodeSeq
 
 
 
 
 
   There must be a simple way to accomplish such a common task!
 
   Thanks to all the members for commenting...
 
   On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
Or you can use S.locateMappedSnippet ... but first try to see if
nested snippet won't do the trick for you ...
 
On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:
 
 Can you paste some code?
 
 Essentially we support nested snippets so your snippet can simply
 return a markup containing another snippet and it will be invoked.
 If
 you really want to manually invoke a snippet from another snippet
 and
 if you are not using StatefulSnippets you can just instantiate the
 class and call your function and pass it the right NodeSeq.
 
 Br's,
 Marius
 
 On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:
 
  I am enhancing the Todo app by adding tags.
 
  I have retained the TD.scala snippet to manage the Todos on my
 page,
  and added a TG.scala snippet to handle tags on the same page,
 which
  works well for creating new and listing in both cases.
 
  Now I want to filter my Todos list by a Tag instance I select
 from my
  list, and therefore need to pass the id of the selected tag over
 from
  the TG snippet to the TD snippet, where it can be used as a
 filter
  argument for a find method.
 
  The problem is that scala says it cannot find snippet TD, whose
   method
  I am calling as TD.list from the TG.scala snippet. I have tried
 all
  kinds of explicit importing, but no luck.
 
  So,  can a snippet call a snippet, or is that controlled only
 from
   the
  web page?- Hide quoted text -
 
- Show quoted text -
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp
 



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

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

[Lift] Re: can a Snippet call a Snippet?

2009-07-02 Thread g-man

The open_! came right from the 'Getting Started' Todo tutorial I am
enhancing:

Listing 17:  list method in TD class
def list(html: NodeSeq) = {
 val id = S.attr(all_id).open_!

Nevertheless, the question remains: How can I filter the Todo items by
a Tag and render the list?

I guess I could always link to a new page and let the template drive
the snippet, but I kind of wanted to keep one page open and just do
AJAX stuff within div elements.

Thanks again..


On Jul 2, 5:46 am, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote:

  I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
  (todos).open_!

 Don't use open_!  It's dangerous.

 That's why Boxes exist.  They contain (or don't) something that may or may
 not exist.  If you use open_! in your code, it is a major mistake (a logic
 error) unless the line before the open contains if (thing.isDefined) {

 Thanks,

 David







  Here's my layout:

  todo.html template 

  lift:TD.listTodos todos=todos
  --- Todo list table stuff ---
  lift:TD.listTags tags=tags
  --- Tag list table stuff (where the selection to filter comes from)
  ---

  TD.scala snippet =

  // this arity is for the default 'show all Todos' condition
  def list(html: NodeSeq) = {
     val id = S.attr(todos).open_!

  // this arity is for the 'filter by Tag' case
  def list(filterTag: Long)(html: NodeSeq) = {
     val id = S.attr(todos).open_!

  The two snippet methods could probably be combined with a (param:
  Long*) signature, but Scala does not seem to care right now. The
  default works perfectly, but when a Tag is selected to filter by, the
  'todos' id Box cannot be seen when attempting to open.

  Is this because it is probably out of scope? I am using an ajaxbutton
  to make the call and pass in the tag.id, but it is hard to see how an
  S.attr could exist for one request, then be gone for the next, unless
  I am confusing this with a stateful attribute.

  On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
   On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:

I will look into the nested snippets.

For expediency, I folded all the snippets that interact with my
template into one file, so I can concentrate on the business logic.

For my Todo app enhancement, I need to pass the id of my selected Tag
(which I have confirmed is correctly gathered from the page request)
in to the TD.list method, so that the filtered Todos (those bearing
the required Tag) will be found and rendered.

My problem is that if I try to pass an additional argument (tagId:
Long), the TD.list method is not happy and will not even render the
template.

I have tried both paired (html: NodeSeq, tagId: Long) as well as
curried style (html: NodeSeq)(tagId: Long), but neither works.

   Try:

   list(tagId: Long)(html: NodeSeq): NodeSeq

   That way list(44L) _ becomes a NodeSeq = NodeSeq

There must be a simple way to accomplish such a common task!

Thanks to all the members for commenting...

On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
 Or you can use S.locateMappedSnippet ... but first try to see if
 nested snippet won't do the trick for you ...

 On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:

  Can you paste some code?

  Essentially we support nested snippets so your snippet can simply
  return a markup containing another snippet and it will be invoked.
  If
  you really want to manually invoke a snippet from another snippet
  and
  if you are not using StatefulSnippets you can just instantiate the
  class and call your function and pass it the right NodeSeq.

  Br's,
  Marius

  On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:

   I am enhancing the Todo app by adding tags.

   I have retained the TD.scala snippet to manage the Todos on my
  page,
   and added a TG.scala snippet to handle tags on the same page,
  which
   works well for creating new and listing in both cases.

   Now I want to filter my Todos list by a Tag instance I select
  from my
   list, and therefore need to pass the id of the selected tag over
  from
   the TG snippet to the TD snippet, where it can be used as a
  filter
   argument for a find method.

   The problem is that scala says it cannot find snippet TD, whose
method
   I am calling as TD.list from the TG.scala snippet. I have tried
  all
   kinds of explicit importing, but no luck.

   So,  can a snippet call a snippet, or is that controlled only
  from
the
   web page?- Hide quoted text -

 - Show quoted text -

   --
   Lift, the simply functional web frameworkhttp://liftweb.net
   Beginning Scalahttp://www.apress.com/book/view/1430219890
   Follow me:http://twitter.com/dpp
   Git some:http://github.com/dpp

 --
 

[Lift] Re: can a Snippet call a Snippet?

2009-07-02 Thread David Pollak
On Thu, Jul 2, 2009 at 6:55 AM, Timothy Perrett timo...@getintheloop.euwrote:


 We really ought to get around to writing a “guides for boxes” - its easily
 one of the most confusing concepts in lift (a magnitude less confusing
 than when it was called Can[T])


http://blog.lostlake.org/index.php?/archives/50-The-Scala-Option-class-and-how-lift-uses-it.html

Options and Boxes are very similar, although Boxes have Failure as well as
Empty (None)

Also, note that the code in the example is Scala 2.3 era code, so some
syntax has changed.




 Cheers, Tim


 On 02/07/2009 14:46, David Pollak feeder.of.the.be...@gmail.com wrote:



 On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote:


 I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
 (todos).open_!


 Don't use open_!  It's dangerous.

 That's why Boxes exist.  They contain (or don't) something that may or may
 not exist.  If you use open_! in your code, it is a major mistake (a logic
 error) unless the line before the open contains if (thing.isDefined) {

 Thanks,

 David




 Here's my layout:

 todo.html template 

 lift:TD.listTodos todos=todos
 --- Todo list table stuff ---
 lift:TD.listTags tags=tags
 --- Tag list table stuff (where the selection to filter comes from)
 ---

 TD.scala snippet =

 // this arity is for the default 'show all Todos' condition
 def list(html: NodeSeq) = {
 val id = S.attr(todos).open_!

 // this arity is for the 'filter by Tag' case
 def list(filterTag: Long)(html: NodeSeq) = {
 val id = S.attr(todos).open_!

 The two snippet methods could probably be combined with a (param:
 Long*) signature, but Scala does not seem to care right now. The
 default works perfectly, but when a Tag is selected to filter by, the
 'todos' id Box cannot be seen when attempting to open.

 Is this because it is probably out of scope? I am using an ajaxbutton
 to make the call and pass in the tag.id http://tag.id , but it is hard
 to see how an

 S.attr could exist for one request, then be gone for the next, unless
 I am confusing this with a stateful attribute.


 On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
  On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:
 
   I will look into the nested snippets.
 
   For expediency, I folded all the snippets that interact with my
   template into one file, so I can concentrate on the business logic.
 
   For my Todo app enhancement, I need to pass the id of my selected Tag
   (which I have confirmed is correctly gathered from the page request)
   in to the TD.list method, so that the filtered Todos (those bearing
   the required Tag) will be found and rendered.
 
   My problem is that if I try to pass an additional argument (tagId:
   Long), the TD.list method is not happy and will not even render the
   template.
 
   I have tried both paired (html: NodeSeq, tagId: Long) as well as
   curried style (html: NodeSeq)(tagId: Long), but neither works.
 
  Try:
 
  list(tagId: Long)(html: NodeSeq): NodeSeq
 
  That way list(44L) _ becomes a NodeSeq = NodeSeq
 
 
 
 
 
   There must be a simple way to accomplish such a common task!
 
   Thanks to all the members for commenting...
 
   On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
Or you can use S.locateMappedSnippet ... but first try to see if
nested snippet won't do the trick for you ...
 
On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:
 
 Can you paste some code?
 
 Essentially we support nested snippets so your snippet can simply
 return a markup containing another snippet and it will be invoked.
 If
 you really want to manually invoke a snippet from another snippet
 and
 if you are not using StatefulSnippets you can just instantiate the
 class and call your function and pass it the right NodeSeq.
 
 Br's,
 Marius
 
 On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:
 
  I am enhancing the Todo app by adding tags.
 
  I have retained the TD.scala snippet to manage the Todos on my
 page,
  and added a TG.scala snippet to handle tags on the same page,
 which
  works well for creating new and listing in both cases.
 
  Now I want to filter my Todos list by a Tag instance I select
 from my
  list, and therefore need to pass the id of the selected tag over
 from
  the TG snippet to the TD snippet, where it can be used as a
 filter
  argument for a find method.
 
  The problem is that scala says it cannot find snippet TD, whose
   method
  I am calling as TD.list from the TG.scala snippet. I have tried
 all
  kinds of explicit importing, but no luck.
 
  So,  can a snippet call a snippet, or is that controlled only
 from
   the
  web page?- Hide quoted text -
 
- Show quoted text -
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net 
 http://liftweb.net
  Beginning 

[Lift] Re: can a Snippet call a Snippet?

2009-07-02 Thread Timothy Perrett

But of course ­ I know this :-)

Thinking back to when I first started scala a couple of years ago I just
couldn¹t understand why you wanted to put something in a box... Your article
does a good job of explaining, but I think we could do with some specific
documentation.

Cheers, Tim

On 02/07/2009 15:04, David Pollak feeder.of.the.be...@gmail.com wrote:

 http://blog.lostlake.org/index.php?/archives/50-The-Scala-Option-class-and-how
 -lift-uses-it.html
 
 Options and Boxes are very similar, although Boxes have Failure as well as
 Empty (None)
 
 Also, note that the code in the example is Scala 2.3 era code, so some syntax
 has changed.
  


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



[Lift] Re: can a Snippet call a Snippet?

2009-07-02 Thread Timothy Perrett

We really ought to get around to writing a ³guides for boxes² - its easily
one of the most confusing concepts in lift (a magnitude less confusing
than when it was called Can[T])

Cheers, Tim

On 02/07/2009 14:46, David Pollak feeder.of.the.be...@gmail.com wrote:

 
 
 On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote:
 
 I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
 (todos).open_!
 
 Don't use open_!  It's dangerous.
 
 That's why Boxes exist.  They contain (or don't) something that may or may not
 exist.  If you use open_! in your code, it is a major mistake (a logic error)
 unless the line before the open contains if (thing.isDefined) {
 
 Thanks,
 
 David
  
 
 
 Here's my layout:
 
 todo.html template 
 
 lift:TD.listTodos todos=todos
 --- Todo list table stuff ---
 lift:TD.listTags tags=tags
 --- Tag list table stuff (where the selection to filter comes from)
 ---
 
 TD.scala snippet =
 
 // this arity is for the default 'show all Todos' condition
 def list(html: NodeSeq) = {
     val id = S.attr(todos).open_!
 
 // this arity is for the 'filter by Tag' case
 def list(filterTag: Long)(html: NodeSeq) = {
     val id = S.attr(todos).open_!
 
 The two snippet methods could probably be combined with a (param:
 Long*) signature, but Scala does not seem to care right now. The
 default works perfectly, but when a Tag is selected to filter by, the
 'todos' id Box cannot be seen when attempting to open.
 
 Is this because it is probably out of scope? I am using an ajaxbutton
 to make the call and pass in the tag.id http://tag.id , but it is hard to
 see how an
 S.attr could exist for one request, then be gone for the next, unless
 I am confusing this with a stateful attribute.
 
 
 On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
  On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:
 
   I will look into the nested snippets.
 
   For expediency, I folded all the snippets that interact with my
   template into one file, so I can concentrate on the business logic.
 
   For my Todo app enhancement, I need to pass the id of my selected Tag
   (which I have confirmed is correctly gathered from the page request)
   in to the TD.list method, so that the filtered Todos (those bearing
   the required Tag) will be found and rendered.
 
   My problem is that if I try to pass an additional argument (tagId:
   Long), the TD.list method is not happy and will not even render the
   template.
 
   I have tried both paired (html: NodeSeq, tagId: Long) as well as
   curried style (html: NodeSeq)(tagId: Long), but neither works.
 
  Try:
 
  list(tagId: Long)(html: NodeSeq): NodeSeq
 
  That way list(44L) _ becomes a NodeSeq = NodeSeq
 
 
 
 
 
   There must be a simple way to accomplish such a common task!
 
   Thanks to all the members for commenting...
 
   On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
Or you can use S.locateMappedSnippet ... but first try to see if
nested snippet won't do the trick for you ...
 
On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:
 
 Can you paste some code?
 
 Essentially we support nested snippets so your snippet can simply
 return a markup containing another snippet and it will be
 invoked. If
 you really want to manually invoke a snippet from another snippet
and
 if you are not using StatefulSnippets you can just instantiate
the
 class and call your function and pass it the right NodeSeq.
 
 Br's,
 Marius
 
 On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:
 
  I am enhancing the Todo app by adding tags.
 
  I have retained the TD.scala snippet to manage the Todos on my
page,
  and added a TG.scala snippet to handle tags on the same page,
which
  works well for creating new and listing in both cases.
 
  Now I want to filter my Todos list by a Tag instance I select
from my
  list, and therefore need to pass the id of the selected tag
over from
  the TG snippet to the TD snippet, where it can be used as a
filter
  argument for a find method.
 
  The problem is that scala says it cannot find snippet TD,
whose
   method
  I am calling as TD.list from the TG.scala snippet. I have
tried all
  kinds of explicit importing, but no luck.
 
  So,  can a snippet call a snippet, or is that controlled only
from
   the
  web page?- Hide quoted text -
 
- Show quoted text -
 
  --
  Lift, the simply functional web frameworkhttp://liftweb.net
 http://liftweb.net
  Beginning Scalahttp://www.apress.com/book/view/1430219890
 http://www.apress.com/book/view/1430219890
  Follow me:http://twitter.com/dpp
  Git some:http://github.com/dpp
 
 
 


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

[Lift] Re: can a Snippet call a Snippet?

2009-07-01 Thread g-man

I will look into the nested snippets.

For expediency, I folded all the snippets that interact with my
template into one file, so I can concentrate on the business logic.

For my Todo app enhancement, I need to pass the id of my selected Tag
(which I have confirmed is correctly gathered from the page request)
in to the TD.list method, so that the filtered Todos (those bearing
the required Tag) will be found and rendered.

My problem is that if I try to pass an additional argument (tagId:
Long), the TD.list method is not happy and will not even render the
template.

I have tried both paired (html: NodeSeq, tagId: Long) as well as
curried style (html: NodeSeq)(tagId: Long), but neither works.

There must be a simple way to accomplish such a common task!

Thanks to all the members for commenting...


On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
 Or you can use S.locateMappedSnippet ... but first try to see if
 nested snippet won't do the trick for you ...

 On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:



  Can you paste some code?

  Essentially we support nested snippets so your snippet can simply
  return a markup containing another snippet and it will be invoked. If
  you really want to manually invoke a snippet from another snippet and
  if you are not using StatefulSnippets you can just instantiate the
  class and call your function and pass it the right NodeSeq.

  Br's,
  Marius

  On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:

   I am enhancing the Todo app by adding tags.

   I have retained the TD.scala snippet to manage the Todos on my page,
   and added a TG.scala snippet to handle tags on the same page, which
   works well for creating new and listing in both cases.

   Now I want to filter my Todos list by a Tag instance I select from my
   list, and therefore need to pass the id of the selected tag over from
   the TG snippet to the TD snippet, where it can be used as a filter
   argument for a find method.

   The problem is that scala says it cannot find snippet TD, whose method
   I am calling as TD.list from the TG.scala snippet. I have tried all
   kinds of explicit importing, but no luck.

   So,  can a snippet call a snippet, or is that controlled only from the
   web page?- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: can a Snippet call a Snippet?

2009-07-01 Thread David Pollak
On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:


 I will look into the nested snippets.

 For expediency, I folded all the snippets that interact with my
 template into one file, so I can concentrate on the business logic.

 For my Todo app enhancement, I need to pass the id of my selected Tag
 (which I have confirmed is correctly gathered from the page request)
 in to the TD.list method, so that the filtered Todos (those bearing
 the required Tag) will be found and rendered.

 My problem is that if I try to pass an additional argument (tagId:
 Long), the TD.list method is not happy and will not even render the
 template.

 I have tried both paired (html: NodeSeq, tagId: Long) as well as
 curried style (html: NodeSeq)(tagId: Long), but neither works.


Try:

list(tagId: Long)(html: NodeSeq): NodeSeq

That way list(44L) _ becomes a NodeSeq = NodeSeq




 There must be a simple way to accomplish such a common task!

 Thanks to all the members for commenting...


 On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
  Or you can use S.locateMappedSnippet ... but first try to see if
  nested snippet won't do the trick for you ...
 
  On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:
 
 
 
   Can you paste some code?
 
   Essentially we support nested snippets so your snippet can simply
   return a markup containing another snippet and it will be invoked. If
   you really want to manually invoke a snippet from another snippet and
   if you are not using StatefulSnippets you can just instantiate the
   class and call your function and pass it the right NodeSeq.
 
   Br's,
   Marius
 
   On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:
 
I am enhancing the Todo app by adding tags.
 
I have retained the TD.scala snippet to manage the Todos on my page,
and added a TG.scala snippet to handle tags on the same page, which
works well for creating new and listing in both cases.
 
Now I want to filter my Todos list by a Tag instance I select from my
list, and therefore need to pass the id of the selected tag over from
the TG snippet to the TD snippet, where it can be used as a filter
argument for a find method.
 
The problem is that scala says it cannot find snippet TD, whose
 method
I am calling as TD.list from the TG.scala snippet. I have tried all
kinds of explicit importing, but no luck.
 
So,  can a snippet call a snippet, or is that controlled only from
 the
web page?- Hide quoted text -
 
  - Show quoted text -
 



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

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



[Lift] Re: can a Snippet call a Snippet?

2009-07-01 Thread g-man

I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
(todos).open_!

Here's my layout:

todo.html template 

lift:TD.listTodos todos=todos
--- Todo list table stuff ---
lift:TD.listTags tags=tags
--- Tag list table stuff (where the selection to filter comes from)
---

TD.scala snippet =

// this arity is for the default 'show all Todos' condition
def list(html: NodeSeq) = {
val id = S.attr(todos).open_!

// this arity is for the 'filter by Tag' case
def list(filterTag: Long)(html: NodeSeq) = {
val id = S.attr(todos).open_!

The two snippet methods could probably be combined with a (param:
Long*) signature, but Scala does not seem to care right now. The
default works perfectly, but when a Tag is selected to filter by, the
'todos' id Box cannot be seen when attempting to open.

Is this because it is probably out of scope? I am using an ajaxbutton
to make the call and pass in the tag.id, but it is hard to see how an
S.attr could exist for one request, then be gone for the next, unless
I am confusing this with a stateful attribute.


On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:

  I will look into the nested snippets.

  For expediency, I folded all the snippets that interact with my
  template into one file, so I can concentrate on the business logic.

  For my Todo app enhancement, I need to pass the id of my selected Tag
  (which I have confirmed is correctly gathered from the page request)
  in to the TD.list method, so that the filtered Todos (those bearing
  the required Tag) will be found and rendered.

  My problem is that if I try to pass an additional argument (tagId:
  Long), the TD.list method is not happy and will not even render the
  template.

  I have tried both paired (html: NodeSeq, tagId: Long) as well as
  curried style (html: NodeSeq)(tagId: Long), but neither works.

 Try:

 list(tagId: Long)(html: NodeSeq): NodeSeq

 That way list(44L) _ becomes a NodeSeq = NodeSeq





  There must be a simple way to accomplish such a common task!

  Thanks to all the members for commenting...

  On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
   Or you can use S.locateMappedSnippet ... but first try to see if
   nested snippet won't do the trick for you ...

   On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:

Can you paste some code?

Essentially we support nested snippets so your snippet can simply
return a markup containing another snippet and it will be invoked. If
you really want to manually invoke a snippet from another snippet and
if you are not using StatefulSnippets you can just instantiate the
class and call your function and pass it the right NodeSeq.

Br's,
Marius

On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:

 I am enhancing the Todo app by adding tags.

 I have retained the TD.scala snippet to manage the Todos on my page,
 and added a TG.scala snippet to handle tags on the same page, which
 works well for creating new and listing in both cases.

 Now I want to filter my Todos list by a Tag instance I select from my
 list, and therefore need to pass the id of the selected tag over from
 the TG snippet to the TD snippet, where it can be used as a filter
 argument for a find method.

 The problem is that scala says it cannot find snippet TD, whose
  method
 I am calling as TD.list from the TG.scala snippet. I have tried all
 kinds of explicit importing, but no luck.

 So,  can a snippet call a snippet, or is that controlled only from
  the
 web page?- Hide quoted text -

   - Show quoted text -

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: can a Snippet call a Snippet?

2009-07-01 Thread Naftoli Gugenhem

Where is the second list getting called from? Code?

-
g-mangregor...@gmail.com wrote:


I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr
(todos).open_!

Here's my layout:

todo.html template 

lift:TD.listTodos todos=todos
--- Todo list table stuff ---
lift:TD.listTags tags=tags
--- Tag list table stuff (where the selection to filter comes from)
---

TD.scala snippet =

// this arity is for the default 'show all Todos' condition
def list(html: NodeSeq) = {
val id = S.attr(todos).open_!

// this arity is for the 'filter by Tag' case
def list(filterTag: Long)(html: NodeSeq) = {
val id = S.attr(todos).open_!

The two snippet methods could probably be combined with a (param:
Long*) signature, but Scala does not seem to care right now. The
default works perfectly, but when a Tag is selected to filter by, the
'todos' id Box cannot be seen when attempting to open.

Is this because it is probably out of scope? I am using an ajaxbutton
to make the call and pass in the tag.id, but it is hard to see how an
S.attr could exist for one request, then be gone for the next, unless
I am confusing this with a stateful attribute.


On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote:

  I will look into the nested snippets.

  For expediency, I folded all the snippets that interact with my
  template into one file, so I can concentrate on the business logic.

  For my Todo app enhancement, I need to pass the id of my selected Tag
  (which I have confirmed is correctly gathered from the page request)
  in to the TD.list method, so that the filtered Todos (those bearing
  the required Tag) will be found and rendered.

  My problem is that if I try to pass an additional argument (tagId:
  Long), the TD.list method is not happy and will not even render the
  template.

  I have tried both paired (html: NodeSeq, tagId: Long) as well as
  curried style (html: NodeSeq)(tagId: Long), but neither works.

 Try:

 list(tagId: Long)(html: NodeSeq): NodeSeq

 That way list(44L) _ becomes a NodeSeq = NodeSeq





  There must be a simple way to accomplish such a common task!

  Thanks to all the members for commenting...

  On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote:
   Or you can use S.locateMappedSnippet ... but first try to see if
   nested snippet won't do the trick for you ...

   On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:

Can you paste some code?

Essentially we support nested snippets so your snippet can simply
return a markup containing another snippet and it will be invoked. If
you really want to manually invoke a snippet from another snippet and
if you are not using StatefulSnippets you can just instantiate the
class and call your function and pass it the right NodeSeq.

Br's,
Marius

On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:

 I am enhancing the Todo app by adding tags.

 I have retained the TD.scala snippet to manage the Todos on my page,
 and added a TG.scala snippet to handle tags on the same page, which
 works well for creating new and listing in both cases.

 Now I want to filter my Todos list by a Tag instance I select from my
 list, and therefore need to pass the id of the selected tag over from
 the TG snippet to the TD snippet, where it can be used as a filter
 argument for a find method.

 The problem is that scala says it cannot find snippet TD, whose
  method
 I am calling as TD.list from the TG.scala snippet. I have tried all
 kinds of explicit importing, but no luck.

 So,  can a snippet call a snippet, or is that controlled only from
  the
 web page?- Hide quoted text -

   - Show quoted text -

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Git some:http://github.com/dpp


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



[Lift] Re: can a Snippet call a Snippet?

2009-06-30 Thread marius d.

Can you paste some code?

Essentially we support nested snippets so your snippet can simply
return a markup containing another snippet and it will be invoked. If
you really want to manually invoke a snippet from another snippet and
if you are not using StatefulSnippets you can just instantiate the
class and call your function and pass it the right NodeSeq.

Br's,
Marius

On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:
 I am enhancing the Todo app by adding tags.

 I have retained the TD.scala snippet to manage the Todos on my page,
 and added a TG.scala snippet to handle tags on the same page, which
 works well for creating new and listing in both cases.

 Now I want to filter my Todos list by a Tag instance I select from my
 list, and therefore need to pass the id of the selected tag over from
 the TG snippet to the TD snippet, where it can be used as a filter
 argument for a find method.

 The problem is that scala says it cannot find snippet TD, whose method
 I am calling as TD.list from the TG.scala snippet. I have tried all
 kinds of explicit importing, but no luck.

 So,  can a snippet call a snippet, or is that controlled only from the
 web page?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: can a Snippet call a Snippet?

2009-06-30 Thread marius d.

Or you can use S.locateMappedSnippet ... but first try to see if
nested snippet won't do the trick for you ...

On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote:
 Can you paste some code?

 Essentially we support nested snippets so your snippet can simply
 return a markup containing another snippet and it will be invoked. If
 you really want to manually invoke a snippet from another snippet and
 if you are not using StatefulSnippets you can just instantiate the
 class and call your function and pass it the right NodeSeq.

 Br's,
 Marius

 On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote:

  I am enhancing the Todo app by adding tags.

  I have retained the TD.scala snippet to manage the Todos on my page,
  and added a TG.scala snippet to handle tags on the same page, which
  works well for creating new and listing in both cases.

  Now I want to filter my Todos list by a Tag instance I select from my
  list, and therefore need to pass the id of the selected tag over from
  the TG snippet to the TD snippet, where it can be used as a filter
  argument for a find method.

  The problem is that scala says it cannot find snippet TD, whose method
  I am calling as TD.list from the TG.scala snippet. I have tried all
  kinds of explicit importing, but no luck.

  So,  can a snippet call a snippet, or is that controlled only from the
  web page?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Lift] Re: can a Snippet call a Snippet?

2009-06-29 Thread Naftoli Gugenhem

I don't have such a clear picture of what you're trying to do. If you need to 
refer to the instance of a snippet that exists on the same page, it looks to me 
like that data is private in S.snippetForClass.
Maybe you can nest the Tag tags in the ToDo snippet tag, have it instantiate a 
Tag instance, and call its xml processing functions directly, so that its SHtml 
setters etc. will refer to variables in the outer snippet's scope, i.e. the Tag 
instance it owns.

-
g-mangregor...@gmail.com wrote:


I am enhancing the Todo app by adding tags.

I have retained the TD.scala snippet to manage the Todos on my page,
and added a TG.scala snippet to handle tags on the same page, which
works well for creating new and listing in both cases.

Now I want to filter my Todos list by a Tag instance I select from my
list, and therefore need to pass the id of the selected tag over from
the TG snippet to the TD snippet, where it can be used as a filter
argument for a find method.

The problem is that scala says it cannot find snippet TD, whose method
I am calling as TD.list from the TG.scala snippet. I have tried all
kinds of explicit importing, but no luck.

So,  can a snippet call a snippet, or is that controlled only from the
web page?






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