[Lift] A question on radio button

2009-12-01 Thread sunanda
Hi,

I have got two radio button fields("Yes","No")


In my form I need to display an input field onclick of the button
"Yes"  else the field needs to be hidden.
How can I achieve this inside the form.

Regards,
Sunanda


--

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] Is it possible to use Schemifier without DB Access?

2009-12-01 Thread Joern
Hi,

I just want to see the statements Schemifier.schemify() would use to
create all my tables. Right now, it only creates statements, if there
is no such table in the DB. How could I avoid having it look at the
existing tables and just let Schemifier give me all the create
statements?

Thanks,
Joern

--

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




[Lift] Re: Image upload and serving example

2009-12-01 Thread DMB
You don't even need f.get in there as it turns out. "f.get" should
just be "file". Beautiful. Thanks for the tip.

On Dec 1, 8:07 pm, David Pollak  wrote:
> On Tue, Dec 1, 2009 at 8:03 PM, DMB  wrote:
> > Ended up doing this:
>
> >    def show(xhtml: NodeSeq) : NodeSeq = {
> >        if(S.post_?) {
> >            val f : Option[FileParamHolder] = S.request match {
> >                case Empty => Empty
> >                case Full(req) =>
> >                    req.uploadedFiles.find(_.name == "file_upload")
> >            }
>
> >            if(f.isDefined) {
> >                acceptFile(f.get)
> >            }
> >        }
> >        return xhtml
> >    }
>
> This is a place for a for comprehension:
>
> def show(xhtml: NodeSeq): NodeSeq = {
>   for {
>     request <- S.request if S.post_?
>     file <- request.uploadedFiles.find(_.name == "file_upload")
>   } acceptFile(f.get)
>
>   xhtml
>
> }
>
> Note that the code is shorter, reads better and has no branches in it.
>
>
>
>
>
> > And putting a bare upload field in the snippet, like you sugested. I
> > still wonder if the binding method is the best place for this, though.
>
> > On Dec 1, 10:14 am, David Pollak 
> > wrote:
> > > If you have the Req (request), you can do:
>
> > > val req: Req = ...
> > > val theFile: Option[FileParamHolder] = req.uploadedFiles.find(_.name ==
> > > "my_param_name")
>
> > > On Tue, Dec 1, 2009 at 2:49 AM, DMB  wrote:
> > > > Just what I was looking for, thanks!
>
> > > > By the way, is there a way to assign a "name" attribute to a file
> > > > upload input field? The reason is I have a legacy piece of code that
> > > > does HTTP uploads by simulating a form submit. This code requires that
> > > > the form field name be known in advance, for obvious reasons.
>
> > > > On Nov 30, 9:26 pm, David Pollak 
> > > > wrote:
> > > > > Folks,
>
> > > > > Lately there's been a bunch of chatter on the list about image upload
> > and
> > > > > figuring out how to put the image files in the right place to serve
> > them
> > > > > again.
>
> > > > > I've written a simple example of image uploading, storing the image
> > in
> > > > the
> > > > > RDBMS and then serving the image.  You can find the code at:
> > > >http://github.com/dpp/imagine/
>
> > > > > The file upload snippet is very simple:
>
> > > > > class DoUpload {
> > > > >   private def saveFile(fp: FileParamHolder): Unit = {
> > > > >     fp.file match {
> > > > >       case null =>
> > > > >       case x if x.length == 0 =>
> > > > >       case x =>
> > > > >         val blob = ImageBlob.create.image(x).saveMe
> > > > >         ImageInfo.create.name
> > > > > (fp.fileName).mimeType(fp.mimeType).blob(blob).saveMe
> > > > >         S.notice("Thanks for the upload")
> > > > >         S.redirectTo("/")
> > > > >     }
> > > > >   }
>
> > > > >   def render(in: NodeSeq): NodeSeq =
> > > > >   bind("upload", in, "file" -> SHtml.fileUpload(saveFile _))
>
> > > > > }
>
> > > > > If the blob is uploaded, it's put in a row in ImageBlob and an
> > ImageInfo
> > > > row
> > > > > is created to store the name and mime type.  There are two different
> > rows
> > > > so
> > > > > that one doesn't have to pull the whole blob back when you're
> > checking
> > > > for
> > > > > the upload date.
>
> > > > > Serving the image is similarly concise:
>
> > > > >   def serveImage: LiftRules.DispatchPF = {
> > > > >     case req @ Req("images" :: _ :: Nil, _, GetRequest) if
> > > > > findFromRequest(req).isDefined =>
> > > > >       () => {
> > > > >         val info = findFromRequest(req).open_! // open is valid here
> > > > because
> > > > > we just tested in the guard
>
> > > > >         // Test for expiration
> > > > >         req.testFor304(info.date, "Expires" -> toInternetDate(millis
> > +
> > > > > 30.days)) or
> > > > >         // load the blob and return it
> > > > >         info.blob.obj.map(blob => InMemoryResponse(blob.image,
> > > > > List(("Last-Modified", toInternetDate(info.date.is)),
>
> > > > >  ("Expires", toInternetDate(millis + 30.days)),
>
> > > > >  ("Content-Type", info.mimeType.is)), Nil,  200))
> > > > >       }
> > > > >   }
>
> > > > > If the request matches /images/xxx where xxx is a name in the
> > ImageInfo
> > > > > table, check to see if we can return a 304 (not modified).  If not,
> > we
> > > > pull
> > > > > the blob from the database and return it.
>
> > > > > I hope this helps folks who are looking to manage and serve images.
>
> > > > > Thanks,
>
> > > > > David
>
> > > > > --
> > > > > 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...@googlegroup

Re: [Lift] Re: Image upload and serving example

2009-12-01 Thread David Pollak
On Tue, Dec 1, 2009 at 8:03 PM, DMB  wrote:

> Ended up doing this:
>
>def show(xhtml: NodeSeq) : NodeSeq = {
>if(S.post_?) {
>val f : Option[FileParamHolder] = S.request match {
>case Empty => Empty
>case Full(req) =>
>req.uploadedFiles.find(_.name == "file_upload")
>}
>
>if(f.isDefined) {
>acceptFile(f.get)
>}
>}
>return xhtml
>}
>

This is a place for a for comprehension:

def show(xhtml: NodeSeq): NodeSeq = {
  for {
request <- S.request if S.post_?
file <- request.uploadedFiles.find(_.name == "file_upload")
  } acceptFile(f.get)

  xhtml
}

Note that the code is shorter, reads better and has no branches in it.


