[Lift] Re: primeObj

2009-08-12 Thread David Pollak
On Wed, Aug 12, 2009 at 5:53 PM, Naftoli Gugenheim wrote:

>
> Why doesn't MappedLongForeignKey.apply(v: O) call primeObj?


Because the caching is not the default behavior.  The priming is for getting
the objects precached as part of the query.


>
> And why doesn't setting its value directly invalidate the cache?
> Thanks.
>
>
> >
>


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

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



[Lift] primeObj

2009-08-12 Thread Naftoli Gugenheim

Why doesn't MappedLongForeignKey.apply(v: O) call primeObj?
And why doesn't setting its value directly invalidate the cache?
Thanks.


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



[Lift] Please follow good practice when filing defects

2009-08-12 Thread David Pollak
Folks,

When you file a defect (or a request a feature), please include a
reproducible example... the best way to do this is to clone the
http://github.com/dpp/lift_1_1_sample/tree/master project and build a simple
app that shows the problem.

Also, please include the expected output... even if it's obvious to you.  I
closed two tickets today that included text like "this should work, too".
What does "work" mean to you because in both cases the output looked just
fine to me.

As Lift grows, please take the time to file tickets with enough information
that a committer can pick up the issue and work it without building a lot of
example code or trying to crawl into the ticket opener's head.

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
Git some: http://github.com/dpp

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



[Lift] Re: todo app., Oracle: Invalid column type

2009-08-12 Thread Derek Chen-Becker
I'm deploying a new version of 1.0.1-SNAPSHOT right now onto scala-tools.org.
It should be ready in 30 minutes or so with the fixes for Oracle and
PostgreSQL.

Derek

On Tue, Aug 11, 2009 at 9:40 AM, Derek Chen-Becker wrote:

> Yeah, that's basically how you do it in PostgreSQL, although they have an
> alias SERIAL that does the work of setting up the sequence and everything
> for you.
>
> Derek
>
>
> On Tue, Aug 11, 2009 at 10:23 AM, Kris Nuttycombe <
> kris.nuttyco...@gmail.com> wrote:
>
>>
>> ROWID is indeed a pseudo-column that isn't even stable, to my
>> knowledge. I've always know it as a 0-based index over the rows
>> returned from a query.
>>
>> As of 9i, at least, Oracle insisted that you implement
>> auto-incrementing columns manually using a sequence and an associated
>> trigger. I presume that they have a good reason for this, perhaps
>> related to replication or something. It's a hassle.
>>
>> Kris
>>
>> On Mon, Aug 10, 2009 at 4:26 PM, Derek Chen-Becker
>> wrote:
>> > OK, I think that I've at least figured out the cause of the exception.
>> The
>> > Oracle driver is set to use ROWID for primary keys and long indices. As
>> far
>> > as I can tell from the Oracle docs, ROWID is a pseudo-column and
>> shouldn't
>> > really be used as a column type in table creation DDL. The Boolean
>> > conversion appears to be working correctly, so now I just need to figure
>> out
>> > the best way to abstract auto-increment column creation.
>> >
>> > Derek
>> >
>> > On Mon, Aug 10, 2009 at 1:51 AM, Jon Kleiser 
>> > wrote:
>> >>
>> >> Hi,
>> >>
>> >> Here's the contents of my default.props file:
>> >>
>> >> db.driver = oracle.jdbc.OracleDriver
>> >> db.url = jdbc:oracle:thin:@myserver.site.no:1540:mydatabase
>> >> db.user = myuser
>> >> db.password = xxx
>> >>
>> >> The file is located in todo/src/main/webapp/WEB-INF/classes/props/
>> >>
>> >> /Jon
>> >>
>> >>
>> >> On 8/10/09 5:01 AM, Derek Chen-Becker wrote:
>> >>>
>> >>> Or at least the JDBC connection URL that you're using (no passwords or
>> >>> username needed).
>> >>>
>> >>> On Sun, Aug 9, 2009 at 8:25 AM, Derek Chen-Becker <
>> dchenbec...@gmail.com
>> >>> > wrote:
>> >>>
>> >>>Please send me the props file. I want to duplicate exactly (as much
>> >>>as possible) what you're doing.
>> >>>
>> >>>Derek
>> >>>
>> >>>
>> >>>On Sat, Aug 8, 2009 at 2:14 PM, Jon Kleiser <
>> jon.klei...@usit.uio.no
>> >>>> wrote:
>> >>>
>> >>>Hi Derek,
>> >>>
>> >>>The attached file should be identical to the project I use for
>> >>>the Oracle
>> >>>testing, except that the file specifying the Oracle connection
>> >>>(was it
>> >>>default.props?) is missing. I have it on my PPC Mac, not here.
>> I
>> >>>guess you
>> >>>know how to create that file and where to put it. If you're not
>> >>>sure, let
>> >>>me know, and I'll send you the info early Monday (or later).
>> >>>
>> >>>/Jon
>> >
>> >
>> > >
>> >
>>
>> >>
>>
>

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



[Lift] Re: Mapper nullability

2009-08-12 Thread Naftoli Gugenheim
I filed an issue: http://github.com/dpp/liftweb/issues/#issue/48There's
something wrong with the code formatting.
Also for NOT NULL - http://github.com/dpp/liftweb/issues#issue/47

On Tue, Aug 11, 2009 at 2:44 PM, David Pollak  wrote:

>
>
> On Sun, Aug 9, 2009 at 6:15 PM, Naftoli Gugenheim wrote:
>
>>
>> Does Mapper have control over the nullability of a column? Is there a way
>> to specify NOT NULL?
>
>
> No.  Support for particular databases will set primary keys to NOT NULL.
>
>
>>
>> Also, what am I doing wrong if my IdPK'd tables aren't having their id
>> columns created as primary keys in H2?
>
>
> This is likely a bug in the H2 support.  If you've got a reproducible case,
> please file a defect.
>
>
>>
>> Thanks.
>>
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
> >
>

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



[Lift] Re: TableEditor article

2009-08-12 Thread Timothy Perrett

Just tweaked the spacing mainly - there appear to be some slight
oddities with the textile parser. It also doesnt like code with tabs,
it prefers spaces.

Cheers, Tim

On Aug 12, 11:35 pm, Naftoli Gugenheim  wrote:
> Thanks. What did you have to do to fix the markup?
>
> On Wed, Aug 12, 2009 at 6:22 PM, Timothy Perrett 
> wrote:
>
>
>
>
>
> > I just fixed the article markup - thanks for writing it up.
>
> > Cheers, Tim
>
> > On Aug 12, 10:51 pm, Naftoli Gugenheim  wrote:
> > > Apparently some less than/greater than signs aren't being converted into
> > > their entity format.
>
> > > On Wed, Aug 12, 2009 at 5:49 PM, Naftoli Gugenheim  > >wrote:
>
> > > >http://wiki.github.com/dpp/liftweb/example-use-tableeditor-to-manage-.
> > ..
>
> > > > On Wed, Aug 12, 2009 at 5:48 PM, Naftoli Gugenheim <
> > naftoli...@gmail.com>wrote:
>
> > > >> I just wrote a brief wiki article on GitHub about using TableEditor,
> > but
> > > >> not being familiar with the formatting syntax, the code snippets are
> > > >> truncated. Can anyone take a look at it and fix it? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: TableEditor article

