Re: [Lift] Re: How can one bind value-less attributes?
On Sun, Dec 6, 2009 at 8:28 PM, David Pollak feeder.of.the.be...@gmail.comwrote: On Sun, Dec 6, 2009 at 7:25 PM, Alex Boisvert alex.boisv...@gmail.comwrote: Using the latest and greatest (master branch), I can't reproduce the MatchError but I can reproduce the issue with the attribute being generated if the value is null. How about adding a Box alternative rather than perpetuating a paradigm based on null? Yes, that's better. I'll do that. [Side diatribe: Can't wait for a working scala.NotNull so we can implicitly convert (non-null) literal values to Some() or Full() instance and reduce verbosity] alex -- 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: How can one bind value-less attributes?
On Mon, Dec 7, 2009 at 9:22 AM, Alex Boisvert alex.boisv...@gmail.comwrote: On Sun, Dec 6, 2009 at 8:28 PM, David Pollak feeder.of.the.be...@gmail.com wrote: On Sun, Dec 6, 2009 at 7:25 PM, Alex Boisvert alex.boisv...@gmail.comwrote: Using the latest and greatest (master branch), I can't reproduce the MatchError but I can reproduce the issue with the attribute being generated if the value is null. How about adding a Box alternative rather than perpetuating a paradigm based on null? Yes, that's better. I'll do that. [Side diatribe: Can't wait for a working scala.NotNull so we can implicitly convert (non-null) literal values to Some() or Full() instance and reduce verbosity] Mmmm sweet tasty NotNull. alex -- 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: How can one bind value-less attributes?
I looked at adding a Box variant, but it wasn't a strictly speaking trivial change since calcValue on BindParam is of type NodeSeq. I guess it could become Box[NodeSeq] and then when binding at element positions convert that to NodeSeq.Empty, but I also have had the need (which I've worked around) to be able to replace a single bound attribute with multiple result attributes, so I was thinking that it would be best to allow AttrBindParams to generate MetaData, not just a value. I had written some code to play with this idea, but I didn't get too far because I was busy and needed feedback from other committers. I can return it to working tonight if there's interest. -Ross On Dec 7, 2009, at 12:22 PM, Alex Boisvert wrote: On Sun, Dec 6, 2009 at 8:28 PM, David Pollak feeder.of.the.be...@gmail.com wrote: On Sun, Dec 6, 2009 at 7:25 PM, Alex Boisvert alex.boisv...@gmail.com wrote: Using the latest and greatest (master branch), I can't reproduce the MatchError but I can reproduce the issue with the attribute being generated if the value is null. How about adding a Box alternative rather than perpetuating a paradigm based on null? Yes, that's better. I'll do that. [Side diatribe: Can't wait for a working scala.NotNull so we can implicitly convert (non-null) literal values to Some() or Full() instance and reduce verbosity] alex -- 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: How can one bind value-less attributes?
Sha-bam http://github.com/dpp/liftweb/issues/#issue/229 -Ross On Dec 7, 2009, at 12:43 PM, David Pollak wrote: Is there a ticket for this? I'm in ticket-closing mode today ;-) On Mon, Dec 7, 2009 at 9:29 AM, Ross Mellgren dri...@gmail.com wrote: I looked at adding a Box variant, but it wasn't a strictly speaking trivial change since calcValue on BindParam is of type NodeSeq. I guess it could become Box[NodeSeq] and then when binding at element positions convert that to NodeSeq.Empty, but I also have had the need (which I've worked around) to be able to replace a single bound attribute with multiple result attributes, so I was thinking that it would be best to allow AttrBindParams to generate MetaData, not just a value. I had written some code to play with this idea, but I didn't get too far because I was busy and needed feedback from other committers. I can return it to working tonight if there's interest. -Ross On Dec 7, 2009, at 12:22 PM, Alex Boisvert wrote: On Sun, Dec 6, 2009 at 8:28 PM, David Pollak feeder.of.the.be...@gmail.com wrote: On Sun, Dec 6, 2009 at 7:25 PM, Alex Boisvert alex.boisv...@gmail.com wrote: Using the latest and greatest (master branch), I can't reproduce the MatchError but I can reproduce the issue with the attribute being generated if the value is null. How about adding a Box alternative rather than perpetuating a paradigm based on null? Yes, that's better. I'll do that. [Side diatribe: Can't wait for a working scala.NotNull so we can implicitly convert (non-null) literal values to Some() or Full() instance and reduce verbosity] alex -- 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 . -- 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 . -- 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: How can one bind value-less attributes?
Alex Black a...@alexblack.ca writes: If you output null for theattributevalue, theattributeis not rendered: I've just upgraded from 1.0 to 1.1-M6, and this doesn't seem to work any more - could this be a bug in M6? Maybe. The code I wrote worked in 1.1-SNAPSHOT at the time.you could try this just to verify. /Jeppe [...] scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,Text(checked),checked)) res11: scala.xml.NodeSeq = input type=checkbox checked=checked/input scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,null,selected)) res12: scala.xml.NodeSeq = input type=checkbox /input -- 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: How can one bind value-less attributes?
Using the latest and greatest (master branch), I can't reproduce the MatchError but I can reproduce the issue with the attribute being generated if the value is null. I'll fix it tomorrow morning. alex On Sun, Dec 6, 2009 at 5:59 AM, Alex Black a...@alexblack.ca wrote: If you output null for theattributevalue, theattributeis not rendered: I've just upgraded from 1.0 to 1.1-M6, and this doesn't seem to work any more - could this be a bug in M6? Message: scala.MatchError: null scala.runtime.ScalaRunTime$.boxArray(ScalaRunTime.scala:136) net.liftweb.util.BindHelpers$class.mix$1(BindHelpers.scala:612) net.liftweb.util.BindHelpers$class.net$liftweb$util$BindHelpers$ $bindByNameMixIn(BindHelpers.scala:618) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$ $anonfun$apply$27.apply(BindHelpers.scala:440) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$ $anonfun$apply$27.apply(BindHelpers.scala:436) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:436) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala: 449) net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala: 409) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:409) net.liftweb.util.Helpers$.bind(Helpers.scala:29) net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:380) net.liftweb.util.Helpers$.bind(Helpers.scala:29) scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,Text(checked),checked)) res11: scala.xml.NodeSeq = input type=checkbox checked=checked/input scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,null,selected)) res12: scala.xml.NodeSeq = input type=checkbox /input /Jeppe -- 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.
Re: [Lift] Re: How can one bind value-less attributes?
On Sun, Dec 6, 2009 at 7:25 PM, Alex Boisvert alex.boisv...@gmail.comwrote: Using the latest and greatest (master branch), I can't reproduce the MatchError but I can reproduce the issue with the attribute being generated if the value is null. How about adding a Box alternative rather than perpetuating a paradigm based on null? I'll fix it tomorrow morning. alex On Sun, Dec 6, 2009 at 5:59 AM, Alex Black a...@alexblack.ca wrote: If you output null for theattributevalue, theattributeis not rendered: I've just upgraded from 1.0 to 1.1-M6, and this doesn't seem to work any more - could this be a bug in M6? Message: scala.MatchError: null scala.runtime.ScalaRunTime$.boxArray(ScalaRunTime.scala:136) net.liftweb.util.BindHelpers$class.mix$1(BindHelpers.scala:612) net.liftweb.util.BindHelpers$class.net$liftweb$util$BindHelpers$ $bindByNameMixIn(BindHelpers.scala:618) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$ $anonfun$apply$27.apply(BindHelpers.scala:440) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$ $anonfun$apply$27.apply(BindHelpers.scala:436) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:436) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:444) net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind $1$1.apply(BindHelpers.scala:424) scala.Seq$class.flatMap(Seq.scala:294) scala.xml.NodeSeq.flatMap(NodeSeq.scala:34) net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1 (BindHelpers.scala:424) net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala: 449) net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala: 409) net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65) net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:409) net.liftweb.util.Helpers$.bind(Helpers.scala:29) net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:380) net.liftweb.util.Helpers$.bind(Helpers.scala:29) scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,Text(checked),checked)) res11: scala.xml.NodeSeq = input type=checkbox checked=checked/input scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,null,selected)) res12: scala.xml.NodeSeq = input type=checkbox /input /Jeppe -- 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.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
Re: [Lift] Re: How can one bind value-less attributes?
Alex Black a...@alexblack.ca writes: Is there a good/reasonable way to conditionally output checked=checked or output nothing? If you output null for the attribute value, the attribute is not rendered: scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,Text(checked),checked)) res11: scala.xml.NodeSeq = input type=checkbox checked=checked/input scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,null,selected)) res12: scala.xml.NodeSeq = input type=checkbox /input /Jeppe -- 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: How can one bind value-less attributes?
null... shudder. :-) On Wed, Dec 2, 2009 at 12:32 AM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote: Alex Black a...@alexblack.ca writes: Is there a good/reasonable way to conditionally output checked=checked or output nothing? If you output null for the attribute value, the attribute is not rendered: scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,Text(checked),checked)) res11: scala.xml.NodeSeq = input type=checkbox checked=checked/input scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,null,selected)) res12: scala.xml.NodeSeq = input type=checkbox /input /Jeppe -- 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: How can one bind value-less attributes?
David Pollak feeder.of.the.be...@gmail.com writes: null... shudder. :-) Yeaah, somehow it doesn't look nice anymore :-) Your idea with an Option/Box for attribute binding seems nice clean /Jeppe On Wed, Dec 2, 2009 at 12:32 AM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote: Alex Black a...@alexblack.ca writes: Is there a good/reasonable way to conditionally output checked=checked or output nothing? If you output null for the attribute value, the attribute is not rendered: scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,Text(checked),checked)) res11: scala.xml.NodeSeq = input type=checkbox checked=checked/input scala bind(stuff, input type=checkbox stuff:s=/, AttrBindParam(s,null,selected)) res12: scala.xml.NodeSeq = input type=checkbox /input /Jeppe -- 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.
Re: [Lift] Re: How can one bind value-less attributes?
You can use SHtml.checkbox() to easily generate the checkbox, bind(..., checkbox - SHtml.checkbox(isChecked, checked = if (checked) doSomething()) ) The first parameter is whether the checkbox should be checked by default. The second parameter is a function to do something when form is submitted. alex On Tue, Dec 1, 2009 at 2:50 PM, Alex Black a...@alexblack.ca wrote: Is there a good/reasonable way to conditionally output checked=checked or output nothing? My code looks like this: bind(manufacturer, xhtml, AttrBindParam(selected, Text(selected), selected)) I can add an if statement, and then output Text(notSelected) instead, but that doesn't seem to work - the correct option is not selected. - Alex On Dec 1, 5:30 pm, Ross Mellgren dri...@gmail.com wrote: Valueless attributes are prohibited by XML. The proper XHTML formulation is to use the name of the attribute as the value, e.g. checked=checked -Ross On Dec 1, 2009, at 5:28 PM, Alex Black wrote: For example, if my html template looks like this: lift:surround with=default at=content h2foobar/h2 lift:MySnippet.render input type=checkbox/ /lift:MySnippet.render /lift:surround I'd like to render it conditionally as: h2foobar/h2 input type=checkbox checked/ Is there syntax to add the checked to the checkbox? perhaps similar to the syntax to bind attribute values? Thanks! - Alex -- 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.
Re: [Lift] Re: How can one bind value-less attributes?
Here's one way, Helpers.bind(..., myElement - (if (condition) myElement/ else myElement myAttribute=value/)) I don't think there's a bind helper to conditionally output the attribute. Maybe our bind experts know. alex On Tue, Dec 1, 2009 at 3:29 PM, Alex Black a...@alexblack.ca wrote: Thanks Alex. That would work, but I'm looking for a more generic solution. Restating the problem: Based on some condition I want to generate an attribute or not generate an attribute, e.g.: myElement myAttribute=value / OR myElement - Alex On Dec 1, 6:23 pm, Alex Boisvert alex.boisv...@gmail.com wrote: You can use SHtml.checkbox() to easily generate the checkbox, bind(..., checkbox - SHtml.checkbox(isChecked, checked = if (checked) doSomething()) ) The first parameter is whether the checkbox should be checked by default. The second parameter is a function to do something when form is submitted. alex On Tue, Dec 1, 2009 at 2:50 PM, Alex Black a...@alexblack.ca wrote: Is there a good/reasonable way to conditionally output checked=checked or output nothing? My code looks like this: bind(manufacturer, xhtml, AttrBindParam(selected, Text(selected), selected)) I can add an if statement, and then output Text(notSelected) instead, but that doesn't seem to work - the correct option is not selected. - Alex On Dec 1, 5:30 pm, Ross Mellgren dri...@gmail.com wrote: Valueless attributes are prohibited by XML. The proper XHTML formulation is to use the name of the attribute as the value, e.g. checked=checked -Ross On Dec 1, 2009, at 5:28 PM, Alex Black wrote: For example, if my html template looks like this: lift:surround with=default at=content h2foobar/h2 lift:MySnippet.render input type=checkbox/ /lift:MySnippet.render /lift:surround I'd like to render it conditionally as: h2foobar/h2 input type=checkbox checked/ Is there syntax to add the checked to the checkbox? perhaps similar to the syntax to bind attribute values? Thanks! - Alex -- 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 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 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.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.
Re: [Lift] Re: How can one bind value-less attributes?
I think you are approaching it from the wrong angle. Lift is not an MVC style framework -- the template and the snippets coordinate (conspire?) to deliver XHTML. The actual tags might be in the snippet, if there's any logic being applied to their creation / modification / etc. -Ross On Dec 1, 2009, at 6:59 PM, Alex Black wrote: I appreciate the suggestion, I did think of that, but one of my goals is to keep the XHTML out of my code..! This seems a tough problem in general.. Ideally in snippets there would be no presentation, just data I think, e.g. in this case a boolean. The XHTML template would then form the presentation of that data, whether it be a checkbox or whatever. Perhaps I'm approaching this from the wrong angle? - Alex On Dec 1, 6:55 pm, Alex Boisvert alex.boisv...@gmail.com wrote: Here's one way, Helpers.bind(..., myElement - (if (condition) myElement/ else myElement myAttribute=value/)) I don't think there's a bind helper to conditionally output the attribute. Maybe our bind experts know. alex On Tue, Dec 1, 2009 at 3:29 PM, Alex Black a...@alexblack.ca wrote: Thanks Alex. That would work, but I'm looking for a more generic solution. Restating the problem: Based on some condition I want to generate an attribute or not generate an attribute, e.g.: myElement myAttribute=value / OR myElement - Alex On Dec 1, 6:23 pm, Alex Boisvert alex.boisv...@gmail.com wrote: You can use SHtml.checkbox() to easily generate the checkbox, bind(..., checkbox - SHtml.checkbox(isChecked, checked = if (checked) doSomething()) ) The first parameter is whether the checkbox should be checked by default. The second parameter is a function to do something when form is submitted. alex On Tue, Dec 1, 2009 at 2:50 PM, Alex Black a...@alexblack.ca wrote: Is there a good/reasonable way to conditionally output checked=checked or output nothing? My code looks like this: bind(manufacturer, xhtml, AttrBindParam(selected, Text(selected), selected)) I can add an if statement, and then output Text(notSelected) instead, but that doesn't seem to work - the correct option is not selected. - Alex On Dec 1, 5:30 pm, Ross Mellgren dri...@gmail.com wrote: Valueless attributes are prohibited by XML. The proper XHTML formulation is to use the name of the attribute as the value, e.g. checked=checked -Ross On Dec 1, 2009, at 5:28 PM, Alex Black wrote: For example, if my html template looks like this: lift:surround with=default at=content h2foobar/h2 lift:MySnippet.render input type=checkbox/ /lift:MySnippet.render /lift:surround I'd like to render it conditionally as: h2foobar/h2 input type=checkbox checked/ Is there syntax to add the checked to the checkbox? perhaps similar to the syntax to bind attribute values? Thanks! - Alex -- 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 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 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.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. -- 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: How can one bind value-less attributes?
On Tue, Dec 1, 2009 at 3:59 PM, Alex Black a...@alexblack.ca wrote: I appreciate the suggestion, I did think of that, but one of my goals is to keep the XHTML out of my code..! This seems a tough problem in general.. Ideally in snippets there would be no presentation, just data I think, e.g. in this case a boolean. The XHTML template would then form the presentation of that data, whether it be a checkbox or whatever. Perhaps I'm approaching this from the wrong angle? lift:MySnippet stuff:checkedinput type=checkbox//stuff:checked /lift:MySnippet class MySnippet { def render(in: NodeSeq): NodeSeq = bind(stuff, in, checked - (myNode = myNode % (if (shouldBeChecked) (checked - checked) else Null)) } It would be nice to do: lift:MySnippet input type=checkbox stuff:checked=maybe/ /lift:MySnippet class MySnippet { def render(in: NodeSeq): NodeSeq = bind(stuff, in, FuncAttrBindParam(checked, _ = if (shouldBeChecked) Some(checked) else None, checked)) } But that's not yet possible. Maybe it's worth a ticket. - Alex On Dec 1, 6:55 pm, Alex Boisvert alex.boisv...@gmail.com wrote: Here's one way, Helpers.bind(..., myElement - (if (condition) myElement/ else myElement myAttribute=value/)) I don't think there's a bind helper to conditionally output the attribute. Maybe our bind experts know. alex On Tue, Dec 1, 2009 at 3:29 PM, Alex Black a...@alexblack.ca wrote: Thanks Alex. That would work, but I'm looking for a more generic solution. Restating the problem: Based on some condition I want to generate an attribute or not generate an attribute, e.g.: myElement myAttribute=value / OR myElement - Alex On Dec 1, 6:23 pm, Alex Boisvert alex.boisv...@gmail.com wrote: You can use SHtml.checkbox() to easily generate the checkbox, bind(..., checkbox - SHtml.checkbox(isChecked, checked = if (checked) doSomething()) ) The first parameter is whether the checkbox should be checked by default. The second parameter is a function to do something when form is submitted. alex On Tue, Dec 1, 2009 at 2:50 PM, Alex Black a...@alexblack.ca wrote: Is there a good/reasonable way to conditionally output checked=checked or output nothing? My code looks like this: bind(manufacturer, xhtml, AttrBindParam(selected, Text(selected), selected)) I can add an if statement, and then output Text(notSelected) instead, but that doesn't seem to work - the correct option is not selected. - Alex On Dec 1, 5:30 pm, Ross Mellgren dri...@gmail.com wrote: Valueless attributes are prohibited by XML. The proper XHTML formulation is to use the name of the attribute as the value, e.g. checked=checked -Ross On Dec 1, 2009, at 5:28 PM, Alex Black wrote: For example, if my html template looks like this: lift:surround with=default at=content h2foobar/h2 lift:MySnippet.render input type=checkbox/ /lift:MySnippet.render /lift:surround I'd like to render it conditionally as: h2foobar/h2 input type=checkbox checked/ Is there syntax to add the checked to the checkbox? perhaps similar to the syntax to bind attribute values? Thanks! - Alex -- 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 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com liftweb%252bunsubscr...@googlegroups.comliftweb%25252bunsubscr...@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 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com liftweb%252bunsubscr...@googlegroups.comliftweb%25252bunsubscr...@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