[Lift] Money and Mapper

2009-09-16 Thread José María

Hi,

I need to save some prices of products, while working in other
languages I use some Decimal type so I don't have overflows and
problems with IEEE floating point numbers. I see that Mapper has types
for everything, from gender to postal codes... what about BigDecimal
or Money?

Cheers.
--~--~-~--~~~---~--~~
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: Nested binding

2009-09-14 Thread José María

That's what I need Heiko!!

But I've another problem, the following code:

def estante1 (xhtml : NodeSeq ) : NodeSeq =  this.estante(xhtml,
Peluches, List(180L,34L,55L) )

def estante (xhtml: NodeSeq, nombre: String, listaProductos : List
[Long]) : NodeSeq = {
bind(estante, xhtml,
 nombre -- nombre,
 productos -- listaProductos.flatMap( id =
  Producto.find(id) match {
  case Full(producto) = bind(p,
chooseTemplate(producto,datos,xhtml),
  nombre --
producto.nombre)

  case _ = NodeSeq.Empty
  }))
  }

Applied to:

lift:estantes.estante1
div class=Estante
h3estante:nombre//h3
ul
estante:productos
producto:datos
p:nombre/
/producto:datos
/estante:productos
/ul
/div
/lift:estantes.estante1

Generates this xhtml:


div class=Estante
h3Peluches/h3
ul
   List(
, Peluche de la E. Coli (Escherichi Coli),
,
, Peluche del Resfriado común (Rhinovirus),
,
, Peluche de la Sífilis (Treponema pallidum),
   )
/ul
/div

Looks like a serialization of the NodeSeq, as if it doesn't concat the
nodes.

Cheers




On Sep 14, 12:48 pm, Heiko Seeberger heiko.seeber...@googlemail.com
wrote:
 Jose,
 please take it from 
 here:http://wiki.github.com/dpp/liftweb/how-to-binding-view-content-to-code

 Cheers,

 Heiko

 2009/9/14 José María josemariar...@gmail.com





  Hi,

  I want to render the content of some tables one after another:

  table 1
   data
  table 2
   data
  table 3
   data

  I want to separate the XHTML from the code, so I'm trying to use
  binding. My problem is that each table is rendered with the same XHTML
  template, as every row.

  If I use bind to bind the tables:

  lift:mysnippet.tables
  
  /lift:mysnippet.tables

  What can I do to bind the rows inside this snippet so I can render
  them? This is what I tried/want/expect:

  lift:mysnippet.tables
   table:name/
  table:rows?
    row:name??
  /table:rows ?
  /lift:mysnippet.tables

  Best regards.

 --
 Heiko Seeberger

 My job: weiglewilczek.com
 My blog: heikoseeberger.name
 Follow me: twitter.com/hseeberger
 OSGi on Scala: scalamodules.org
 Lift, the simply functional web framework: liftweb.net
--~--~-~--~~~---~--~~
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] Box and bind

2009-09-08 Thread José María

Hi.

Boxes are giving me a hard time.

Say you have a model of a Product.

If I've a snippet that retrieves a Product from the DB:

val product : Box[Product] = Product.find(2)

And now I want to bind product with bind(),  product is a Box and it
can be empty, how can I bind something that doesn't exists? You have
to return a NodeSeq in a snippet. What should my code must do?

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



[Lift] Re: Box and bind

2009-09-08 Thread José María

That's my code:

val product = Product.find(id)


producto.map(product =
  bind(product, xhtml,
   url_enlace -- /product/ + product.id.toString ,
  )
   ).openOr(NodeSeq.Empty)
}

and I get this error:

[INFO] use java command with args in file forced : false
/usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/helloworld/
snippet/Portada.scala:55: error: overloaded method value bind with
alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
=
scala.xml.MetaData],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
scala.xml.NodeSeq and
(String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
scala.xml.NodeSeq cannot be applied to
(java.lang.String,scala.xml.NodeSeq,java.lang.String,java.lang.String,net.liftweb.util.Helpers.BindParam,net.liftweb.util.Helpers.BindParam)
  bind(producto, xhtml,
  ^
one error found



What's wrong?



On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
 Well it depends on precisely what you want. If you want your snippet  
 to become empty if the product is not there, try:

 productBox.map(product = {
    bind(product, ns, ...)

 }).openOr(NodeSeq.Empty)

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

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

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

 -Ross

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



  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread José María

It worked when I put the () around the bind param

and the question is ... why?




On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind  
 argument related thing, probably because you have a precedence  
 problem... try:

 producto.map(product =
    bind(product, xhtml,
         url_enlace - (/product/ + product.id.toString),
        )
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over  
 producto. I presume either producto is coming from somewhere else (and  
 val product is being shadowed inside the map) or that you pasted not  
 exactly what you're compiling.

 -Ross

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



  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

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

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

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

  -Ross

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

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box  
  and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread José María

I adapted the code but not the error, Producto is Product in Spanish.



On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
 So that doesn't seem to be a box-related thing so much as a bind  
 argument related thing, probably because you have a precedence  
 problem... try:

 producto.map(product =
    bind(product, xhtml,
         url_enlace - (/product/ + product.id.toString),
        )
 ).openOr(NodeSeq.Empty)

 Also, FYI, you have val product = Product.find(id), but then map over  
 producto. I presume either producto is coming from somewhere else (and  
 val product is being shadowed inside the map) or that you pasted not  
 exactly what you're compiling.

 -Ross

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



  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box[(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

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

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

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

  -Ross

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

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box  
  and it
  can be empty, how can I bind something that doesn't exists? You have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Re: Box and bind

2009-09-08 Thread José María

OMG

So, as - begins with - then it has the precedence of the operator
-



On Sep 8, 7:52 pm, Naftoli Gugenheim naftoli...@gmail.com wrote:
 Precedence is determined by the first character of an operator.

 -

 Ross Mellgrendri...@gmail.com wrote:

 Because the compiler interpret your expression as you expect. Instead  
 of:

 url_enlace - (/product/ + product.id.toString)

 which is what you wanted, it got:

 (url_enlace - /product/) + product.id.toString)

 which it can do because it can take an arbitrary object:

 (url_enlace - /product/): ABindParam
 or (the other implicit -)
 (url_enlace - /product/): Tuple2[String, String]

 and convert them to strings. Of course, once it converts to string, it  
 won't fit in bind()'s argument list and so it gave you the could not  
 find overload error.

 Honestly I'm a bit fuzzy on Scala's operator precedence behavior, I  
 think if I recall you can't set precedence, it comes pre-set on all  
 the standard operators like + / -, etc.

 -Ross

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



  It worked when I put the () around the bind param

  and the question is ... why?

  On Sep 8, 7:35 pm, Ross Mellgren dri...@gmail.com wrote:
  So that doesn't seem to be a box-related thing so much as a bind
  argument related thing, probably because you have a precedence
  problem... try:

  producto.map(product =
     bind(product, xhtml,
          url_enlace - (/product/ + product.id.toString),
         )
  ).openOr(NodeSeq.Empty)

  Also, FYI, you have val product = Product.find(id), but then map over
  producto. I presume either producto is coming from somewhere else  
  (and
  val product is being shadowed inside the map) or that you pasted not
  exactly what you're compiling.

  -Ross

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

  That's my code:

     val product = Product.find(id)

     producto.map(product =
       bind(product, xhtml,
            url_enlace -- /product/ + product.id.toString ,
           )
                ).openOr(NodeSeq.Empty)
     }

  and I get this error:

  [INFO] use java command with args in file forced : false
  /usr/home/josemaria/src/lift/helloworld/src/main/scala/demo/
  helloworld/
  snippet/Portada.scala:55: error: overloaded method value bind with
  alternatives (String,net.liftweb.util.Box[(scala.xml.NodeSeq) =
  scala.xml.NodeSeq],net.liftweb.util.Box
  [(scala.xml.PrefixedAttribute)
  =
  scala.xml.MetaData
  ],scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq and
  (String,scala.xml.NodeSeq,net.liftweb.util.Helpers.BindParam*)
  scala.xml.NodeSeq cannot be applied to
  (java.lang.String
  ,scala.xml.NodeSeq
  ,java.lang.String
  ,java.lang.String
  ,net.liftweb.util.Helpers.BindParam
  ,net.liftweb.util.Helpers.BindParam)
       bind(producto, xhtml,
       ^
  one error found

  What's wrong?

  On Sep 8, 7:13 pm, Ross Mellgren dri...@gmail.com wrote:
  Well it depends on precisely what you want. If you want your  
  snippet
  to become empty if the product is not there, try:

  productBox.map(product = {
     bind(product, ns, ...)

  }).openOr(NodeSeq.Empty)

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

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

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

  -Ross

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

  Hi.

  Boxes are giving me a hard time.

  Say you have a model of a Product.

  If I've a snippet that retrieves a Product from the DB:

  val product : Box[Product] = Product.find(2)

  And now I want to bind product with bind(),  product is a Box
  and it
  can be empty, how can I bind something that doesn't exists? You  
  have
  to return a NodeSeq in a snippet. What should my code must do?

  Best regards.


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



[Lift] Logging sql queries generated by Mapper

2009-09-04 Thread José María

Hi,

I'm new to JAVA as platform, I want to see the sql queries generated
by Mapper queries. I've been reading the LiftWeb book but logging
appears only as an appendix at the end and it doesn't tell you
how to configure the Log system.

Should I use Log4J config? Where should I put the configuration files?

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: Logging sql queries generated by Mapper

2009-09-04 Thread José María

I found it after writing the original mail. I always search in
liftweb, I didn't know
there was a wiki in github.

Where can I find the api doc for 1.1-SNAPSHOT?

Cheers.

On Sep 4, 3:00 pm, marius d. marius.dan...@gmail.com wrote:
 Please see this thread:

 http://groups.google.com/group/liftweb/browse_thread/thread/7d5daf78a...

 Br's,
 Marius

 On Sep 4, 5:03 pm, José María josemariar...@gmail.com wrote:

  Hi,

  I'm new to JAVA as platform, I want to see the sql queries generated
  by Mapper queries. I've been reading the LiftWeb book but logging
  appears only as an appendix at the end and it doesn't tell you
  how to configure the Log system.

  Should I use Log4J config? Where should I put the configuration files?

  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] Subquerys Mapper?

2009-09-04 Thread José María

Hi,

Is it possible to do subqueries with Mapper?

If I have something like:

Product.findAll(...)

How can I use it as subquery for another query? What I'm trying to do
is:

Select *  from Table order by random() limit 6

But this doesn't works in modern SQL implementations (Oracle, PG 8.4)
so what I need to do is:

Select * from (select * from Table) order by random limit 6

Cheers.
--~--~-~--~~~---~--~~
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: Snippet inside of a Snippet

2009-09-03 Thread José María

Ok, I've run  mvn clean jetty:run and it works now.

Thanks.

On 3 sep, 03:16, David Pollak feeder.of.the.be...@gmail.com wrote:
 On Wed, Sep 2, 2009 at 3:55 PM, José María josemariar...@gmail.com wrote:

  SOLVED

  lazy val id = S.param(id).flatMap(Helpers.asLong) openOr -1L

  I changed it to:

  lazy val pagina = S.param(numero).openOr(1).toInt

 This is a bad pattern.  It will lead to an exception is the parameter
 numero cannot be parsed as an Int.  Exceptions should only be encouraged
 in places where there is an unexpected situation (e.g., your database goes
 down), not in a situation where you have input that cannot logically be
 turned into a number.

 The reason, as Tim pointed out, that you got the exception was the class
 changed in a way that JavaRebel couldn't handle.  Just stop JavaRebel, do a
 mvn clean install and restart JavaRebel.





  Yes, I'm using JavaRebel

  On 2 sep, 20:58, Timothy Perrett timo...@getintheloop.eu wrote:
   Are you using JavaRebel? Try doing a clean before jetty:run

   Cheers, Tim

   On 2 Sep 2009, at 20:57, José María wrote:

On 2 sep, 17:27, David Pollak feeder.of.the.be...@gmail.com wrote:

Try:

lazy val id = S.param(id).flatMap(Helpers.asLong) openOr -1L

I get:

Exception occured while processing /marca/162

Message: java.lang.IncompatibleClassChangeError
   net.liftweb.util.Full.flatMap(Box.scala:332)
   demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.id
  (MarcaInfo.scala:23)
   demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.id(generated)
   demo.helloworld.snippet.MarcaInfo.id(Marca.scala)
   demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.marca(MarcaInfo.scala:
29)
   demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.marca(generated)
   demo.helloworld.snippet.MarcaInfo.marca(Marca.scala)
   demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.datos(MarcaInfo.scala:
94)
   demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.datos(generated)
   demo.helloworld.snippet.MarcaInfo.datos(Marca.scala)

 --
 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] Snippet inside of a Snippet

2009-09-02 Thread José María

Hi.

I've a snippet in one of  my HTML files and inside of it I put another
snippet like this:

lift:myClass1.func
lift:myClass2.func2
Hi
/lift:myClass2.func
/lift:myClass1.func

If I do that I get the error:

Error processing snippet myClass2:func2.  Reason: Exception During
Snippet Instantiation
  XML causing this error:

lift:myClass2.func2
   Hi
/lift:myClass2.func2

Following doc I put eager_eval=true in lift:myClass1.func but I
got the same error.

What am I doing wrong?

Best regards.

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



[Lift] Re: how does Lift support pagination in Postgresql?

2009-09-02 Thread José María

If you are speaking about offset 10 limit 15 you have:

  Product.findAll(By(Product.brand, 33),
 StartAt(10),
 MaxRows(15))

Best regards.

On 2 sep, 14:18, surfman chinasmile...@gmail.com wrote:
 I am wondering how Lift supports pagination in Postgresql? where I may
 find details for Postgresql support? 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: Snippet inside of a Snippet

2009-09-02 Thread José María

I think that I don't understand the flow, maybe the error appears
because PaginaMarca can't
instantiate some value (for example val id).

Well myClass2 is an invented name, I'll post the real code, but not
all (yes I suppose that the
problem will be in the no-pasted zone :p ):

class PaginaMarca extends BindHelpers {

  val id = S.param(id).openOr(-1).toLong


  def pagina : Int =   try {
S.param(numero).openOr(no es un numero).toInt
  } catch {
case nfe : NumberFormatException  = 1
  }



/*
   * Estas son las marcas que queremos mostrar en los banners
   */
  def listaMarcas (xhtml : NodeSeq) : NodeSeq = {
var marcas = (162, giantmicrobes) ::
  (178, thumbthing) ::
  (177, invicta) ::
  (181, leatherman) ::
  (149, hotworks) ::
  (179, surefire) ::
  (146, techtionary) ::
  (268, no_starch_press) ::
  Nil

marcas.flatMap(  marca = bind(marca,xhtml,
   html -- li
   a href={/marca/+ marca._1} title=
{Buscar productos de  + marca._2}
   img src={http://
static.simpleoption.com/imagenes/marcas/nombres/+marca._2+.png} alt=
{Logo de +marca._2}/
   /a
   /li))

  }

}









On 2 sep, 16:36, David Pollak feeder.of.the.be...@gmail.com wrote:
 Please post the source for myClass2



 On Wed, Sep 2, 2009 at 9:16 AM, José María josemariar...@gmail.com wrote:

  Hi.

  I've a snippet in one of  my HTML files and inside of it I put another
  snippet like this:

  lift:myClass1.func
  lift:myClass2.func2
  Hi
  /lift:myClass2.func
  /lift:myClass1.func

  If I do that I get the error:

  Error processing snippet myClass2:func2.  Reason: Exception During
  Snippet Instantiation
           XML causing this error:

             lift:myClass2.func2
            Hi
             /lift:myClass2.func2

  Following doc I put eager_eval=true in lift:myClass1.func but I
  got the same error.

  What am I doing wrong?

  Best regards.

 --
 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: Great advice for startups

2009-09-02 Thread José María

I'd read it too, it's wonderful, I recomended asmartbear to a friend
(MBA) and now
asmartbear is his new god :)

On 1 sep, 15:38, David Pollak feeder.of.the.be...@gmail.com wrote:
 Folks,

 I read this blog post this 
 morning:http://blog.asmartbear.com/blog/youre-a-little-company-now-act-like-o...

 While this list is mainly for discussing Lift, I thought I'd share the
 link.  It's great advice, IMHO, for small startups.

 Enjoy.

 Thanks,

 David

 --
 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: Snippet inside of a Snippet

2009-09-02 Thread José María

SOLVED

I'd a value that was computed using the val id, I've turned it to
def and all works
now. As id can't be retrieved from URL parameters this val generated
an exception.

I think that the error message is a bit misleading :-/

Thanks!

On 2 sep, 16:47, José María josemariar...@gmail.com wrote:
 I think that I don't understand the flow, maybe the error appears
 because PaginaMarca can't
 instantiate some value (for example val id).

 Well myClass2 is an invented name, I'll post the real code, but not
 all (yes I suppose that the
 problem will be in the no-pasted zone :p ):

 class PaginaMarca extends BindHelpers {

   val id = S.param(id).openOr(-1).toLong

   def pagina : Int =   try {
                     S.param(numero).openOr(no es un numero).toInt
                   } catch {
                     case nfe : NumberFormatException  = 1
                   }

 /*
    * Estas son las marcas que queremos mostrar en los banners
    */
   def listaMarcas (xhtml : NodeSeq) : NodeSeq = {
     var marcas = (162, giantmicrobes) ::
                   (178, thumbthing) ::
                   (177, invicta) ::
                   (181, leatherman) ::
                   (149, hotworks) ::
                   (179, surefire) ::
                   (146, techtionary) ::
                   (268, no_starch_press) ::
                   Nil

     marcas.flatMap(  marca = bind(marca,xhtml,
                                    html -- li
                                    a href={/marca/+ marca._1} title=
 {Buscar productos de  + marca._2}
                                    img src={http://
 static.simpleoption.com/imagenes/marcas/nombres/+marca._2+.png} alt=
 {Logo de +marca._2}/
                                    /a
                                    /li))

   }

 }

 On 2 sep, 16:36, David Pollak feeder.of.the.be...@gmail.com wrote:

  Please post the source for myClass2

  On Wed, Sep 2, 2009 at 9:16 AM, José María josemariar...@gmail.com wrote:

   Hi.

   I've a snippet in one of  my HTML files and inside of it I put another
   snippet like this:

   lift:myClass1.func
   lift:myClass2.func2
   Hi
   /lift:myClass2.func
   /lift:myClass1.func

   If I do that I get the error:

   Error processing snippet myClass2:func2.  Reason: Exception During
   Snippet Instantiation
            XML causing this error:

              lift:myClass2.func2
             Hi
              /lift:myClass2.func2

   Following doc I put eager_eval=true in lift:myClass1.func but I
   got the same error.

   What am I doing wrong?

   Best regards.

  --
  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] How do you organize/use snippets?

2009-09-02 Thread José María

Hi.

I'd a hard time trying to solve a bug in a snippet. The bug appeared
when
I moved a method from a snippet to other so the code will be more
organized.

At first I tried to assign snippets to pages, so page Product.html
will have a
ProductPage snippet. In this snippet I'd values based in Product.html
parameters.

Then, as Lift implements a View-First design I supposed that I needed
to collect
snippets methods about something (product information for example) and
put them
in a  ProductInfo snippet, but I found a bug: sometimes I put
ProductInfo methods
in pages that didn't provide the parameters that I get as val's.

So my question is, how do you use/organize snippets? Do you get page
parameters
inside the def's (so they don't cause problems in some pages)? Do you
follow a
strict ViewFirst design?