2009-08-12 Thread Naftoli Gugenheim
Thanks. What did you have to do to fix the markup?

On Wed, Aug 12, 2009 at 6:22 PM, Timothy Perrett wrote:

>
> I just fixed the article markup - thanks for writing it up.
>
> Cheers, Tim
>
> On Aug 12, 10:51 pm, Naftoli Gugenheim  wrote:
> > Apparently some less than/greater than signs aren't being converted into
> > their entity format.
> >
> > On Wed, Aug 12, 2009 at 5:49 PM, Naftoli Gugenheim  >wrote:
> >
> >
> >
> >
> >
> > >http://wiki.github.com/dpp/liftweb/example-use-tableeditor-to-manage-.
> ..
> >
> > > On Wed, Aug 12, 2009 at 5:48 PM, Naftoli Gugenheim <
> naftoli...@gmail.com>wrote:
> >
> > >> I just wrote a brief wiki article on GitHub about using TableEditor,
> but
> > >> not being familiar with the formatting syntax, the code snippets are
> > >> truncated. Can anyone take a look at it and fix it? Thanks.
> >
>

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



[Lift] Re: TableEditor article

2009-08-12 Thread Timothy Perrett

I just fixed the article markup - thanks for writing it up.

Cheers, Tim

On Aug 12, 10:51 pm, Naftoli Gugenheim  wrote:
> Apparently some less than/greater than signs aren't being converted into
> their entity format.
>
> On Wed, Aug 12, 2009 at 5:49 PM, Naftoli Gugenheim 
> wrote:
>
>
>
>
>
> >http://wiki.github.com/dpp/liftweb/example-use-tableeditor-to-manage-...
>
> > On Wed, Aug 12, 2009 at 5:48 PM, Naftoli Gugenheim 
> > wrote:
>
> >> I just wrote a brief wiki article on GitHub about using TableEditor, but
> >> not being familiar with the formatting syntax, the code snippets are
> >> truncated. Can anyone take a look at it and fix it? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Need to be able to add a css class to a form input type if field error - how?

2009-08-12 Thread David Pollak
On Wed, Aug 12, 2009 at 3:18 PM, Ewan  wrote:

>
> Doh.  Thx again.  Keep it simple, keep it simple, keep it simple...



Yes and when you use the .length method, be very afraid... it's O(n) on a
List.


>
>
> On Aug 12, 11:15 pm, David Pollak 
> wrote:
> > On Wed, Aug 12, 2009 at 3:04 PM, Ewan  wrote:
> >
> > > Thanks that did the trick - very cool.  As a matter of scala I created
> > > a method to determine if an error notice had been set (cribbed from
> > > the Msg snippet) and would have preferred to pattern match on the list
> > > itself rather than its length.  How from a scala style point of view
> > > could I rewrite the following?
> >
> > !S.messagesById(id)(S.errors).isEmpty
> >
> >
> >
> >
> >
> >
> >
> > >  private def isFieldError(id: String) = {
> > >   S.messagesById(id)(S.errors).length match {
> > > case 0 => false
> > > case _ => true
> > >   }
> > >  }
> >
> > > -- Ewan
> >
> > > On Aug 12, 10:09 pm, David Pollak 
> > > wrote:
> > > > In your snippet:
> >
> > > > import scala.xml.Null
> >
> > > > SHtml.text(value, value = _) % (if (errorCondition) ("class" ->
> "error")
> > > > else Null)
> >
> > > > On Wed, Aug 12, 2009 at 12:01 PM, Ewan  wrote:
> >
> > > > > Guys
> >
> > > > > When a form field/input type is in error I would like to set the
> css
> > > > > class to something like "error" so that I can decorate it by adding
> a
> > > > > red border around it.  In Struts2 I used to alter the freemarker
> > > > > template, which generated the appropriate input type, by adding the
> > > > > class="error" part if the field was in the list of field errors.
> >
> > > > > Shtml does not attempt this but I guess as attributes can be
> supplied
> > > > > and the field errors must be available somewhere the logic could be
> > > > > coded outside of the form input creation code.  Any other ideas?
> >
> > > > > -- Ewan
> >
> > > > --
> > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > Follow me:http://twitter.com/dpp
> > > > Git some:http://github.com/dpp
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


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

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



[Lift] Re: Need to be able to add a css class to a form input type if field error - how?

2009-08-12 Thread Ewan

Doh.  Thx again.  Keep it simple, keep it simple, keep it simple...

On Aug 12, 11:15 pm, David Pollak 
wrote:
> On Wed, Aug 12, 2009 at 3:04 PM, Ewan  wrote:
>
> > Thanks that did the trick - very cool.  As a matter of scala I created
> > a method to determine if an error notice had been set (cribbed from
> > the Msg snippet) and would have preferred to pattern match on the list
> > itself rather than its length.  How from a scala style point of view
> > could I rewrite the following?
>
> !S.messagesById(id)(S.errors).isEmpty
>
>
>
>
>
>
>
> >  private def isFieldError(id: String) = {
> >   S.messagesById(id)(S.errors).length match {
> >     case 0 => false
> >     case _ => true
> >   }
> >  }
>
> > -- Ewan
>
> > On Aug 12, 10:09 pm, David Pollak 
> > wrote:
> > > In your snippet:
>
> > > import scala.xml.Null
>
> > > SHtml.text(value, value = _) % (if (errorCondition) ("class" -> "error")
> > > else Null)
>
> > > On Wed, Aug 12, 2009 at 12:01 PM, Ewan  wrote:
>
> > > > Guys
>
> > > > When a form field/input type is in error I would like to set the css
> > > > class to something like "error" so that I can decorate it by adding a
> > > > red border around it.  In Struts2 I used to alter the freemarker
> > > > template, which generated the appropriate input type, by adding the
> > > > class="error" part if the field was in the list of field errors.
>
> > > > Shtml does not attempt this but I guess as attributes can be supplied
> > > > and the field errors must be available somewhere the logic could be
> > > > coded outside of the form input creation code.  Any other ideas?
>
> > > > -- Ewan
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Git some:http://github.com/dpp
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp

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



[Lift] Re: how do you initialise a MappedLongForeignKey object?

2009-08-12 Thread george

ok. thanks for your help, i'll try out the various options and see
what works best for me.