>
> And putting a bare upload field in the snippet, like you sugested. I
> still wonder if the binding method is the best place for this, though.
>
> On Dec 1, 10:14 am, David Pollak 
> wrote:
> > If you have the Req (request), you can do:
> >
> > val req: Req = ...
> > val theFile: Option[FileParamHolder] = req.uploadedFiles.find(_.name ==
> > "my_param_name")
> >
> >
> >
> > On Tue, Dec 1, 2009 at 2:49 AM, DMB  wrote:
> > > Just what I was looking for, thanks!
> >
> > > By the way, is there a way to assign a "name" attribute to a file
> > > upload input field? The reason is I have a legacy piece of code that
> > > does HTTP uploads by simulating a form submit. This code requires that
> > > the form field name be known in advance, for obvious reasons.
> >
> > > On Nov 30, 9:26 pm, David Pollak 
> > > wrote:
> > > > Folks,
> >
> > > > Lately there's been a bunch of chatter on the list about image upload
> and
> > > > figuring out how to put the image files in the right place to serve
> them
> > > > again.
> >
> > > > I've written a simple example of image uploading, storing the image
> in
> > > the
> > > > RDBMS and then serving the image.  You can find the code at:
> > >http://github.com/dpp/imagine/
> >
> > > > The file upload snippet is very simple:
> >
> > > > class DoUpload {
> > > >   private def saveFile(fp: FileParamHolder): Unit = {
> > > > fp.file match {
> > > >   case null =>
> > > >   case x if x.length == 0 =>
> > > >   case x =>
> > > > val blob = ImageBlob.create.image(x).saveMe
> > > > ImageInfo.create.name
> > > > (fp.fileName).mimeType(fp.mimeType).blob(blob).saveMe
> > > > S.notice("Thanks for the upload")
> > > > S.redirectTo("/")
> > > > }
> > > >   }
> >
> > > >   def render(in: NodeSeq): NodeSeq =
> > > >   bind("upload", in, "file" -> SHtml.fileUpload(saveFile _))
> >
> > > > }
> >
> > > > If the blob is uploaded, it's put in a row in ImageBlob and an
> ImageInfo
> > > row
> > > > is created to store the name and mime type.  There are two different
> rows
> > > so
> > > > that one doesn't have to pull the whole blob back when you're
> checking
> > > for
> > > > the upload date.
> >
> > > > Serving the image is similarly concise:
> >
> > > >   def serveImage: LiftRules.DispatchPF = {
> > > > case req @ Req("images" :: _ :: Nil, _, GetRequest) if
> > > > findFromRequest(req).isDefined =>
> > > >   () => {
> > > > val info = findFromRequest(req).open_! // open is valid here
> > > because
> > > > we just tested in the guard
> >
> > > > // Test for expiration
> > > > req.testFor304(info.date, "Expires" -> toInternetDate(millis
> +
> > > > 30.days)) or
> > > > // load the blob and return it
> > > > info.blob.obj.map(blob => InMemoryResponse(blob.image,
> > > > List(("Last-Modified", toInternetDate(info.date.is)),
> >
> > > >  ("Expires", toInternetDate(millis + 30.days)),
> >
> > > >  ("Content-Type", info.mimeType.is)), Nil,  200))
> > > >   }
> > > >   }
> >
> > > > If the request matches /images/xxx where xxx is a name in the
> ImageInfo
> > > > table, check to see if we can return a 304 (not modified).  If not,
> we
> > > pull
> > > > the blob from the database and return it.
> >
> > > > I hope this helps folks who are looking to manage and serve images.
> >
> > > > Thanks,
> >
> > > > David
> >
> > > > --
> > > > 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.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 mess

[Lift] Re: Image upload and serving example

2009-12-01 Thread DMB
Ended up doing this:

def show(xhtml: NodeSeq) : NodeSeq = {
if(S.post_?) {
val f : Option[FileParamHolder] = S.request match {
case Empty => Empty
case Full(req) =>
req.uploadedFiles.find(_.name == "file_upload")
}

if(f.isDefined) {
acceptFile(f.get)
}
}
return xhtml
}

And putting a bare upload field in the snippet, like you sugested. I
still wonder if the binding method is the best place for this, though.

On Dec 1, 10:14 am, David Pollak 
wrote:
> If you have the Req (request), you can do:
>
> val req: Req = ...
> val theFile: Option[FileParamHolder] = req.uploadedFiles.find(_.name ==
> "my_param_name")
>
>
>
> On Tue, Dec 1, 2009 at 2:49 AM, DMB  wrote:
> > Just what I was looking for, thanks!
>
> > By the way, is there a way to assign a "name" attribute to a file
> > upload input field? The reason is I have a legacy piece of code that
> > does HTTP uploads by simulating a form submit. This code requires that
> > the form field name be known in advance, for obvious reasons.
>
> > On Nov 30, 9:26 pm, David Pollak 
> > wrote:
> > > Folks,
>
> > > Lately there's been a bunch of chatter on the list about image upload and
> > > figuring out how to put the image files in the right place to serve them
> > > again.
>
> > > I've written a simple example of image uploading, storing the image in
> > the
> > > RDBMS and then serving the image.  You can find the code at:
> >http://github.com/dpp/imagine/
>
> > > The file upload snippet is very simple:
>
> > > class DoUpload {
> > >   private def saveFile(fp: FileParamHolder): Unit = {
> > >     fp.file match {
> > >       case null =>
> > >       case x if x.length == 0 =>
> > >       case x =>
> > >         val blob = ImageBlob.create.image(x).saveMe
> > >         ImageInfo.create.name
> > > (fp.fileName).mimeType(fp.mimeType).blob(blob).saveMe
> > >         S.notice("Thanks for the upload")
> > >         S.redirectTo("/")
> > >     }
> > >   }
>
> > >   def render(in: NodeSeq): NodeSeq =
> > >   bind("upload", in, "file" -> SHtml.fileUpload(saveFile _))
>
> > > }
>
> > > If the blob is uploaded, it's put in a row in ImageBlob and an ImageInfo
> > row
> > > is created to store the name and mime type.  There are two different rows
> > so
> > > that one doesn't have to pull the whole blob back when you're checking
> > for
> > > the upload date.
>
> > > Serving the image is similarly concise:
>
> > >   def serveImage: LiftRules.DispatchPF = {
> > >     case req @ Req("images" :: _ :: Nil, _, GetRequest) if
> > > findFromRequest(req).isDefined =>
> > >       () => {
> > >         val info = findFromRequest(req).open_! // open is valid here
> > because
> > > we just tested in the guard
>
> > >         // Test for expiration
> > >         req.testFor304(info.date, "Expires" -> toInternetDate(millis +
> > > 30.days)) or
> > >         // load the blob and return it
> > >         info.blob.obj.map(blob => InMemoryResponse(blob.image,
> > > List(("Last-Modified", toInternetDate(info.date.is)),
>
> > >  ("Expires", toInternetDate(millis + 30.days)),
>
> > >  ("Content-Type", info.mimeType.is)), Nil,  200))
> > >       }
> > >   }
>
> > > If the request matches /images/xxx where xxx is a name in the ImageInfo
> > > table, check to see if we can return a 304 (not modified).  If not, we
> > pull
> > > the blob from the database and return it.
>
> > > I hope this helps folks who are looking to manage and serve images.
>
> > > Thanks,
>
> > > David
>
> > > --
> > > 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.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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Re: scaladocs

2009-12-01 Thread Ross Mellgren
It's split up by package -- here are the ones I commonly use for example:

http://www.scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scaladocs/index.html
http://www.scala-tools.org/mvnsites-snapshots/liftweb/lift-util/scaladocs/index.html
http://www.scala-tools.org/mvnsites-snapshots/liftweb/lift-common/scaladocs/index.html

To get to these links from the page I linked:

>> http://scala-tools.org/mvnsites-snapshots/liftweb/

Browse to the module you want on the left nav, e.g. Lift Base Components > Lift 
WebKit and then go to Project Reports > ScalaDocs on bottom left.

Hope that helps,
-Ross


On Dec 1, 2009, at 8:11 PM, E. Biggs wrote:

> hi, thanks.. i'm looking for the API documentation???
> 
> On Dec 1, 5:08 pm, Ross Mellgren  wrote:
>> Tryhttp://scala-tools.org/mvnsites-snapshots/liftweb/instead of with 
>> index.html
>> 
>> -Ross
>> 
>> On Dec 1, 2009, at 8:01 PM, E. Biggs wrote:
>> 
>> 
>> 
>>> shouldhttp://scala-tools.org/mvnsites-snapshots/liftweb/scaladocs/index.html
>>> be something other than nothing?
>> 
>>> Is there a better way to get snapshot scaladocs?
>> 
>>> --
>> 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Lift" group.
>>> To post to this group, send email to lift...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> liftweb+unsubscr...@googlegroups.com.
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/liftweb?hl=en.
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to 
> liftweb+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/liftweb?hl=en.
> 
> 