Cheers.

--~--~-~--~~~---~--~~
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: Snippet inside of a Snippet

2009-09-02 Thread José María



On 2 sep, 17:27, David Pollak feeder.of.the.be...@gmail.com wrote:

 Try:

 lazy val id = S.param(id).flatMap(Helpers.asLong) openOr -1L

I get:

Exception occured while processing /marca/162

Message: java.lang.IncompatibleClassChangeError
net.liftweb.util.Full.flatMap(Box.scala:332)
demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.id(MarcaInfo.scala:23)
demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.id(generated)
demo.helloworld.snippet.MarcaInfo.id(Marca.scala)
demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.marca(MarcaInfo.scala:
29)
demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.marca(generated)
demo.helloworld.snippet.MarcaInfo.marca(Marca.scala)
demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.datos(MarcaInfo.scala:
94)
demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.datos(generated)
demo.helloworld.snippet.MarcaInfo.datos(Marca.scala)

--~--~-~--~~~---~--~~
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: Snippet inside of a Snippet

2009-09-02 Thread José María

SOLVED

lazy val id = S.param(id).flatMap(Helpers.asLong) openOr -1L

I changed it to:

lazy val pagina = S.param(numero).openOr(1).toInt

Yes, I'm using JavaRebel


On 2 sep, 20:58, Timothy Perrett timo...@getintheloop.eu wrote:
 Are you using JavaRebel? Try doing a clean before jetty:run

 Cheers, Tim

 On 2 Sep 2009, at 20:57, José María wrote:



  On 2 sep, 17:27, David Pollak feeder.of.the.be...@gmail.com wrote:

  Try:

  lazy val id = S.param(id).flatMap(Helpers.asLong) openOr -1L

  I get:

  Exception occured while processing /marca/162

  Message: java.lang.IncompatibleClassChangeError
     net.liftweb.util.Full.flatMap(Box.scala:332)
     demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.id(MarcaInfo.scala:23)
     demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.id(generated)
     demo.helloworld.snippet.MarcaInfo.id(Marca.scala)
     demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.marca(MarcaInfo.scala:
  29)
     demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.marca(generated)
     demo.helloworld.snippet.MarcaInfo.marca(Marca.scala)
     demo.helloworld.snippet.MarcaInfo$$M$1be0ea1b.datos(MarcaInfo.scala:
  94)
     demo.helloworld.snippet.MarcaInfo$$A$1be0ea1b.datos(generated)
     demo.helloworld.snippet.MarcaInfo.datos(Marca.scala)