On Aug 12, 1:26 pm, Naftoli Gugenheim  wrote:
> You have to mix it in to each foreign key field, i.e., User.address and 
> Address.user. Or only have one field, e.g., User.address, and a method on 
> Address that finds the user that references it (but it will only work once 
> they're saved).
>
> -
>
> george wrote:
>
> I add the address to the user
>
> user.address(a)
>
> later on the user gets saved
>
> the address is inserted in the address table
>
> but in the user table, the address id is NULL
>
> On Aug 11, 11:36 pm, Naftoli Gugenheim  wrote:
>
>
>
> > What do you mean?
>
> > -
>
> > george wrote:
>
> > Ok I am getting somewhere now, thanks!
>
> > The address goes into the database fine when I get a reference to it
> > like this:
>
> > def getAddress : Address =
> >         address.obj match {
> >                 case Full(a) => a
> >                 case _ =>
> >                         val a = new Address
> >                         address(a)
> >                         a
> >         }
>
> > But the problem now is that the corresponding foreign key on the users
> > table is not set...
>
> > On Aug 11, 11:13 pm, Naftoli Gugenheim  wrote:
>
> > > Just on the field, like you have it; not on the mapper.
>
> > > -
>
> > > george wrote:
>
> > > I'm not sure exactly how to implement that.
>
> > > Like this?
>
> > > Address.scala
> > > class Address extends LongKeyedMapper[Address] with IdPK with
> > > LongMappedForeignMapper[T,Address]
>
> > > User.scala
> > > class User extends MegaProtoUser[User] {
> > > object address extends MappedLongForeignKey(this, Address) with
> > > LongMappedForeignMapper[User, Address]
>
> > > }
>
> > > This was the only docs I could find on the LongMappedForeignMapper:
>
> > >http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relat...
>
> > > How does it work for a 1 - 1 relationship?
>
> > > On Aug 11, 10:36 pm, Naftoli Gugenheim  wrote:
>
> > > > Did you try LongMappedForeignMapper? I created it for this exact 
> > > > purpose, so if it's not working I want to know.
> > > > Thanks.
>
> > > > -
>
> > > > george wrote:
>
> > > > Hi Steffen, thanks for the thought.
>
> > > > In your case I think the User object will already be saved in the
> > > > database when you add an address to it.
>
> > > > I'm trying to make it so that when a new User signs up, they fill in
> > > > their address at the same time as the other fields. So there is no
> > > > User object in the database to add an address to yet.
>
> > > > On Aug 11, 9:57 pm, Steffen Weißmann
>
> > > >  wrote:
> > > > > I think the problem is the "new Address". You need
> > > > > Address.create.save. My code is:
>
> > > > >         def addAddress(form: NodeSeq) = {
> > > > >             val user = User.currentUser.open_!
> > > > >                 val addr = user.address.obj.openOr {
> > > > >                         val newAdr = Address.create
> > > > >                         newAdr.save
> > > > >                         user.address(newAdr).save
> > > > >                         println("Creating new Address for user 
> > > > > "+user.firstName+" "+user.lastName)
> > > > >                         newAdr
> > > > >                 }
> > > > >                 def doBind(form: NodeSeq): NodeSeq =
> > > > >                         {bind("form", form,
> > > > >                                 "table" -> 
> > > > > addr.toForm(Full(S.?("address.submit")), doBind, addr
> > > > > => addr.save)
> > > > >                         )}
> > > > >                 doBind(form)
> > > > >         }
>
> > > > > Steffen.
>
> > > > > On Tue, Aug 11, 2009 at 10:48 PM, Naftoli 
> > > > > Gugenheim wrote:
>
> > > > > > Try mixing in LongMappedForeignMapper to address, or calling 
> > > > > > address.primeObj(addressObj).
> > > > > > What doesn't work the way you tried?
>
> > > > > > -
> > > > > > george wrote:
>
> > > > > > I have extended MegaProtoUser in order to add a related Address 
> > > > > > object
> > > > > > which is a MappedLongForeignKey.
>
> > > > > > The idea being simply that there is a 1 to 1 relationship between a
> > > > > > User and their Address.
>
> > > > > > When a new User object is instantiated (but not yet persisted), I 
> > > > > > want
> > > > > > to be able to get the related address object like this:
>
> > > > > > user.address.obj
>
> > > > > > But the returned Box is always empty, I guess because nothing has 
> > > > > > been
> > > > > > saved yet.
>
> > > > > > I need to somehow initialise the address if it is Empty otherwise
> > > > > > return the current Address.
>
> > > > > > I thought something like this would work, but it doesn't:
>
> > > > > > user.address.obj.openOr(user.address(new 
> > > > > > Address).address.obj.open_!)
>
> > 

[Lift] Re: Need to be able to add a css class to a form input type if field error - how?

2009-08-12 Thread David Pollak
On Wed, Aug 12, 2009 at 3:04 PM, Ewan  wrote:

>
> Thanks that did the trick - very cool.  As a matter of scala I created
> a method to determine if an error notice had been set (cribbed from
> the Msg snippet) and would have preferred to pattern match on the list
> itself rather than its length.  How from a scala style point of view
> could I rewrite the following?
>

!S.messagesById(id)(S.errors).isEmpty


>
>  private def isFieldError(id: String) = {
>   S.messagesById(id)(S.errors).length match {
> case 0 => false
> case _ => true
>   }
>  }
>
> -- Ewan
>
> On Aug 12, 10:09 pm, David Pollak 
> wrote:
> > In your snippet:
> >
> > import scala.xml.Null
> >
> > SHtml.text(value, value = _) % (if (errorCondition) ("class" -> "error")
> > else Null)
> >
> >
> >
> > On Wed, Aug 12, 2009 at 12:01 PM, Ewan  wrote:
> >
> > > Guys
> >
> > > When a form field/input type is in error I would like to set the css
> > > class to something like "error" so that I can decorate it by adding a
> > > red border around it.  In Struts2 I used to alter the freemarker
> > > template, which generated the appropriate input type, by adding the
> > > class="error" part if the field was in the list of field errors.
> >
> > > Shtml does not attempt this but I guess as attributes can be supplied
> > > and the field errors must be available somewhere the logic could be
> > > coded outside of the form input creation code.  Any other ideas?
> >
> > > -- Ewan
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


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

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



[Lift] Re: Need to be able to add a css class to a form input type if field error - how?

2009-08-12 Thread Ewan

Thanks that did the trick - very cool.  As a matter of scala I created
a method to determine if an error notice had been set (cribbed from
the Msg snippet) and would have preferred to pattern match on the list
itself rather than its length.  How from a scala style point of view
could I rewrite the following?

 private def isFieldError(id: String) = {
   S.messagesById(id)(S.errors).length match {
 case 0 => false
 case _ => true
   }
 }

-- Ewan

On Aug 12, 10:09 pm, David Pollak 
wrote:
> In your snippet:
>
> import scala.xml.Null
>
> SHtml.text(value, value = _) % (if (errorCondition) ("class" -> "error")
> else Null)
>
>
>
> On Wed, Aug 12, 2009 at 12:01 PM, Ewan  wrote:
>
> > Guys
>
> > When a form field/input type is in error I would like to set the css
> > class to something like "error" so that I can decorate it by adding a
> > red border around it.  In Struts2 I used to alter the freemarker
> > template, which generated the appropriate input type, by adding the
> > class="error" part if the field was in the list of field errors.
>
> > Shtml does not attempt this but I guess as attributes can be supplied
> > and the field errors must be available somewhere the logic could be
> > coded outside of the form input creation code.  Any other ideas?
>
> > -- Ewan
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp

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



[Lift] Re: TableEditor article

2009-08-12 Thread Naftoli Gugenheim
Apparently some less than/greater than signs aren't being converted into
their entity format.

On Wed, Aug 12, 2009 at 5:49 PM, Naftoli Gugenheim wrote:

>
> http://wiki.github.com/dpp/liftweb/example-use-tableeditor-to-manage-simple-lists
>
>
> On Wed, Aug 12, 2009 at 5:48 PM, Naftoli Gugenheim 
> wrote:
>
>> I just wrote a brief wiki article on GitHub about using TableEditor, but
>> not being familiar with the formatting syntax, the code snippets are
>> truncated. Can anyone take a look at it and fix it? Thanks.
>>
>
>

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



[Lift] Re: TableEditor article

2009-08-12 Thread Naftoli Gugenheim
http://wiki.github.com/dpp/liftweb/example-use-tableeditor-to-manage-simple-lists

On Wed, Aug 12, 2009 at 5:48 PM, Naftoli Gugenheim wrote:

> I just wrote a brief wiki article on GitHub about using TableEditor, but
> not being familiar with the formatting syntax, the code snippets are
> truncated. Can anyone take a look at it and fix it? Thanks.
>

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



[Lift] TableEditor article

2009-08-12 Thread Naftoli Gugenheim
I just wrote a brief wiki article on GitHub about using TableEditor, but not
being familiar with the formatting syntax, the code snippets are truncated.
Can anyone take a look at it and fix it? Thanks.

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



[Lift] Re: Need to be able to add a css class to a form input type if field error - how?

2009-08-12 Thread David Pollak
In your snippet:

import scala.xml.Null

SHtml.text(value, value = _) % (if (errorCondition) ("class" -> "error")
else Null)


On Wed, Aug 12, 2009 at 12:01 PM, Ewan  wrote:

>
> Guys
>
> When a form field/input type is in error I would like to set the css
> class to something like "error" so that I can decorate it by adding a
> red border around it.  In Struts2 I used to alter the freemarker
> template, which generated the appropriate input type, by adding the
> class="error" part if the field was in the list of field errors.
>
> Shtml does not attempt this but I guess as attributes can be supplied
> and the field errors must be available somewhere the logic could be
> coded outside of the form input creation code.  Any other ideas?
>
> -- Ewan
>
> >
>


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

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



[Lift] Re: h2 web console

2009-08-12 Thread Tim Nelson
That actually starts up a webserver that serves the H2 console servlet.
Alternatively, you can just use the servlet inside your existing app,
without having to start a separate web server.

http://gist.github.com/19

Also, if you're using H2, you might want to try their built-in connection
pool.

http://gist.github.com/166687

Tim

On Wed, Aug 12, 2009 at 1:14 PM, jon  wrote:

>
> Hi,
>
> For those using h2, you can make a call to the following function from
> boot to start up a web console while you're running in development
> mode:
>
>  def startH2WebConsole = {
>if (Props.mode == Props.RunModes.Development) {
>  import _root_.org.h2.server.web.WebServer
>  import _root_.org.h2.tools.Server
>  import _root_.org.h2.util.StartBrowser
>  val webServer = new WebServer()
>  val server  = new Server(webServer, Array("-webPort", "0"))
>  server.start
>  DBVendor.newConnection(DefaultConnectionIdentifier).map
> (c=>StartBrowser.openURL(webServer.addSession(c)))
>}
>  }
>
> - Jon
> >
>

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



[Lift] Need to be able to add a css class to a form input type if field error - how?

2009-08-12 Thread Ewan

Guys

When a form field/input type is in error I would like to set the css
class to something like "error" so that I can decorate it by adding a
red border around it.  In Struts2 I used to alter the freemarker
template, which generated the appropriate input type, by adding the
class="error" part if the field was in the list of field errors.

Shtml does not attempt this but I guess as attributes can be supplied
and the field errors must be available somewhere the logic could be
coded outside of the form input creation code.  Any other ideas?

-- Ewan

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



[Lift] Re: New Mapped Fields (MappedTimestamp and MappedMac)

2009-08-12 Thread Peter Robinett

Ok, I think we all agree now that a mixin trait wasn't the best idea.
I've gone back and rewritten MappedTimestamp as a class which extended
MappedDateTime, and I think it's now working correctly. The commit is
here: 
http://github.com/pr1001/lift_1_1_sample/commit/d744a7cffe7d929ddbc531e8d8afea864a6fdc72

Peter

On Aug 8, 6:30 am, David Pollak  wrote:
> On Sat, Aug 8, 2009 at 2:05 AM, Peter Robinett wrote:
>
>
>
> > I thought Naftoli's suggestion to make it a mixin so that it could be
> > added to MappedDates or MappedDateTimes was a reasonable one. Do you
> > think this just complicates things?
>
> Yes.  It's more code for a developer to type and it's more complex under the
> covers.
>
>
>
>
>
> > Peter
>
> > On Aug 7, 5:19 pm, David Pollak  wrote:
> > > Why are you trying to make this a mixin?  Why not just create a
> > > MappedTimestamp field?
>
> > > On Tue, Aug 4, 2009 at 2:27 PM, Peter Robinett  > >wrote:
>
> > > > Ahh, good idea. The compile errors all had to do with the the type
> > > > parameters. I don't know much about Scala's type system yet, so I was
> > > > defining the trait incorrectly based upon code I had copied and
> > > > pasted.
>
> > > > I'm now trying to have MappedTimestamp extend MappedField[Date, T]
> > > > instead and I am this much closer to getting it to work. Here are the
> > > > compile errors:
> > > > /Users/peter/Sites/liftstringprimary/src/main/scala/com/liftcode/model/
> > > > Cat.scala:38: error: illegal inheritance;
> > > >  object ts inherits different type instances of trait MappedField:
> > > > net.liftweb.mapper.MappedField
> > > > [java.util.Date,net.liftweb.mapper.MappedDateTime[java.util.Date]] and
> > > > net.liftweb.mapper.MappedField[java.util.Date,com.liftcode.model.Cat]
> > > >  object ts extends MappedDateTime(this) with MappedTimestamp
> > > > [MappedDateTime[Date]]
> > > >        ^
> > > > /Users/peter/Sites/liftstringprimary/src/main/scala/com/liftcode/model/
> > > > Cat.scala:38: error: type arguments [net.liftweb.mapper.MappedDateTime
> > > > [java.util.Date]] do not conform to trait MappedTimestamp's type
> > > > parameter bounds [T <: net.liftweb.mapper.Mapper[T]]
> > > >  object ts extends MappedDateTime(this) with MappedTimestamp
> > > > [MappedDateTime[Date]]
> > > >                                             ^
> > > > two errors found
>
> > > > The relevant lines, I believe, are:
> > > > Cat.scala: object ts extends MappedDateTime(this) with MappedTimestamp
> > > > [MappedDateTime[Date]]
> > > > MappedTimstamp.scala: trait MappedTimestamp[T<:Mapper[T]] extends
> > > > MappedField[Date, T] {
>
> > > > And the code on GitHub:
> > > >http://github.com/pr1001/lift_1_1_sample/tree/master
>
> > > > As for all the overrides, looking at it again I see that I didn't need
> > > > to override all those build methods. The others are still needed to
> > > > have millisecond Longs where appropriate.
>
> > > > Peter
>
> > > > Peter
>
> > > > On Aug 4, 1:17 pm, Naftoli Gugenheim  wrote:
> > > > > Didn't look very closely, but if you extend MappedDate you lock
> > yourself
> > > > out of MappedDatTime and vice versa. However both of them extend
> > > > MappedField[Date, T] which is a trait not a class, so if you extend
> > that it
> > > > should be mixable in to both.
> > > > > What was the compile error?
> > > > > Aren't you writing a lot of functionality that is in
> > MappedDate(Time)?
> > > > Define your mixin as a delta to MappedDate(Time); it should only have
> > the
> > > > aspects that differentiate it.
>
> > > > > -
>
> > > > > Peter Robinett wrote:
>
> > > > > Not at all, I just thought it would be hard to read. Here it is:
>
> > > > > Peter
>
> > > > > import _root_.java.sql.{ResultSet, Types}
> > > > > import _root_.java.util.Date
> > > > > import _root_.java.lang.reflect.Method
>
> > > > > import _root_.net.liftweb._
> > > > > import util._
> > > > > import Helpers._
> > > > > import http._
> > > > > import S._
> > > > > import js._
>
> > > > > import _root_.scala.xml.{NodeSeq}
>
> > > > > import net.liftweb.mapper.Mapper
> > > > > import net.liftweb.mapper.MappedDateTime
>
> > > > > trait MappedTimestamp[T<:Mapper[T]] extends MappedDateTime[Date] {
> > > > >   this: T with MappedTimestamp[T] =>
>
> > > > >   override def toLong: Long = is match {
> > > > >     case null => 0L
> > > > >     case d: Date => d.getTime
> > > > >   }
>
> > > > >   /**
> > > > >    * Get the JDBC SQL Type for this field
> > > > >    */
> > > > >   override def targetSQLType = Types.BIGINT
>
> > > > >   /**
> > > > >    * Create an input field for the item
> > > > >    */
> > > > >   override def _toForm: Box[NodeSeq] =
> > > > >   S.fmapFunc({s: List[String] => this.setFromAny(s)}){funcName =>
> > > > >   Full( > > > >       name={funcName} lift:gc={funcName}
> > > > >       value={is match {case null => "" case s => s}}/>)
> > > > >   }
>
> > > > >   override def jdbcFriendly(field : String) : Object = is match {
> > > > >     case 

[Lift] Re: More problems with CRUDify and SessionVars

2009-08-12 Thread David Pollak
On Mon, Aug 10, 2009 at 9:07 AM, Jeppe Nejsum Madsen wrote:

>
> David Pollak  writes:
>
> > (1) Don't use open_! unless you have a very, very, very good reason to do
> > so.  It defeats the purpose of Box.
>
> I'm aware of this. But in this situation, most Locs are protected, ie the
> user is always logged in, so the only alternatives I see are:
>
> 1) wrap the code in map or something similar which will then return
> Empty if no user is found. But this is dangerous, giving the user the
> impression that no data is found when in fact this is a coding error.


User.currentUserId.map(... business logic here) openOr defaultValue


>
>
> 2) Redirect to a nice error page if this code is called with no user
> active. This is of course the nice solution, but we have more pressing
> needs atm :-)
>
> But maybe I've missed something obvious and there are better ways to
> handle this?


See the above code.

>
>
> > (2) If you have a particular question/example of what you want to do (a
> > complete, runnable example), I can work out a pattern for you.
>
> The question comes down to: Why is User.currentUserId Empty when
> findForParam is called?


Because this method is called during the re-writing phase.

I've updated Lift to make the session available during the re-writing phase
if there is a session (a new session will not be created) to deal with this
situation.


> The user is signed in, since
> findForListParams works fine.
>
> If I remember the previous thread correctly, there is some tension
> between request rewriting (as is done in CRUDify when edit/delete
> actions are called ) and the session/request var initialization. Wonder
> if I'm seeing more of the same here?
>
> I might be able to put together an example, but that will have to wait a
> few days (lots of stuff to catch up with after vacation :-)
>
> /Jeppe
>
> >
>


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

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



[Lift] Re: bind with outer element?

2009-08-12 Thread David Pollak
On Wed, Aug 12, 2009 at 11:31 AM, jon  wrote:

>
> Thanks Ross! that works.


+1


>
>
> On Aug 12, 1:59 pm, Ross Mellgren  wrote:
> > BindHelpers.currentNode is a Box[NodeSeq] that gives you the node that
> > bind is currently replacing.
> >
> > -Ross
> >
> > On Aug 12, 2009, at 11:02 AM, jon wrote:
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > I actually solved by wrapping the node i cared about in another node,
> > > but tried the FuncBindParam and it does seem to only grab the child
> > > nodes.
> >
> > > On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
> > >> Doesn't the FuncBindParam only get the element's child NodeSeq?
> >
> > >> -
> >
> > >> David Pollak wrote:
> > >> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
> >
> > >>> Hi,
> >
> > >>> I have a template with the following
> >
> > >>> 
> > >>>  
> > >>>  
> > >>>
> > >>>...
> > >>>  
> > >>> 
> >
> > >>> And a snippet like:
> >
> > >>> def doSnippet(x:NodeSeq):NodeSeq = {
> > >>>  bind("t", x,
> > >>>"name"-> (doName(_)),
> >
> > >> try:
> >
> > >> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
> > >> longVersion else shortVersion
> >
> > >> bind("t", x, FuncBindParam("name", myFunc _))
> >
> > >> You get the complete  passed to myFunc.
> >
> > >> Thanks,
> >
> > >> David
> >
> > >>>"foo" -> (doForm(_))
> > >>>  )
> > >>> }
> >
> > >>> In the code above only the contents of the bound tags are available
> > >>> for doName and doForm, if I want to be able to read the attribute
> > >>> "shorten" in doName and have "foo" render with an enclosing 
> > >>> tag,  how do I create the bind params?
> >
> > >>> I am doing an expensive batch operation upfront, so I want
> > >>> everything
> > >>> to be in the same snippet.
> >
> > >>> Thanks,
> >
> > >>> Jon
> >
> > >> --
> > >> Lift, the simply functional web frameworkhttp://liftweb.net
> > >> Beginning Scalahttp://www.apress.com/book/view/1430219890
> > >> Follow me:http://twitter.com/dpp
> > >> Git some:http://github.com/dpp
> >
>


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

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



[Lift] Re: bind with outer element?

2009-08-12 Thread jon

Thanks Ross! that works.

On Aug 12, 1:59 pm, Ross Mellgren  wrote:
> BindHelpers.currentNode is a Box[NodeSeq] that gives you the node that  
> bind is currently replacing.
>
> -Ross
>
> On Aug 12, 2009, at 11:02 AM, jon wrote:
>
>
>
>
>
> > Hi,
>
> > I actually solved by wrapping the node i cared about in another node,
> > but tried the FuncBindParam and it does seem to only grab the child
> > nodes.
>
> > On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
> >> Doesn't the FuncBindParam only get the element's child NodeSeq?
>
> >> -
>
> >> David Pollak wrote:
> >> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
>
> >>> Hi,
>
> >>> I have a template with the following
>
> >>> 
> >>>  
> >>>  
> >>>    
> >>>    ...
> >>>  
> >>> 
>
> >>> And a snippet like:
>
> >>> def doSnippet(x:NodeSeq):NodeSeq = {
> >>>  bind("t", x,
> >>>    "name"-> (doName(_)),
>
> >> try:
>
> >> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
> >> longVersion else shortVersion
>
> >> bind("t", x, FuncBindParam("name", myFunc _))
>
> >> You get the complete  passed to myFunc.
>
> >> Thanks,
>
> >> David
>
> >>>    "foo" -> (doForm(_))
> >>>  )
> >>> }
>
> >>> In the code above only the contents of the bound tags are available
> >>> for doName and doForm, if I want to be able to read the attribute
> >>> "shorten" in doName and have "foo" render with an enclosing 
> >>> tag,  how do I create the bind params?
>
> >>> I am doing an expensive batch operation upfront, so I want  
> >>> everything
> >>> to be in the same snippet.
>
> >>> Thanks,
>
> >>> Jon
>
> >> --
> >> Lift, the simply functional web frameworkhttp://liftweb.net
> >> Beginning Scalahttp://www.apress.com/book/view/1430219890
> >> Follow me:http://twitter.com/dpp
> >> Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: ajaxForm with mapped function

2009-08-12 Thread jon

That is surprising...

revised function:

  def ajaxForm(body: NodeSeq,func: ()=>JsCmd) = {
  SHtml.ajaxForm(body ++ SHtml.hidden(func))
  }

very cool!

thanks,

- jon

On Aug 12, 11:51 am, David Pollak 
wrote:
> On Wed, Aug 12, 2009 at 8:14 AM, jon  wrote:
>
> > Thanks Dave,
>
> > I explored both of those routes.  The hidden field would allow me to
> > execute on the server, but not send back JS to execute on the client.
> > The ajaxButton would allow me to execute code on the client, but not
> > submit the form (unless I put the form serialize code in the
> > button?).  I wanted the JS code to vary depending on input from the
> > whole form submission.
>
> Try it... you'll be surprised.
>
> If you have a SHtml.hidden() that returns a JsCmd, that JsCmd will be sent
> to the browser.
>
>
>
>
>
>
>
> > On Aug 11, 8:17 pm, David Pollak 
> > wrote:
> > > On Tue, Aug 11, 2009 at 3:31 PM, jon  wrote:
>
> > > > Hi,
>
> > > > I'm not sure if this behavior already exists via some other mechanism,
> > > > but I wanted an ajaxForm that executed a JsCmd sent from the sever
> > > > after submit.  Here it is:
>
> > > >        def ajaxForm(body: NodeSeq,func: ()=>JsCmd) = {
> > > >          val id = Helpers.nextFuncName
>
> > > >          fmapFunc(func)(name =>  > > > onsubmit={makeAjaxCall(LiftRules.jsArtifacts.serialize(id)).toJsCmd+";
> > > > return false;"}>  {body}
> > > > )
> > > >        }
>
> > > > Is there a better way?
>
> > > You could use an ajaxButton to update the div... alternatively, put an
> > > SHtml.hidden field in the form itself.
>
> > > >  jsonForms seemed like a bit of overkill to do
> > > > what i wanted=> simple update of div after submit.
>
> > > > - Jon
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Git some:http://github.com/dpp
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] h2 web console

2009-08-12 Thread jon

Hi,

For those using h2, you can make a call to the following function from
boot to start up a web console while you're running in development
mode:

 def startH2WebConsole = {
if (Props.mode == Props.RunModes.Development) {
  import _root_.org.h2.server.web.WebServer
  import _root_.org.h2.tools.Server
  import _root_.org.h2.util.StartBrowser
  val webServer = new WebServer()
  val server  = new Server(webServer, Array("-webPort", "0"))
  server.start
  DBVendor.newConnection(DefaultConnectionIdentifier).map
(c=>StartBrowser.openURL(webServer.addSession(c)))
}
  }

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



[Lift] Re: bind with outer element?

2009-08-12 Thread Ross Mellgren

BindHelpers.currentNode is a Box[NodeSeq] that gives you the node that  
bind is currently replacing.

-Ross

On Aug 12, 2009, at 11:02 AM, jon wrote:

>
> Hi,
>
> I actually solved by wrapping the node i cared about in another node,
> but tried the FuncBindParam and it does seem to only grab the child
> nodes.
>
> On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
>> Doesn't the FuncBindParam only get the element's child NodeSeq?
>>
>> -
>>
>>
>>
>>
>>
>> David Pollak wrote:
>> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
>>
>>> Hi,
>>
>>> I have a template with the following
>>
>>> 
>>>  
>>>  
>>>
>>>...
>>>  
>>> 
>>
>>> And a snippet like:
>>
>>> def doSnippet(x:NodeSeq):NodeSeq = {
>>>  bind("t", x,
>>>"name"-> (doName(_)),
>>
>> try:
>>
>> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
>> longVersion else shortVersion
>>
>> bind("t", x, FuncBindParam("name", myFunc _))
>>
>> You get the complete  passed to myFunc.
>>
>> Thanks,
>>
>> David
>>
>>
>>
>>
>>
>>>"foo" -> (doForm(_))
>>>  )
>>> }
>>
>>> In the code above only the contents of the bound tags are available
>>> for doName and doForm, if I want to be able to read the attribute
>>> "shorten" in doName and have "foo" render with an enclosing 
>>> tag,  how do I create the bind params?
>>
>>> I am doing an expensive batch operation upfront, so I want  
>>> everything
>>> to be in the same snippet.
>>
>>> Thanks,
>>
>>> Jon
>>
>> --
>> Lift, the simply functional web frameworkhttp://liftweb.net
>> Beginning Scalahttp://www.apress.com/book/view/1430219890
>> Follow me:http://twitter.com/dpp
>> Git some:http://github.com/dpp
> >


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



[Lift] Re: ajaxForm with mapped function

2009-08-12 Thread David Pollak
On Wed, Aug 12, 2009 at 8:14 AM, jon  wrote:

>
> Thanks Dave,
>
> I explored both of those routes.  The hidden field would allow me to
> execute on the server, but not send back JS to execute on the client.
> The ajaxButton would allow me to execute code on the client, but not
> submit the form (unless I put the form serialize code in the
> button?).  I wanted the JS code to vary depending on input from the
> whole form submission.


Try it... you'll be surprised.

If you have a SHtml.hidden() that returns a JsCmd, that JsCmd will be sent
to the browser.


>
>
>
> On Aug 11, 8:17 pm, David Pollak 
> wrote:
> > On Tue, Aug 11, 2009 at 3:31 PM, jon  wrote:
> >
> > > Hi,
> >
> > > I'm not sure if this behavior already exists via some other mechanism,
> > > but I wanted an ajaxForm that executed a JsCmd sent from the sever
> > > after submit.  Here it is:
> >
> > >def ajaxForm(body: NodeSeq,func: ()=>JsCmd) = {
> > >  val id = Helpers.nextFuncName
> >
> > >  fmapFunc(func)(name =>  > > onsubmit={makeAjaxCall(LiftRules.jsArtifacts.serialize(id)).toJsCmd+";
> > > return false;"}>  {body}
> > > )
> > >}
> >
> > > Is there a better way?
> >
> > You could use an ajaxButton to update the div... alternatively, put an
> > SHtml.hidden field in the form itself.
> >
> > >  jsonForms seemed like a bit of overkill to do
> > > what i wanted=> simple update of div after submit.
> >
> > > - Jon
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
> >
>


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

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



[Lift] Re: ajaxForm with mapped function

2009-08-12 Thread jon

Thanks Dave,

I explored both of those routes.  The hidden field would allow me to
execute on the server, but not send back JS to execute on the client.
The ajaxButton would allow me to execute code on the client, but not
submit the form (unless I put the form serialize code in the
button?).  I wanted the JS code to vary depending on input from the
whole form submission.


On Aug 11, 8:17 pm, David Pollak 
wrote:
> On Tue, Aug 11, 2009 at 3:31 PM, jon  wrote:
>
> > Hi,
>
> > I'm not sure if this behavior already exists via some other mechanism,
> > but I wanted an ajaxForm that executed a JsCmd sent from the sever
> > after submit.  Here it is:
>
> >        def ajaxForm(body: NodeSeq,func: ()=>JsCmd) = {
> >          val id = Helpers.nextFuncName
>
> >          fmapFunc(func)(name =>  > onsubmit={makeAjaxCall(LiftRules.jsArtifacts.serialize(id)).toJsCmd+";
> > return false;"}>  {body}
> > )
> >        }
>
> > Is there a better way?
>
> You could use an ajaxButton to update the div... alternatively, put an
> SHtml.hidden field in the form itself.
>
> >  jsonForms seemed like a bit of overkill to do
> > what i wanted=> simple update of div after submit.
>
> > - Jon
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: bind with outer element?

2009-08-12 Thread jon

Hi,

I actually solved by wrapping the node i cared about in another node,
but tried the FuncBindParam and it does seem to only grab the child
nodes.

On Aug 11, 11:37 pm, Naftoli Gugenheim  wrote:
> Doesn't the FuncBindParam only get the element's child NodeSeq?
>
> -
>
>
>
>
>
> David Pollak wrote:
> On Mon, Aug 10, 2009 at 1:44 PM, jon  wrote:
>
> > Hi,
>
> > I have a template with the following
>
> > 
> >  
> >  
> >    
> >    ...
> >  
> > 
>
> > And a snippet like:
>
> > def doSnippet(x:NodeSeq):NodeSeq = {
> >  bind("t", x,
> >    "name"-> (doName(_)),
>
> try:
>
> def myFunc(node: NodeSeq): NodeSeq = if ((node \ "@shorten").isEmpty)
> longVersion else shortVersion
>
> bind("t", x, FuncBindParam("name", myFunc _))
>
> You get the complete  passed to myFunc.
>
> Thanks,
>
> David
>
>
>
>
>
> >    "foo" -> (doForm(_))
> >  )
> > }
>
> > In the code above only the contents of the bound tags are available
> > for doName and doForm, if I want to be able to read the attribute
> > "shorten" in doName and have "foo" render with an enclosing 
> > tag,  how do I create the bind params?
>
> > I am doing an expensive batch operation upfront, so I want everything
> > to be in the same snippet.
>
> > Thanks,
>
> > Jon
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: foreign key reference that will never be null

2009-08-12 Thread Derek Chen-Becker
I think that having control over nullability would be great, although in
this case we would have to make a separate MappedLongNotNullForeignKey trait
or something like it, since you can't arbitrarily change the return type on
the method from Box to T.

Derek

On Tue, Aug 11, 2009 at 6:12 PM, harryh  wrote:

>
> In my app I have a bunch of Users.  Each User is always in a city so I
> put this in User:
>
> object cityid extends MappedLongForeignKey(this, City)
>
> but this allows for things like cityid = NULL or cityid = something
> that is not a valid City pk.  And also cityid.obj is a Box[City]
> instead of just a City.  Is there something I can do to enforce a
> stronger constraint?  It would be great if
>
> A) I could avoid the Box entirely and just get a City
> B) The Schemafier set cityid NOT NULL and set a foreign key constraint
> in the database
>
> -harryh
>
> >
>

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



[Lift] Re: how do you initialise a MappedLongForeignKey object?

2009-08-12 Thread Naftoli Gugenheim

You have to mix it in to each foreign key field, i.e., User.address and 
Address.user. Or only have one field, e.g., User.address, and a method on 
Address that finds the user that references it (but it will only work once 
they're saved).

-
george wrote:


I add the address to the user

user.address(a)

later on the user gets saved

the address is inserted in the address table

but in the user table, the address id is NULL



On Aug 11, 11:36 pm, Naftoli Gugenheim  wrote:
> What do you mean?
>
> -
>
> george wrote:
>
> Ok I am getting somewhere now, thanks!
>
> The address goes into the database fine when I get a reference to it
> like this:
>
> def getAddress : Address =
>         address.obj match {
>                 case Full(a) => a
>                 case _ =>
>                         val a = new Address
>                         address(a)
>                         a
>         }
>
> But the problem now is that the corresponding foreign key on the users
> table is not set...
>
> On Aug 11, 11:13 pm, Naftoli Gugenheim  wrote:
>
>
>
> > Just on the field, like you have it; not on the mapper.
>
> > -
>
> > george wrote:
>
> > I'm not sure exactly how to implement that.
>
> > Like this?
>
> > Address.scala
> > class Address extends LongKeyedMapper[Address] with IdPK with
> > LongMappedForeignMapper[T,Address]
>
> > User.scala
> > class User extends MegaProtoUser[User] {
> > object address extends MappedLongForeignKey(this, Address) with
> > LongMappedForeignMapper[User, Address]
>
> > }
>
> > This was the only docs I could find on the LongMappedForeignMapper:
>
> >http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relat...
>
> > How does it work for a 1 - 1 relationship?
>
> > On Aug 11, 10:36 pm, Naftoli Gugenheim  wrote:
>
> > > Did you try LongMappedForeignMapper? I created it for this exact purpose, 
> > > so if it's not working I want to know.
> > > Thanks.
>
> > > -
>
> > > george wrote:
>
> > > Hi Steffen, thanks for the thought.
>
> > > In your case I think the User object will already be saved in the
> > > database when you add an address to it.
>
> > > I'm trying to make it so that when a new User signs up, they fill in
> > > their address at the same time as the other fields. So there is no
> > > User object in the database to add an address to yet.
>
> > > On Aug 11, 9:57 pm, Steffen Weißmann
>
> > >  wrote:
> > > > I think the problem is the "new Address". You need
> > > > Address.create.save. My code is:
>
> > > >         def addAddress(form: NodeSeq) = {
> > > >             val user = User.currentUser.open_!
> > > >                 val addr = user.address.obj.openOr {
> > > >                         val newAdr = Address.create
> > > >                         newAdr.save
> > > >                         user.address(newAdr).save
> > > >                         println("Creating new Address for user 
> > > > "+user.firstName+" "+user.lastName)
> > > >                         newAdr
> > > >                 }
> > > >                 def doBind(form: NodeSeq): NodeSeq =
> > > >                         {bind("form", form,
> > > >                                 "table" -> 
> > > > addr.toForm(Full(S.?("address.submit")), doBind, addr
> > > > => addr.save)
> > > >                         )}
> > > >                 doBind(form)
> > > >         }
>
> > > > Steffen.
>
> > > > On Tue, Aug 11, 2009 at 10:48 PM, Naftoli 
> > > > Gugenheim wrote:
>
> > > > > Try mixing in LongMappedForeignMapper to address, or calling 
> > > > > address.primeObj(addressObj).
> > > > > What doesn't work the way you tried?
>
> > > > > -
> > > > > george wrote:
>
> > > > > I have extended MegaProtoUser in order to add a related Address object
> > > > > which is a MappedLongForeignKey.
>
> > > > > The idea being simply that there is a 1 to 1 relationship between a
> > > > > User and their Address.
>
> > > > > When a new User object is instantiated (but not yet persisted), I want
> > > > > to be able to get the related address object like this:
>
> > > > > user.address.obj
>
> > > > > But the returned Box is always empty, I guess because nothing has been
> > > > > saved yet.
>
> > > > > I need to somehow initialise the address if it is Empty otherwise
> > > > > return the current Address.
>
> > > > > I thought something like this would work, but it doesn't:
>
> > > > > user.address.obj.openOr(user.address(new Address).address.obj.open_!)
>
> > > > > Anyone know how to do this properly?
>
> > > > --
> > > > Steffen Weissmann
>
> > > > Technische Universitaet Berlin - Math. Department - MA 3-2
>
> > > > Str. des 17. Juni 136
> > > > 10623 Berlin - Germany
>
> > > > Phone: +49 30 314-29278
> > > > Mail: weissm...@math.tu-berlin.de
> > > > Web:www.math.tu-berlin.de/~weissman


--~--~-~--~~~---~--~~
You rece

[Lift] Re: how to wtite scala code in dynamic table

2009-08-12 Thread Timothy Perrett

Pravin,

Checkout my example here: http://is.gd/sfyT - the key point your
looking for is chooseTemplate; you can have two NodeSeq, one with a
"Nothing to display" type message if there is no content, and one with
the content if it exists.

Does that help?

Cheers, Tim

On Aug 12, 7:54 am, pravin  wrote:
> Hi ,
> i going to populate dynamic table contains.
> but i want to do some validation before dispaly
> how can i do this ...
>
> e.g ..
> i have one snippet with one method
>
> abc(){
> ...
>  CellNo :
> { emp.CellNo} ,Name :{emp.Name} , 
>   
>
> /// suppose if there no cell no i dont want to display this record how
> can i add this code in this td
>
> }
>
> Thanks in advance
> -Pravin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: javascript error in embed.js

2009-08-12 Thread David Persons

Thank you very much David, works great now. I accidentally asked the
question in the Lift group instead of the Wave user group. Glad I
did :-)

grtz

On Aug 12, 2:12 am, David Pollak 
wrote:
> Google is not honoring XHTML.
>
> To serve the pages as text/html:
>
> LiftRules.useXhtmlMimeType = false
>
> Thanks,
>
> David
>
>
>
> On Tue, Aug 11, 2009 at 4:45 PM, David Persons  wrote:
>
> > Hello everybody,
>
> > I got stuck trying to embed a Wave on an already existing website.. My
> > guess is there is a conflict with another js file used on the page:
>
> > Error: uncaught exception: [Exception... "Operation is not supported"
> > code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"
> > location: "http://wave-api.appspot.com/public/embed.jsLine: 2"]
>
> > Anyone has seen this error before and/or any tips anyone?
>
> > kind regards,
> > David Persons
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: how do you initialise a MappedLongForeignKey object?

2009-08-12 Thread george

I add the address to the user

user.address(a)

later on the user gets saved

the address is inserted in the address table

but in the user table, the address id is NULL



On Aug 11, 11:36 pm, Naftoli Gugenheim  wrote:
> What do you mean?
>
> -
>
> george wrote:
>
> Ok I am getting somewhere now, thanks!
>
> The address goes into the database fine when I get a reference to it
> like this:
>
> def getAddress : Address =
>         address.obj match {
>                 case Full(a) => a
>                 case _ =>
>                         val a = new Address
>                         address(a)
>                         a
>         }
>
> But the problem now is that the corresponding foreign key on the users
> table is not set...
>
> On Aug 11, 11:13 pm, Naftoli Gugenheim  wrote:
>
>
>
> > Just on the field, like you have it; not on the mapper.
>
> > -
>
> > george wrote:
>
> > I'm not sure exactly how to implement that.
>
> > Like this?
>
> > Address.scala
> > class Address extends LongKeyedMapper[Address] with IdPK with
> > LongMappedForeignMapper[T,Address]
>
> > User.scala
> > class User extends MegaProtoUser[User] {
> > object address extends MappedLongForeignKey(this, Address) with
> > LongMappedForeignMapper[User, Address]
>
> > }
>
> > This was the only docs I could find on the LongMappedForeignMapper:
>
> >http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relat...
>
> > How does it work for a 1 - 1 relationship?
>
> > On Aug 11, 10:36 pm, Naftoli Gugenheim  wrote:
>
> > > Did you try LongMappedForeignMapper? I created it for this exact purpose, 
> > > so if it's not working I want to know.
> > > Thanks.
>
> > > -
>
> > > george wrote:
>
> > > Hi Steffen, thanks for the thought.
>
> > > In your case I think the User object will already be saved in the
> > > database when you add an address to it.
>
> > > I'm trying to make it so that when a new User signs up, they fill in
> > > their address at the same time as the other fields. So there is no
> > > User object in the database to add an address to yet.
>
> > > On Aug 11, 9:57 pm, Steffen Weißmann
>
> > >  wrote:
> > > > I think the problem is the "new Address". You need
> > > > Address.create.save. My code is:
>
> > > >         def addAddress(form: NodeSeq) = {
> > > >             val user = User.currentUser.open_!
> > > >                 val addr = user.address.obj.openOr {
> > > >                         val newAdr = Address.create
> > > >                         newAdr.save
> > > >                         user.address(newAdr).save
> > > >                         println("Creating new Address for user 
> > > > "+user.firstName+" "+user.lastName)
> > > >                         newAdr
> > > >                 }
> > > >                 def doBind(form: NodeSeq): NodeSeq =
> > > >                         {bind("form", form,
> > > >                                 "table" -> 
> > > > addr.toForm(Full(S.?("address.submit")), doBind, addr
> > > > => addr.save)
> > > >                         )}
> > > >                 doBind(form)
> > > >         }
>
> > > > Steffen.
>
> > > > On Tue, Aug 11, 2009 at 10:48 PM, Naftoli 
> > > > Gugenheim wrote:
>
> > > > > Try mixing in LongMappedForeignMapper to address, or calling 
> > > > > address.primeObj(addressObj).
> > > > > What doesn't work the way you tried?
>
> > > > > -
> > > > > george wrote:
>
> > > > > I have extended MegaProtoUser in order to add a related Address object
> > > > > which is a MappedLongForeignKey.
>
> > > > > The idea being simply that there is a 1 to 1 relationship between a
> > > > > User and their Address.
>
> > > > > When a new User object is instantiated (but not yet persisted), I want
> > > > > to be able to get the related address object like this:
>
> > > > > user.address.obj
>
> > > > > But the returned Box is always empty, I guess because nothing has been
> > > > > saved yet.
>
> > > > > I need to somehow initialise the address if it is Empty otherwise
> > > > > return the current Address.
>
> > > > > I thought something like this would work, but it doesn't:
>
> > > > > user.address.obj.openOr(user.address(new Address).address.obj.open_!)
>
> > > > > Anyone know how to do this properly?
>
> > > > --
> > > > Steffen Weissmann
>
> > > > Technische Universitaet Berlin - Math. Department - MA 3-2
>
> > > > Str. des 17. Juni 136
> > > > 10623 Berlin - Germany
>
> > > > Phone: +49 30 314-29278
> > > > Mail: weissm...@math.tu-berlin.de
> > > > Web:www.math.tu-berlin.de/~weissman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/

[Lift] how to wtite scala code in dynamic table

2009-08-12 Thread pravin

Hi ,
i going to populate dynamic table contains.
but i want to do some validation before dispaly
how can i do this ...

e.g ..
i have one snippet with one method

abc(){
...
 CellNo :
{ emp.CellNo} ,Name :{emp.Name} , 
  

/// suppose if there no cell no i dont want to display this record how
can i add this code in this td
}


Thanks in advance
-Pravin

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