--

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




[Lift] Re: scaladocs

2009-12-01 Thread E. Biggs
hi, thanks.. i'm looking for the API documentation???

On Dec 1, 5:08 pm, Ross Mellgren  wrote:
> Tryhttp://scala-tools.org/mvnsites-snapshots/liftweb/instead of with 
> index.html
>
> -Ross
>
> On Dec 1, 2009, at 8:01 PM, E. Biggs wrote:
>
>
>
> > shouldhttp://scala-tools.org/mvnsites-snapshots/liftweb/scaladocs/index.html
> > be something other than nothing?
>
> > Is there a better way to get snapshot scaladocs?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

--

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




Re: [Lift] scaladocs

2009-12-01 Thread Ross Mellgren
Try http://scala-tools.org/mvnsites-snapshots/liftweb/ instead of with 
index.html

-Ross

On Dec 1, 2009, at 8:01 PM, E. Biggs wrote:

> should http://scala-tools.org/mvnsites-snapshots/liftweb/scaladocs/index.html
> be something other than nothing?
> 
> Is there a better way to get snapshot scaladocs?
> 
> --
> 
> 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] scaladocs

2009-12-01 Thread E. Biggs
should http://scala-tools.org/mvnsites-snapshots/liftweb/scaladocs/index.html
be something other than nothing?

Is there a better way to get snapshot scaladocs?

--

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] Open discussion on Lift Name Calling practices

2009-12-01 Thread David Pollak
Jim,

Thanks for spearheading this effort!

Let's do what we can to give Jim feedback on the timeline and then get the
ball rolling.

Thanks,

David

On Tue, Dec 1, 2009 at 12:43 PM, Jim Barrows  wrote:

> Lift is getting very large.  We've got singular names as lists, and plural
> names that aren't lists.  We've got people calling roses red flowers, spades
> diamonds and other mass chaos.  Well, it's not that bad, but you get the
> idea.  This is an attempt to come up with a series of standard names to make
> working in lift easier, not only for the committers, but also (and more
> importantly) for you folks using it on a day to day basis.
>
> Achieving this means that there must be two things, a set of rules for
> naming conventions, and a process to make sure everyone is following those
> rules, and changing things when we mess it up.
>
> This thread is for discussing the process.  I'll be starting another thread
> to discuss the rules, as well as another thread to discuss current names
> that we want to change.
> As always, if you don't speak up, you're not dissenting, and we welcome
> your views and ideas on how to do this!
>
> 1) Goal discussion (closes 8 Dec 09)
> 2) Identify changes, and put the list on the wiki (closes 15 Jan 10)
> 3) Convert the list to github tickets.  This includes discussing setting
> priorities etc, assessing impacts etc etc to go into the ticket. (closes 29
> Jan 10)
> 4) Committers can then work the tickets into their own workflows, and
> everything would then follow the normal commit workflow from there.
> (committers work according to priority and impact etc)
> 5) Naming becomes a part of the normal review board process.  However, if a
> committer thinks that the Name Caller needs to look at it earlier, or is
> having a hard time with naming something, by all means send an email.  (
> date we add this to the process 29 Jan 10)
> 6) As we find things we missed, or better names, we work them through the
> github ticket and review system. ( date we add this to the process 29 Jan
> 10)
>
> --
> James A Barrows
>
>  --
> 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.




[Lift] A second rewrite phase

2009-12-01 Thread David Pollak
Folks (especially Jeppe),

I've added a second rewrite phase to Lift.  The second phase takes place
within S scope, so you get SessionVars, etc.  The review board posting is at
http://reviewboard.liftweb.net/r/132/

Anyone who cares about what is accessible during this rewrite phase should
pull the dpp_issue_197 branch from GitHub and do a build to make sure it's
suiting their needs.

Thanks,

David

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

