Well it depends on precisely what you want. If you want your snippet  
to become empty if the product is not there, try:

productBox.map(product => {
   bind("product", ns, ...)
}).openOr(NodeSeq.Empty)

If you want only certain bind positions empty, do the same thing  
inside the bind:

bind("proudct", ns,
      "field" -> productBox.map(p => Text(p.field.toString)).openOr 
(NodeSeq.Empty),
      ...)

map is of course just one of the (simpler) operations you can do with  
a Box, there's more complicated stuff if you need other variants.

-Ross

On Sep 8, 2009, at 3:06 PM, José María wrote:

>
> Hi.
>
> Boxes are giving me a hard time.
>
> Say you have a model of a Product.
>
> If I've a snippet that retrieves a Product from the DB:
>
> val product : Box[Product] = Product.find(2)
>
> And now I want to bind "product" with bind(),  product is a Box and it
> can be empty, how can I bind something that doesn't exists? You have
> to return a NodeSeq in a snippet. What should my code must do?
>
> Best regards.
> >


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