--~--~-~--~~~---~--~~
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] URL Rewrite and complex paths

2009-07-27 Thread José María

Hi.

I have the following problem (I'm porting a site from Python):

I've an url path that follows the patern  /something/int/text or
the pattern /something/int/int/text.

The type of the diferent parts of the url is important, in other
platforms (Python/Ruby) it's possible to use regexp to match the
urls... how is this done in Lift?

This route /company/1/2 is valid and I need to extracts 2 parameters
(id and page).
This route /company/1/hi is valid and I need to extract just 1
parameter (id).

By now my code is:

  case RewriteRequest(ParsePath(company :: id :: page :: text ::
Nil, , true, _), GetRequest, _)
= RewriteResponse(company :: Nil, Map(id - id, page -
page))

  case RewriteRequest(ParsePath(company :: id :: text :: Nil,
, true, _), GetRequest, _)
= RewriteResponse(company :: Nil, Map(id - id))

  case RewriteRequest(ParsePath(company :: id :: Nil, , true,
false), GetRequest, _)
= RewriteResponse(company :: Nil, Map(id - id))


Cheers.

--~--~-~--~~~---~--~~
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: Template tags and properties

2009-07-22 Thread José María

Doesn't this put view code (XML/Xhtml) in controller code? I've read
many times
in Lift doc about not puting logic in view but the reverse can be
even
worst, doing impossible to have a separate design. You can't broke
logic but
design.



On Jul 21, 10:19 am, Timothy Perrett timo...@getintheloop.eu wrote:
 José,

 You'll need to do this from yoursnippetcode - we dont have any view
 logic in templates at all as that breaks lift view first model.

 For example:

 class YouSnippet {
   def example: NodeSeq = aHi/a % href - /mypath/ +
 someDynamicVar

 }

 In your template:

 lift:your_snippet.example /

 Does that make sense?

 Cheers, Tim

 On Jul 21, 10:11 am, José María josemariar...@gmail.com wrote:

  Hi,

  I suppose that this is something simple, how can I put a value inside
  a property in a template?

  Something like:

  a href=/mypath/myobject:id/myobject:idhi/a

  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: Template tags and properties

2009-07-22 Thread José María

That's fine, I just want to generate paths in snippet code.

On Jul 21, 10:20 am, marius d. marius.dan...@gmail.com wrote:
 Something like:

 a lift:snippet=Path.buildhi/a

 where path is thesnippetclass and build is the method name. But what
 is your use case?

 Br's,
 Marius

 On Jul 21, 12:11 pm, José María josemariar...@gmail.com wrote:

  Hi,

  I suppose that this is something simple, how can I put a value inside
  a property in a template?

  Something like:

  a href=/mypath/myobject:id/myobject:idhi/a

  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] Acceding object fields in template

2009-07-22 Thread José María

Hi,

Is it possible to access to the field of an object binded to a name in
a template?

bind(data , xhtml, product -- product)

And then in the template:

   h1 id=Titledata:product.name //h1

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: Template tags and properties

2009-07-22 Thread José María

Solved:

class MyObject {

  def url_image = new UnprefixedAttribute(src, http://localhost/
imgs/ + this.product.id+.jpg, null)
}

In the view (as marius said):


img lift:snippet=MyObject:url_image/

Cheers.




On Jul 21, 9:11 am, José María josemariar...@gmail.com wrote:
 Hi,

 I suppose that this is something simple, how can I put a value inside
 a property in a template?

 Something like:

 a href=/mypath/myobject:id/myobject:idhi/a

 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] Template tags and properties

2009-07-21 Thread José María

Hi,

I suppose that this is something simple, how can I put a value inside
a property in a template?

Something like:

a href=/mypath/myobject:id/myobject:idhi/a

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