2009-12-01 Thread David Pollak
On Tue, Dec 1, 2009 at 3: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?
>






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:





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  wrote:
> > Here's one way,
> >
> > Helpers.bind(...,
> >   "myElement" -> (if (condition)  else  > 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  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.:
> >
> > > 
> >
> > > OR
> >
> > > 
> >
> > > - Alex
> >
> > > On Dec 1, 6:23 pm, Alex Boisvert  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 
> 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  is
> not
> > > > > selected.
> >
> > > > > - Alex
> >
> > > > > On Dec 1, 5:30 pm, Ross Mellgren  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:
> >
> > > > > > > 
> > > > > > >foobar
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 
> >
> > > > > > > I'd like to render it conditionally as:
> >
> > > > > > >foobar
> > > > > > >
> >
> > > > > > > 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.com
> 
> >
> > > 
> 
> >
> >
> > > > > > > .
> > > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/liftweb?hl=en
> > > > > > > .
> >
> > > > > --
> >
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Lift" group.
> > > > > To post to this group, send email to lift...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > liftweb+unsubscr...@googlegroups.com
> 
> >
> > > 
> 
> >
> >
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/liftweb?hl=en.
> >
> > > --
> >
> > > 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
> .

Re: [Lift] Re: How can one bind value-less attributes?

2009-12-01 Thread Ross Mellgren
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  wrote:
>> Here's one way,
>> 
>> Helpers.bind(...,
>>   "myElement" -> (if (condition)  else > 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  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.:
>> 
>>> 
>> 
>>> OR
>> 
>>> 
>> 
>>> - Alex
>> 
>>> On Dec 1, 6:23 pm, Alex Boisvert  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  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  is not
> selected.
>> 
> - Alex
>> 
> On Dec 1, 5:30 pm, Ross Mellgren  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:
>> 
>>> 
>>>foobar
>>>
>>>
>>>
>>> 
>> 
>>> I'd like to render it conditionally as:
>> 
>>>foobar
>>>
>> 
>>> 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.com
>>> 
>> 
>>> .
>>> For more options, visit this group athttp://
> groups.google.com/group/liftweb?hl=en
>>> .
>> 
> --
>> 
> You received this message because you are subscribed to the Google
>>> Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com
>>> 
>> 
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>> 
>>> --
>> 
>>> 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.
> 
> 

--

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




[Lift] Re: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
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  wrote:
> Here's one way,
>
> Helpers.bind(...,
>   "myElement" -> (if (condition)  else  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  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.:
>
> > 
>
> > OR
>
> > 
>
> > - Alex
>
> > On Dec 1, 6:23 pm, Alex Boisvert  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  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  is not
> > > > selected.
>
> > > > - Alex
>
> > > > On Dec 1, 5:30 pm, Ross Mellgren  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:
>
> > > > > > 
> > > > > >                foobar
> > > > > >                
> > > > > >                
> > > > > >                
> > > > > > 
>
> > > > > > I'd like to render it conditionally as:
>
> > > > > >                foobar
> > > > > >                
>
> > > > > > 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.com
> > 
>
> > > > > > .
> > > > > > For more options, visit this group athttp://
> > > > groups.google.com/group/liftweb?hl=en
> > > > > > .
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > liftweb+unsubscr...@googlegroups.com
> > 
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/liftweb?hl=en.
>
> > --
>
> > 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?

2009-12-01 Thread Alex Boisvert
Here's one way,

Helpers.bind(...,
  "myElement" -> (if (condition)  else ))

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  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.:
>
> 
>
> OR
>
> 
>
> - Alex
>
> On Dec 1, 6:23 pm, Alex Boisvert  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  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  is not
> > > selected.
> >
> > > - Alex
> >
> > > On Dec 1, 5:30 pm, Ross Mellgren  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:
> >
> > > > > 
> > > > >foobar
> > > > >
> > > > >
> > > > >
> > > > > 
> >
> > > > > I'd like to render it conditionally as:
> >
> > > > >foobar
> > > > >
> >
> > > > > 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.com
> 
> >
> > > > > .
> > > > > For more options, visit this group athttp://
> > > groups.google.com/group/liftweb?hl=en
> > > > > .
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Lift" group.
> > > To post to this group, send email to lift...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > liftweb+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/liftweb?hl=en.
>
> --
>
> 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: lift-json escaping bug

2009-12-01 Thread Ross Mellgren
Fixed:

d977c95589fbd5de8bc45e43c2867097dd75a807

-Ross

On Nov 30, 2009, at 8:33 PM, harryh wrote:

> Done:
> 
> http://github.com/dpp/liftweb/issues/#issue/214
> 
> On Nov 30, 6:33 pm, Ross Mellgren  wrote:
>> If you file an issue on github I'll write up a patch for you tonight.
>> 
>> -Ross
>> 
>> On Nov 30, 2009, at 6:30 PM, harryh wrote:
>> 
>>> Yes, what Ross said.  Further, taking a look at JsonParser.scala the
>>> bug appears to be on line ~202 where there are a couple of missing
>>> escape sequences: \/ as well as \f.
>> 
>>> -harryh
>> 
>>> On Nov 30, 6:20 pm, Ross Mellgren  wrote:
 He's double escaping so that scala's string interpretation will put a
 raw \ in there, so that it's an escaped forward slash (\/) to the  
 JSON
 parson, as I understand it. The output should be either invalid  
 escape
 or forward slash, but not backslash unless the input was \\.
>> 
 -Ross
>> 
 On Nov 30, 2009, at 6:18 PM, Peter Robinett wrote:
>> 
> Harry, I think you're double-escaping the slash. This works:
> scala> import net.liftweb.json._
> scala> val s1 = "{ \"id\": \"America/New_York\" }"
> s1: java.lang.String = { "id": "America/New_York" }
>> 
> scala> JsonParser.parse(s1)
> res0: net.liftweb.json.JsonAST.JValue = JObject(List(JField
> (id,JString
> (America/New_York
>> 
> Peter Robinett
>> 
> On Nov 30, 2:16 pm, harryh  wrote:
>> scala> import net.liftweb.json._
>> scala> val s2 = "{ \"id\": \"America\\/New_York\" }"
>> s2: java.lang.String = { "id": "America\/New_York" }
>> 
>> scala> JsonParser.parse(s2)
>> res1: net.liftweb.json.JsonAST.JValue = JObject(List(JField
>> (id,JString
>> (America\New_York
>> 
>> It should be America/New_York but for some reason getting a \  
>> instead
>> of a /
>> 
>> -harryh
>> 
> --
>> 
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to 
> liftweb+unsubscr...@googlegroups.com
> .
> For more options, visit this group 
> athttp://groups.google.com/group/liftweb?hl=en
> .
>> 
>>> --
>> 
>>> You received this message because you are subscribed to the Google  
>>> Groups "Lift" group.
>>> To post to this group, send email to lift...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> liftweb+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/liftweb?hl=en
>>> .
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to 
> liftweb+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/liftweb?hl=en.
> 
> 

--

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




[Lift] Re: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
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.:



OR



- Alex

On Dec 1, 6:23 pm, Alex Boisvert  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  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  is not
> > selected.
>
> > - Alex
>
> > On Dec 1, 5:30 pm, Ross Mellgren  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:
>
> > > > 
> > > >                foobar
> > > >                
> > > >                
> > > >                
> > > > 
>
> > > > I'd like to render it conditionally as:
>
> > > >                foobar
> > > >                
>
> > > > 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.com
> > > > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/liftweb?hl=en
> > > > .
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.

--

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?

2009-12-01 Thread Alex Boisvert
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  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  is not
> selected.
>
> - Alex
>
>
> On Dec 1, 5:30 pm, Ross Mellgren  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:
> >
> > > 
> > >foobar
> > >
> > >
> > >
> > > 
> >
> > > I'd like to render it conditionally as:
> >
> > >foobar
> > >
> >
> > > 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.com
> > > .
> > > For more options, visit this group athttp://
> groups.google.com/group/liftweb?hl=en
> > > .
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>

--

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




[Lift] Re: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
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  is not
selected.

- Alex


On Dec 1, 5:30 pm, Ross Mellgren  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:
>
> > 
> >                foobar
> >                
> >                
> >                
> > 
>
> > I'd like to render it conditionally as:
>
> >                foobar
> >                
>
> > 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.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

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




[Lift] Re: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
Thanks, I didn't know that!

On Dec 1, 5:30 pm, Ross Mellgren  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:
>
> > 
> >                foobar
> >                
> >                
> >                
> > 
>
> > I'd like to render it conditionally as:
>
> >                foobar
> >                
>
> > 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.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

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




Re: [Lift] How can one bind value-less attributes?

2009-12-01 Thread Ross Mellgren
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:
>
> 
>foobar
>
>
>
> 
>
> I'd like to render it conditionally as:
>
>foobar
>
>
> 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.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] How can one bind value-less attributes?

2009-12-01 Thread Alex Black
For example, if my html template looks like this:


foobar





I'd like to render it conditionally as:

foobar


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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Open discussion on Lift Name Calling practices

2009-12-01 Thread Jim Barrows
Lift is getting very large.  We've got singular names as lists, and plural
names that aren't lists.  We've got people calling roses red flowers, spades
diamonds and other mass chaos.  Well, it's not that bad, but you get the
idea.  This is an attempt to come up with a series of standard names to make
working in lift easier, not only for the committers, but also (and more
importantly) for you folks using it on a day to day basis.

Achieving this means that there must be two things, a set of rules for
naming conventions, and a process to make sure everyone is following those
rules, and changing things when we mess it up.

This thread is for discussing the process.  I'll be starting another thread
to discuss the rules, as well as another thread to discuss current names
that we want to change.
As always, if you don't speak up, you're not dissenting, and we welcome your
views and ideas on how to do this!

1) Goal discussion (closes 8 Dec 09)
2) Identify changes, and put the list on the wiki (closes 15 Jan 10)
3) Convert the list to github tickets.  This includes discussing setting
priorities etc, assessing impacts etc etc to go into the ticket. (closes 29
Jan 10)
4) Committers can then work the tickets into their own workflows, and
everything would then follow the normal commit workflow from there.
(committers work according to priority and impact etc)
5) Naming becomes a part of the normal review board process.  However, if a
committer thinks that the Name Caller needs to look at it earlier, or is
having a hard time with naming something, by all means send an email.  (
date we add this to the process 29 Jan 10)
6) As we find things we missed, or better names, we work them through the
github ticket and review system. ( date we add this to the process 29 Jan
10)

-- 
James A Barrows

--

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] method call from out of nowhere

2009-12-01 Thread Hannes
David Pollak schrieb:
>
>
> On Mon, Nov 30, 2009 at 11:26 PM, Hannes  > wrote:
>
> Hi David,
>
>>
>>
>> On Mon, Nov 30, 2009 at 12:11 AM, Hannes > > wrote:
>>
>> Hi David,
>>
>> In my LimitOrder Meta Object, I did:
>>
>> override def afterCreate
>>
>> to inform an Actor, everytime a new Order is created. The
>> Actor than calls the joinOtherOrders method.
>> #
>> I think I understand it now. Cause I'm creating new orders
>> inside the loop at some point. But still I don' t really
>> know, why it gets called after the old scope of
>> joinOtherOrders ends...
>>
>>
>> Sounds to me like it's all in your application's logic.  As
>> others have pointed out, Thread.dumpStack will let you figure out
>> where things are being called.
> I think the biggest problem is, that its necessary in my logic to
> inform the Actor, everytime a new order is created. This
> while-loop is an exception to this rule. I don't think that it
> would be a good idea, to change the behavior of how the Actor
> responds to messages, just to fix this case, or? Or is there any
> chance to tell a new order NOT to inform the Actor, even when its
> defined in def afterCreate ?
>
>
> Without seeing the whole of your application logic, it's difficult for 
> me to advise you.
>  
>
>
>>
>> Also, you might want to use recursion and pattern matching to
>> replace your while loop (which is O(n^2) btw):
>>
>> def dealWithList(in: List[Something]): Unit = in match {
>>   case Nil => () // nothing left to do
>>   case x :: _ if x.condition1 => x.doThing1
>>   case x :: _ if x.condition2 => x.doThing2
>>   case x :: xs if x.condition3 => x.doThing3 ; dealWithList(xs)
>>   case _ :: xs => dealWithList(xs)
>> }
> I thought about pattern matching as well, but in my first
> implementation, I just wanted to get it running and change it
> afterwards. Something else: I think recursion is slower than a
> while-loop as long as its not tail recursive, or?
>
>
> This case is tail recursive, so it's as fast as a well written while 
> loop.  But you've got an O(n ^ 2) construct in your app, so 
> performance doesn't seem to be paramount.
No, performance is really importantbut I'm going to improve this 
later on as well... :-)

thanks.
>
> Thanks,
>
> David
>  
>
>
> thanks.
>
>>
>> You have the same semantics of a while loop with the ability to
>> break out, but the code is about your logic rather than about
>> looping.
>>  
>>
>>
>> thanks.
>>
>>>
>>>
>>> On Sun, Nov 29, 2009 at 7:24 AM, Hannes
>>> mailto:hannes.flo...@gmx.li>> wrote:
>>>
>>> Hey Lifters,
>>>
>>>
>>> How is joinOtherOrders being invoked?
>>>  
>>>
>>>
>>> I've some really strange things going on here. Please
>>> consider this
>>> method definition. I've put alot of print "debug"
>>> statements between
>>> other statements. There's a while-loop that only starts,
>>> when the given
>>> list (orders) is not empty. It stops when "done" is set
>>> to true. So far,
>>> so good. Than, have a look at the Lift output. I put in
>>> a comment,
>>> pointing out where the program runs into the while loop.
>>>
>>> What really shocks me, are these print statements :
>>>
>>> before done=false
>>> after done=true
>>> i += 1
>>> outside while
>>> INFO - Service request (GET) / took 121 Milliseconds
>>> start of joinAll!
>>>
>>>
>>> The loop ends with "outside while" and than the method
>>> gets called again
>>> immediately! But who calls it? I don't
>>>
>>> Any ideas?
>>>
>>> thanks.
>>>
>>>
>>>
>>>  method definition
>>> 
>>> --
>>>
>>> def joinOtherOrders: Unit = {
>>>
>>>def joinAll(orders: List[LimitOrder]) = {
>>>
>>>println("start of joinAll!")
>>>
>>>var done = false
>>>
>>>var i = 0
>>>
>>>while (!orders.isEmpty && !done) {
>>>
>>>println("i=" + i + ", " +
>>> "orders.isEmpty=" + orders.isEmpty + ", " + "done=" + done)
>>>
>>>if (this.lots.is  ==
>>> orders(i).lots.is ){
>>>
>>>println("case-1")
>>>
>>>println("this=" + this + ",
>>> orders(i)=" + orders(i))
>>>
>>> 

Re: [Lift] Re: Image upload and serving example

2009-12-01 Thread David Pollak
If you have the Req (request), you can do:

val req: Req = ...
val theFile: Option[FileParamHolder] = req.uploadedFiles.find(_.name ==
"my_param_name")



On Tue, Dec 1, 2009 at 2:49 AM, DMB  wrote:

> Just what I was looking for, thanks!
>
> By the way, is there a way to assign a "name" attribute to a file
> upload input field? The reason is I have a legacy piece of code that
> does HTTP uploads by simulating a form submit. This code requires that
> the form field name be known in advance, for obvious reasons.
>
> On Nov 30, 9:26 pm, David Pollak 
> wrote:
> > Folks,
> >
> > Lately there's been a bunch of chatter on the list about image upload and
> > figuring out how to put the image files in the right place to serve them
> > again.
> >
> > I've written a simple example of image uploading, storing the image in
> the
> > RDBMS and then serving the image.  You can find the code at:
> http://github.com/dpp/imagine/
> >
> > The file upload snippet is very simple:
> >
> > class DoUpload {
> >   private def saveFile(fp: FileParamHolder): Unit = {
> > fp.file match {
> >   case null =>
> >   case x if x.length == 0 =>
> >   case x =>
> > val blob = ImageBlob.create.image(x).saveMe
> > ImageInfo.create.name
> > (fp.fileName).mimeType(fp.mimeType).blob(blob).saveMe
> > S.notice("Thanks for the upload")
> > S.redirectTo("/")
> > }
> >   }
> >
> >   def render(in: NodeSeq): NodeSeq =
> >   bind("upload", in, "file" -> SHtml.fileUpload(saveFile _))
> >
> > }
> >
> > If the blob is uploaded, it's put in a row in ImageBlob and an ImageInfo
> row
> > is created to store the name and mime type.  There are two different rows
> so
> > that one doesn't have to pull the whole blob back when you're checking
> for
> > the upload date.
> >
> > Serving the image is similarly concise:
> >
> >   def serveImage: LiftRules.DispatchPF = {
> > case req @ Req("images" :: _ :: Nil, _, GetRequest) if
> > findFromRequest(req).isDefined =>
> >   () => {
> > val info = findFromRequest(req).open_! // open is valid here
> because
> > we just tested in the guard
> >
> > // Test for expiration
> > req.testFor304(info.date, "Expires" -> toInternetDate(millis +
> > 30.days)) or
> > // load the blob and return it
> > info.blob.obj.map(blob => InMemoryResponse(blob.image,
> > List(("Last-Modified", toInternetDate(info.date.is)),
> >
> >  ("Expires", toInternetDate(millis + 30.days)),
> >
> >  ("Content-Type", info.mimeType.is)), Nil,  200))
> >   }
> >   }
> >
> > If the request matches /images/xxx where xxx is a name in the ImageInfo
> > table, check to see if we can return a 304 (not modified).  If not, we
> pull
> > the blob from the database and return it.
> >
> > I hope this helps folks who are looking to manage and serve images.
> >
> > Thanks,
> >
> > David
> >
> > --
> > 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.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] Beware of using a body tag in a surrounded template, especially with nested surrounds

2009-12-01 Thread David Pollak
On Tue, Dec 1, 2009 at 9:36 AM, Ross Mellgren  wrote:

> Isn't XHTML schema validation turned on by default in dev mode?
>

It's turned off by default.


> Wouldn't it detect this case?
>

It's applied after the rendering is complete.  The / moving
stuff is done before that at it's done by putting stuff in the  tag...
with all this moving around, it's possible that a sub- tag might get
eaten rather than rendered.  I haven't tested it.


>
> -Ross
>
> On Dec 1, 2009, at 12:24 PM, David Pollak wrote:
>
> Putting a  tag in templates is pretty much the only way to go.  If
> you don't put the body tag in the template that surrounds a given page's
> custom content, then you have significant issues related duplication in each
> page.
>
> It is the developer's responsibility to make sure that the HTML is valid.
>
> On Tue, Dec 1, 2009 at 7:26 AM, tiro  wrote:
>
>> Hi,
>>
>> I think it is documented somewhere in the Liftbook that one should not
>> use body tags inside a surround tag, but Lift doesn't seem to
>> complain.
>>
>> I thought I would document the phenomenon I had here since people
>> usually look in the mailing list first.
>>
>> I had used two nested surround templates, where both templates used a
>> body tag. (The inner template would start by surrounding itself with
>> the outer template, then bind the working content itself inside the
>> body tag).
>>
>> Worked fine in Lift 1.0, but in 1.1, the working content would appear
>> twice in the generated HTML, once at the very beginning, and then in
>> the correct place inside the two nested surround templates.
>>
>> Long-term, it would be great to get an error message in this case.
>>
>> Regards,
>> Tim
>>
>>
>> --
>>
>> 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.
>



-- 
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] Beware of using a body tag in a surrounded template, especially with nested surrounds

2009-12-01 Thread Ross Mellgren
Isn't XHTML schema validation turned on by default in dev mode?  
Wouldn't it detect this case?

-Ross

On Dec 1, 2009, at 12:24 PM, David Pollak wrote:

> Putting a  tag in templates is pretty much the only way to  
> go.  If you don't put the body tag in the template that surrounds a  
> given page's custom content, then you have significant issues  
> related duplication in each page.
>
> It is the developer's responsibility to make sure that the HTML is  
> valid.
>
> On Tue, Dec 1, 2009 at 7:26 AM, tiro   
> wrote:
> Hi,
>
> I think it is documented somewhere in the Liftbook that one should not
> use body tags inside a surround tag, but Lift doesn't seem to
> complain.
>
> I thought I would document the phenomenon I had here since people
> usually look in the mailing list first.
>
> I had used two nested surround templates, where both templates used a
> body tag. (The inner template would start by surrounding itself with
> the outer template, then bind the working content itself inside the
> body tag).
>
> Worked fine in Lift 1.0, but in 1.1, the working content would appear
> twice in the generated HTML, once at the very beginning, and then in
> the correct place inside the two nested surround templates.
>
> Long-term, it would be great to get an error message in this case.
>
> Regards,
> Tim
>
>
> --
>
> 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] Beware of using a body tag in a surrounded template, especially with nested surrounds

2009-12-01 Thread David Pollak
Putting a  tag in templates is pretty much the only way to go.  If you
don't put the body tag in the template that surrounds a given page's custom
content, then you have significant issues related duplication in each page.

It is the developer's responsibility to make sure that the HTML is valid.

On Tue, Dec 1, 2009 at 7:26 AM, tiro  wrote:

> Hi,
>
> I think it is documented somewhere in the Liftbook that one should not
> use body tags inside a surround tag, but Lift doesn't seem to
> complain.
>
> I thought I would document the phenomenon I had here since people
> usually look in the mailing list first.
>
> I had used two nested surround templates, where both templates used a
> body tag. (The inner template would start by surrounding itself with
> the outer template, then bind the working content itself inside the
> body tag).
>
> Worked fine in Lift 1.0, but in 1.1, the working content would appear
> twice in the generated HTML, once at the very beginning, and then in
> the correct place inside the two nested surround templates.
>
> Long-term, it would be great to get an error message in this case.
>
> Regards,
> Tim
>
>
> --
>
> 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.




[Lift] Beware of using a body tag in a surrounded template, especially with nested surrounds

2009-12-01 Thread tiro
Hi,

I think it is documented somewhere in the Liftbook that one should not
use body tags inside a surround tag, but Lift doesn't seem to
complain.

I thought I would document the phenomenon I had here since people
usually look in the mailing list first.

I had used two nested surround templates, where both templates used a
body tag. (The inner template would start by surrounding itself with
the outer template, then bind the working content itself inside the
body tag).

Worked fine in Lift 1.0, but in 1.1, the working content would appear
twice in the generated HTML, once at the very beginning, and then in
the correct place inside the two nested surround templates.

Long-term, it would be great to get an error message in this case.

Regards,
Tim


--

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] **URGENT** Archetypes broken

2009-12-01 Thread Indrajit Raychaudhuri


On 01/12/09 7:59 PM, David Pollak wrote:
>
>
> On Mon, Nov 30, 2009 at 11:23 PM, Indrajit Raychaudhuri
> mailto:indraj...@gmail.com>> wrote:
>
>
>
> On 01/12/09 10:58 AM, David Pollak wrote:
>  >
>  >
>  > On Mon, Nov 30, 2009 at 8:25 PM, Ross Mellgren  
>  > >> wrote:
>  >
>  > It looks like they work to me. I'm using this:
>  >
>  > ...
>  > 
>  > ...
>  >
>  > I note you're using archetype:create? The wiki says
>  > archetype:generate; I don't know what archetype:create does,
> though
>  > it looks like an old (and deprecated) name for
> archetype:generate.
>  >
>  >
>  > archetype:create was working up through last week.  There were no
>  > **BREAKING CHANGES** notifications.  archetype:generate forces me to
>  > answer questions (the whole point of having a script is so I can type
>  > the script name and have it work.)
>  >
>  > Sorry for being grumpy about this, but I don't like things
>  > changing/breaking without some form of warning.
>
> Mea maxima culpa! This should have occurred to me that although
> deprecated, somebody still might have been using archetype:create.
>
> The jpa related archetypes had moved to the new archetype format quite
> sometime back. That made me assume the usage of archetype:generate
> pretty much 'given'. In hindsight, I think that was a bad assumption!
>
>
> Except when I sent around the call for getting the JPA stuff tested, my
> example was with create and it failed in exactly the same way as the new
> stuff failed.
>
> Sorry for continuing to be grumpy about this, but I should not have to
> be a maven guru to use Lift.  There are a couple of simple maven
> commands I need to know and if those commands change, I should at the
> very least get a polite message telling me what has changed.  If I woke
> up and "mvn clean jetty:run" had somehow morphed into something else,
> I'd like to know.

In complete agreement, and you have every reason to be grumpy. Just that 
(a) I didn't manage to send out the summary of archetype related changes 
this weekend and (b) under-assessed the need for communicating the 
difference between archetype:generate and archetype:create immediately 
after the merge to the master. Even at least making a reference in the 
RB note might have helped. Again, sorry on all the counts.

>
> I look forward to the breaking changes note.  I look forward to making
> sure that we keep Lift easy to use by providing our user base with
> simple and understandable migrations when things change.

Have just sent out a note. Hope that would help. Additionally, I'll 
update the relevant wiki pages in a couple of days to reflect these 
changes. Of course anybody else updating the wiki meanwhile is more than 
welcome.

>
>
> Nonetheless, very sorry for this inconvenience. And even more, sorry for
> the oversight in not sending out the **BREAKING CHANGES** email. I'll
> take care of this later in the day.
>
> - Indrajit
>
>  >
>  >
>  > -Ross
>  >
>  > On Nov 30, 2009, at 10:51 PM, David Pollak wrote:
>  >
>  >> Folks,
>  >>
>  >> Somehow somebody broke the basic archetype.  This is not
>  >> acceptable.  Here's what I typed and here's what happened:
>  >>
>  >> d...@sevenof9:~/tmp$ cat /home/dpp/bin/new_lift
>  >> #!/bin/sh
>  >> mvn archetype:create -U   -DarchetypeGroupId=net.liftweb \
>  >> -DarchetypeArtifactId=lift-archetype-basic \
>  >> -DarchetypeVersion=1.1-SNAPSHOT \
>  >>
> -DremoteRepositories=http://scala-tools.org/repo-snapshots \
>  >> -DgroupId=$1 -DartifactId=$2
>  >>
>  >>
>  >> d...@sevenof9:~/tmp$ new_lift com.liftcode imagine
>  >> [INFO] Scanning for projects...
>  >> [INFO] Searching repository for plugin with prefix:
> 'archetype'.
>  >> [INFO] org.apache.maven.plugins: checking for updates
> from central
>  >> [INFO] org.codehaus.mojo: checking for updates from central
>  >> [INFO] artifact
>  >> org.apache.maven.plugins:maven-archetype-plugin:
> checking for
>  >> updates from central
>  >> [INFO]
>  >>
> 
>  >> [INFO] Building Maven Default Project
>  >> [INFO]task-segment: [archetype:create]
> (aggregator-style)
>  >> [INFO]
>  >>
> 
>  >> [INFO] Setting property: classpath.resource.loader.class =>
>  >> 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
>  >> [INFO] Setting property: v

Re: [Lift] **URGENT** Archetypes broken

2009-12-01 Thread David Pollak
On Mon, Nov 30, 2009 at 11:23 PM, Indrajit Raychaudhuri  wrote:

>
>
> On 01/12/09 10:58 AM, David Pollak wrote:
> >
> >
> > On Mon, Nov 30, 2009 at 8:25 PM, Ross Mellgren  > > wrote:
> >
> > It looks like they work to me. I'm using this:
> >
>  > ...
>  > 
>  > ...
> >
> > I note you're using archetype:create? The wiki says
> > archetype:generate; I don't know what archetype:create does, though
> > it looks like an old (and deprecated) name for archetype:generate.
> >
> >
> > archetype:create was working up through last week.  There were no
> > **BREAKING CHANGES** notifications.  archetype:generate forces me to
> > answer questions (the whole point of having a script is so I can type
> > the script name and have it work.)
> >
> > Sorry for being grumpy about this, but I don't like things
> > changing/breaking without some form of warning.
>
> Mea maxima culpa! This should have occurred to me that although
> deprecated, somebody still might have been using archetype:create.
>
> The jpa related archetypes had moved to the new archetype format quite
> sometime back. That made me assume the usage of archetype:generate
> pretty much 'given'. In hindsight, I think that was a bad assumption!
>

Except when I sent around the call for getting the JPA stuff tested, my
example was with create and it failed in exactly the same way as the new
stuff failed.

Sorry for continuing to be grumpy about this, but I should not have to be a
maven guru to use Lift.  There are a couple of simple maven commands I need
to know and if those commands change, I should at the very least get a
polite message telling me what has changed.  If I woke up and "mvn clean
jetty:run" had somehow morphed into something else, I'd like to know.

I look forward to the breaking changes note.  I look forward to making sure
that we keep Lift easy to use by providing our user base with simple and
understandable migrations when things change.



>
> Nonetheless, very sorry for this inconvenience. And even more, sorry for
> the oversight in not sending out the **BREAKING CHANGES** email. I'll
> take care of this later in the day.
>
> - Indrajit
>
> >
> >
> > -Ross
> >
> > On Nov 30, 2009, at 10:51 PM, David Pollak wrote:
> >
> >> Folks,
> >>
> >> Somehow somebody broke the basic archetype.  This is not
> >> acceptable.  Here's what I typed and here's what happened:
> >>
> >> d...@sevenof9:~/tmp$ cat /home/dpp/bin/new_lift
> >> #!/bin/sh
> >> mvn archetype:create -U   -DarchetypeGroupId=net.liftweb \
> >> -DarchetypeArtifactId=lift-archetype-basic \
> >> -DarchetypeVersion=1.1-SNAPSHOT \
> >> -DremoteRepositories=http://scala-tools.org/repo-snapshots\
> >> -DgroupId=$1 -DartifactId=$2
> >>
> >>
> >> d...@sevenof9:~/tmp$ new_lift com.liftcode imagine
> >> [INFO] Scanning for projects...
> >> [INFO] Searching repository for plugin with prefix: 'archetype'.
> >> [INFO] org.apache.maven.plugins: checking for updates from
> central
> >> [INFO] org.codehaus.mojo: checking for updates from central
> >> [INFO] artifact
> >> org.apache.maven.plugins:maven-archetype-plugin: checking for
> >> updates from central
> >> [INFO]
> >>
> 
> >> [INFO] Building Maven Default Project
> >> [INFO]task-segment: [archetype:create] (aggregator-style)
> >> [INFO]
> >>
> 
> >> [INFO] Setting property: classpath.resource.loader.class =>
> >> 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
> >> [INFO] Setting property: velocimacro.messages.on => 'false'.
> >> [INFO] Setting property: resource.loader => 'classpath'.
> >> [INFO] Setting property: resource.manager.logwhenfound =>
> 'false'.
> >> [INFO] [archetype:create {execution: default-cli}]
> >> [WARNING] This goal is deprecated. Please use mvn
> >> archetype:generate instead
> >> [INFO] Defaulting package to group ID: com.liftcode
> >> [INFO] We are using command line specified remote
> >> repositories: http://scala-tools.org/repo-snapshots
> >> [INFO] snapshot net.liftweb:lift-archetype-basic:1.1-SNAPSHOT:
> >> checking for updates from id0
> >> Downloading:
> >>
> http://scala-tools.org/repo-snapshots/net/liftweb/lift-archetype-basic/1.1-SNAPSHOT/lift-archetype-basic-1.1-SNAPSHOT.jar
> >> [INFO]
> >>
> 
> >> [INFO] Using following parameters for creating OldArchetype:
> >> lift-archetype-basic:1.1-SNAPSHOT
> >> [INFO]
> >>
> 
> >> [INFO] Para

[Lift] **BREAKING CHANGES**: Use "mvn archetype:generate" to generate 1.1-SNAPSHOT archetypes

2009-12-01 Thread Indrajit Raychaudhuri
Friends,

Following the recent refactoring that the Lift archetypes went though,
we have moved forward to the new archetype metadata format [1] for all
the archetypes.

So far, the JPA related archetypes were using the new metadata format
while the others (esp. lift-archetype-blank and lift-archetype-basic)
were still on the old format. Moving to the new metadata format helps
us keep things consistent, comply with Maven's recommendation and open
the archetypes up for additional future enhancements.

>From now on, the recommended Maven goal to generate projects from
archetype is to use "archetype:generate" [2]. The currently deprecated
Maven goal "archetype:create" [3] would not work to give expected
result and thus is not recommended anymore.

Therefore, to generate project from the archetypes in the master you
would use a command of the form:

mvn archetype:generate \
  -DarchetypeRepository=http://scala-tools.org/repo-snapshots \
  -DremoteRepositories=http://scala-tools.org/repo-snapshots \
  -DarchetypeGroupId=net.liftweb \
  -DarchetypeArtifactId=lift-archetype-blank \
  -DarchetypeVersion=1.1-SNAPSHOT \
  -DgroupId=com.mypackage \
  -DartifactId=myproject \
  -Dversion=1.0-SNAPSHOT

Currently, the possible archetypeArtifactId are:
  - lift-archetype-blank
  - lift-archetype-basic
  - lift-archetype-jpa-blank-single
  - lift-archetype-jpa-blank
  - lift-archetype-jpa-basic

If you create project interactively (default behavior), -DgroupId, -
DartifactId, -Dversion are optional. Maven would prompt for these
values (and some more) interactively.

On the other hand, if you are using a batch/shell script to generate
project non-interactively, you would need to add at least -DgroupId, -
DartifactId and additionally set -DinteractiveMode=false.


Cheers, Indrajit

References:
[1] 
http://maven.apache.org/plugins/maven-archetype-plugin/specification/archetype-metadata.html
[2] http://maven.apache.org/plugins/maven-archetype-plugin/generate-mojo.html
[3] http://maven.apache.org/plugins/maven-archetype-plugin/create-mojo.html

--

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] method call from out of nowhere

2009-12-01 Thread David Pollak
On Mon, Nov 30, 2009 at 11:26 PM, Hannes  wrote:

>  Hi David,
>
>
>
> On Mon, Nov 30, 2009 at 12:11 AM, Hannes  wrote:
>
>> Hi David,
>>
>> In my LimitOrder Meta Object, I did:
>>
>> override def afterCreate
>>
>> to inform an Actor, everytime a new Order is created. The Actor than calls
>> the joinOtherOrders method.
>> #
>> I think I understand it now. Cause I'm creating new orders inside the loop
>> at some point. But still I don' t really know, why it gets called after the
>> old scope of joinOtherOrders ends...
>>
>
> Sounds to me like it's all in your application's logic.  As others have
> pointed out, Thread.dumpStack will let you figure out where things are being
> called.
>
> I think the biggest problem is, that its necessary in my logic to inform
> the Actor, everytime a new order is created. This while-loop is an exception
> to this rule. I don't think that it would be a good idea, to change the
> behavior of how the Actor responds to messages, just to fix this case, or?
> Or is there any chance to tell a new order NOT to inform the Actor, even
> when its defined in def afterCreate ?
>

Without seeing the whole of your application logic, it's difficult for me to
advise you.


>
>
> Also, you might want to use recursion and pattern matching to replace your
> while loop (which is O(n^2) btw):
>
> def dealWithList(in: List[Something]): Unit = in match {
>   case Nil => () // nothing left to do
>   case x :: _ if x.condition1 => x.doThing1
>   case x :: _ if x.condition2 => x.doThing2
>   case x :: xs if x.condition3 => x.doThing3 ; dealWithList(xs)
>   case _ :: xs => dealWithList(xs)
> }
>
> I thought about pattern matching as well, but in my first implementation, I
> just wanted to get it running and change it afterwards. Something else: I
> think recursion is slower than a while-loop as long as its not tail
> recursive, or?
>

This case is tail recursive, so it's as fast as a well written while loop.
But you've got an O(n ^ 2) construct in your app, so performance doesn't
seem to be paramount.

Thanks,

David


>
> thanks.
>
>
> You have the same semantics of a while loop with the ability to break out,
> but the code is about your logic rather than about looping.
>
>
>>
>> thanks.
>>
>>
>>
>> On Sun, Nov 29, 2009 at 7:24 AM, Hannes  wrote:
>>
>>> Hey Lifters,
>>>
>>
>> How is joinOtherOrders being invoked?
>>
>>
>>>
>>> I've some really strange things going on here. Please consider this
>>> method definition. I've put alot of print "debug" statements between
>>> other statements. There's a while-loop that only starts, when the given
>>> list (orders) is not empty. It stops when "done" is set to true. So far,
>>> so good. Than, have a look at the Lift output. I put in a comment,
>>> pointing out where the program runs into the while loop.
>>>
>>> What really shocks me, are these print statements :
>>>
>>> before done=false
>>> after done=true
>>> i += 1
>>> outside while
>>> INFO - Service request (GET) / took 121 Milliseconds
>>> start of joinAll!
>>>
>>>
>>> The loop ends with "outside while" and than the method gets called again
>>> immediately! But who calls it? I don't
>>>
>>> Any ideas?
>>>
>>> thanks.
>>>
>>>
>>>
>>>  method definition
>>>
>>> --
>>>
>>> def joinOtherOrders: Unit = {
>>>
>>>def joinAll(orders: List[LimitOrder]) = {
>>>
>>>println("start of joinAll!")
>>>
>>>var done = false
>>>
>>>var i = 0
>>>
>>>while (!orders.isEmpty && !done) {
>>>
>>>println("i=" + i + ", " + "orders.isEmpty=" +
>>> orders.isEmpty + ", " + "done=" + done)
>>>
>>>if (this.lots.is == orders(i).lots.is){
>>>
>>>println("case-1")
>>>
>>>println("this=" + this + ", orders(i)=" + orders(i))
>>>
>>>this.open(orders(i))
>>>
>>>done = true
>>>
>>>}
>>>
>>>if (this.lots.is < orders(i).lots.is){
>>>
>>>println("case-2")
>>>
>>>println("this=" + this + ", orders(i)=" + orders(i))
>>>
>>>orders(i).reduceLots(this.lots.is)
>>>
>>>val newOrder = orders(i).cloneWith(this.lots.is)
>>>
>>>newOrder.save
>>>
>>>this.open(newOrder)
>>>
>>>println("before done=" + done)
>>>
>>>done = true
>>>
>>>println("after done=" + done)
>>>
>>>}
>>>
>>>if (this.lots.is > orders(i).lots.is){
>>>
>>>println("case-3")
>>>
>>>println("this=" + this + ", orders(i)=" + orders(i))
>>>
>>>this.reduceLots(orders(i).lots.is)
>>>
>>>val newOrder = this.cloneWith(orders(i).lots.is)
>>>
>>>newOrder.save
>>>
>>>newOrder.ope

[Lift] Re: Image upload and serving example

2009-12-01 Thread DMB
Just what I was looking for, thanks!

By the way, is there a way to assign a "name" attribute to a file
upload input field? The reason is I have a legacy piece of code that
does HTTP uploads by simulating a form submit. This code requires that
the form field name be known in advance, for obvious reasons.

On Nov 30, 9:26 pm, David Pollak 
wrote:
> Folks,
>
> Lately there's been a bunch of chatter on the list about image upload and
> figuring out how to put the image files in the right place to serve them
> again.
>
> I've written a simple example of image uploading, storing the image in the
> RDBMS and then serving the image.  You can find the code 
> at:http://github.com/dpp/imagine/
>
> The file upload snippet is very simple:
>
> class DoUpload {
>   private def saveFile(fp: FileParamHolder): Unit = {
>     fp.file match {
>       case null =>
>       case x if x.length == 0 =>
>       case x =>
>         val blob = ImageBlob.create.image(x).saveMe
>         ImageInfo.create.name
> (fp.fileName).mimeType(fp.mimeType).blob(blob).saveMe
>         S.notice("Thanks for the upload")
>         S.redirectTo("/")
>     }
>   }
>
>   def render(in: NodeSeq): NodeSeq =
>   bind("upload", in, "file" -> SHtml.fileUpload(saveFile _))
>
> }
>
> If the blob is uploaded, it's put in a row in ImageBlob and an ImageInfo row
> is created to store the name and mime type.  There are two different rows so
> that one doesn't have to pull the whole blob back when you're checking for
> the upload date.
>
> Serving the image is similarly concise:
>
>   def serveImage: LiftRules.DispatchPF = {
>     case req @ Req("images" :: _ :: Nil, _, GetRequest) if
> findFromRequest(req).isDefined =>
>       () => {
>         val info = findFromRequest(req).open_! // open is valid here because
> we just tested in the guard
>
>         // Test for expiration
>         req.testFor304(info.date, "Expires" -> toInternetDate(millis +
> 30.days)) or
>         // load the blob and return it
>         info.blob.obj.map(blob => InMemoryResponse(blob.image,
> List(("Last-Modified", toInternetDate(info.date.is)),
>
>  ("Expires", toInternetDate(millis + 30.days)),
>
>  ("Content-Type", info.mimeType.is)), Nil,  200))
>       }
>   }
>
> If the request matches /images/xxx where xxx is a name in the ImageInfo
> table, check to see if we can return a 304 (not modified).  If not, we pull
> the blob from the database and return it.
>
> I hope this helps folks who are looking to manage and serve images.
>
> Thanks,
>
> David
>
> --
> 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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.