[Lift] Re: What is purpose of RequestVar/StatefulSnipplet for forms?

2010-01-28 Thread tommycli
What do you mean these functions are called only on submit? Is that
when the POST goes through and the page is rendered again?

On Jan 27, 1:57 am, Adam Warski a...@warski.org wrote:
 Hello,

  What's the purpose of RequestVars and StatefulSnippet? I thought the
  values were retained anyway through POST. That is, on submit, the
  functions desc = _ and amount = _ were executed and the so the
  state was kept...

  Are those functions only executed after the bind is complete? There
  must be something I'm missing here.

 The functions are called after form submission, and the variable desc and 
 amount will be updated. However those variables will belong to the original 
 method call. So when the page is re-rendered (e.g. because of validation 
 errors), the add method will be called again, and fresh variables will be 
 created. So the values won't be retained. If you want to keep the values 
 between updating and re-rendering, you need something more global, like a 
 RequestVar or a StatefulSnippet.

 --
 Adam Warskihttp://www.warski.orghttp://www.softwaremill.eu

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



[Lift] What is purpose of RequestVar/StatefulSnipplet for forms?

2010-01-26 Thread tommycli
Hi,

I'm reading the lift book about forms, and in reference to this code:

def add (xhtml : NodeSeq) : NodeSeq = {
var desc = 
var amount = 0

def processEntryAdd () { ... }

bind(entry, xhtml,
description - SHtml.text(desc, desc = _),
amount - SHtml.text(amount, amount = _),
submit - SHtml.submit(Add, processEntryAdd))
}

am coming across:

That means that if you want to retain values between submission and
re-rendering of the form, you’ll want to
use RequestVars (Section 3.16) or a StatefulSnippet (Section 3.11.2)
instead .

What's the purpose of RequestVars and StatefulSnippet? I thought the
values were retained anyway through POST. That is, on submit, the
functions desc = _ and amount = _ were executed and the so the
state was kept...

Are those functions only executed after the bind is complete? There
must be something I'm missing here.

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



[Lift] Re: Two new issues for TextileParser

2010-01-22 Thread tommycli
My mistake. The last time I brought a bug up, you told me to file a
bug on github - so I assumed it was general procedure.

On Jan 18, 9:07 pm, David Pollak feeder.of.the.be...@gmail.com
wrote:
 Please don't open tickets unless you discuss them on this list first.



 On Sun, Jan 17, 2010 at 6:45 PM, tommycli tommy...@ucla.edu wrote:
  I created two new issues for TextileParser.

  290. TextileParser molests divs

  291. TextileParser does not support notextile

  Additionally, it'd be nice if TextileParser were implemented in a way
  such that it was extensible. The main issue is that it's just a
  singleton object, which cannot be extended.

  Perhaps instead of:

  object TextileParser

  we could have:

  class TextileParserCls {
   ... real stuff...
  }

  object TextileParser extends TextileParserCls

  People could then extend the class and instantiate their own singleton
  if they wanted to extend the parser.

  Thanks, and sorry if I'm becoming a bug on the Textile.

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

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Surf the harmonics

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



[Lift] Two new issues for TextileParser

2010-01-17 Thread tommycli
I created two new issues for TextileParser.

290. TextileParser molests divs

291. TextileParser does not support notextile

Additionally, it'd be nice if TextileParser were implemented in a way
such that it was extensible. The main issue is that it's just a
singleton object, which cannot be extended.

Perhaps instead of:

object TextileParser

we could have:

class TextileParserCls {
  ... real stuff...
}

object TextileParser extends TextileParserCls

People could then extend the class and instantiate their own singleton
if they wanted to extend the parser.

Thanks, and sorry if I'm becoming a bug on the Textile.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Sending a File back in custom dispatch

2010-01-08 Thread tommycli
Hi,

What's the preferred way of sending back a static file (that lives on
the host filesystem) through lift? I'm using lift's custom dispatch.

I'm currently putting a FileInputStream into StreamingResponse. I'm
not setting a Content-Type in the StreamingResponse constructor, but
Jetty seems to be sending:

Content-Type: application/xhtml+xml; charset=utf-8


This is obviously bad for CSS files or images that I'm serving. Is
there a smarter way to send the contents of files? Preferably one that
automatically sets the correct Content-Type... or leaves it blank for
the browser to ascertain.

Of course, I can always use the Java mime-util library to detect and
set for each file, just wondering if there's a smarter way to do this.
-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] Sending malformed HTML in custom dispatch

2009-12-25 Thread tommycli
I'm using custom dispatch (to handle both XML  media files). Often, I
will want to send a page that contains user-inputted (X)HTML. This
will often be malformed HTML that is nevertheless rendered fine by a
modern browser.

How would I send this through? I tried PlainTextResponse, but it sends
the wrong mime type and shows up as well... plaintext. And
XHtmlResponse requires valid XHTML.

Is there any response that sends a String and claims that it's (x)
html?

--

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




[Lift] Re: Validation errors shown on CRUDify models?

2009-12-21 Thread tommycli
Thanks guys.

On Dec 21, 11:59 am, David Pollak feeder.of.the.be...@gmail.com
wrote:
 On Mon, Dec 21, 2009 at 1:53 AM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote:



  tommycli tommy...@ucla.edu writes:

   Are validation errors shown on CRUDify create/edit pages?

   I have validators set up like this:

     object subdomain extends MappedString(this,64) {
       override def validations = List(valUnique(Subdomain taken.)_,

  valRegex(Pattern.compile(^[A-Za-z0-9-]*$),
                                              Subdomains must only contain
  letters, numbers, and
   hyphens.
                                            )_) ::: super.validations
       override def displayName = Subdomain
       override def dbIndexed_? = true
     }

   And on an invalid entry, the form will just silently fail - that is,
   when submitted, it will just give back the exact same form state - no
   error messages, no changes in the filled-out entries. This confuses me.

  How should the messages be displayed? AFAIK, per field message display
  is not supported atm.

 Yeah... I need to fix that.  http://github.com/dpp/liftweb/issues#issue/254



  You can display all errors (incl field errors) by
  including the

  lift:Msgs showAll=true/

  snippet. Note the showAll attribute which is now needed to show field
  level errors.

  /Jeppe

  --

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

 --
 Lift, the simply functional web frameworkhttp://liftweb.net
 Beginning Scalahttp://www.apress.com/book/view/1430219890
 Follow me:http://twitter.com/dpp
 Surf the harmonics

--

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




[Lift] Validation errors shown on CRUDify models?

2009-12-20 Thread tommycli
Are validation errors shown on CRUDify create/edit pages?

I have validators set up like this:

  object subdomain extends MappedString(this,64) {
override def validations = List(valUnique(Subdomain taken.)_,

valRegex(Pattern.compile(^[A-Za-z0-9-]*$),
 Subdomains must only contain 
letters, numbers, and
hyphens.
   )_) ::: super.validations
override def displayName = Subdomain
override def dbIndexed_? = true
  }

And on an invalid entry, the form will just silently fail - that is,
when submitted, it will just give back the exact same form state - no
error messages, no changes in the filled-out entries. This confuses me.

--

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




[Lift] Re: Feature Request: Header offset in lift-textile

2009-12-13 Thread tommycli
A use case is inline page previews for entries - whereas on the full
page there should be full headers, on the preview, h1 ought to
become h3 etc.

On Dec 13, 2:20 am, Timothy Perrett timo...@getintheloop.eu wrote:
 Why on earth would you want that? Wouldn't that fundamentally break the 
 standard textile notation?!

 If you want a h2 then just use h2.

 Cheers, Tim

 On 12 Dec 2009, at 20:39, tommycli wrote:

  It'd be nice to have a header-offset feature in lift-textile.

  That is, if header_offset=1 gets passed in as an argument,

  h1. = h2
  h2. = h3

  etc.

  --

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

--

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




[Lift] lift-textile misprocesses a list without a preceding empty line

2009-12-13 Thread tommycli
The below example fails to render a list in lift-textile, but works in
the reference implementation (http://textism.com/tools/textile/
index.php).

Lists work in lift-textile only if there is an empty line preceding
it, but this is a deviation from the reference implementation.

Example follows:
---

For example, these are list items:
* Item 1
* Item 2

---

incorrectly yields:

---
pFor example, these are list items:br/br* Item 1br/br* Item
2/p
---

--

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




[Lift] Feature Request: Header offset in lift-textile

2009-12-12 Thread tommycli
It'd be nice to have a header-offset feature in lift-textile.

That is, if header_offset=1 gets passed in as an argument,

h1. = h2
h2. = h3

etc.

--

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




[Lift] NPE when deploying WAR to Jetty

2009-12-05 Thread tommycli
Hi,

I have a project that works fine when I do: mvn jetty:run, however,
fails with a 500 error when I mvn:package and upload the jar to my
Jetty server. Here is the error I get:

20:04:52.801 ERROR! [SocketListener0-9]
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
593) 11 /:
java.lang.NullPointerException
   at net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply
(HTTPProvider.scala:55)
   at net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply
(HTTPProvider.scala:55)
   at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
   at net.liftweb.http.URLRewriter$.doWith(Req.scala:536)
   at net.liftweb.http.provider.HTTPProvider$class.service
(HTTPProvider.scala:54)
   at net.liftweb.http.LiftFilter.service(LiftServlet.scala:523)
   at net.liftweb.http.provider.servlet.ServletFilterProvider
$class.protected$service(ServletFilterProvider.scala:43)
   at net.liftweb.http.LiftFilter.protected$service(LiftServlet.scala:
523)
[...]

Here is my web.xml, it looks okay to me:

?xml version=1.0 encoding=ISO-8859-1?

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;

web-app
filter
  filter-nameLiftFilter/filter-name
  display-nameLift Filter/display-name
  descriptionThe Filter that intercepts lift calls/description
  filter-classnet.liftweb.http.LiftFilter/filter-class
/filter


filter-mapping
  filter-nameLiftFilter/filter-name
  url-pattern/*/url-pattern
/filter-mapping

/web-app

I realize this isn't a terribly elucidating complaint... I read an
earlier post with the same error, but the solution was non-applicable,
as I am using mvn to both jetty:run locally (it works) and package (it
doesn't work).

--

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




[Lift] Re: NPE when deploying WAR to Jetty

2009-12-05 Thread tommycli
Thanks! Your posts pointed me in the right direction.

Basically: this was a quirk of the distribution I was installing onto:
Ubuntu 8.10.

On 8.10, the two installed java distributions are openjdk and java-gcj-
compat.

Unfortunately, jetty does not know about openjdk, so defaults to java-
gcj, and yields this error:

ERROR - Failed to Boot
java.lang.InternalError: One of the management beans is not compliant.
   at java.lang.management.ManagementFactory.getPlatformMBeanServer
(libgcj.so.90)
   at org.apache.derby.impl.services.jmx.JMXManagementService$3.run
(Unknown Source)
   at org.apache.derby.impl.services.jmx.JMXManagementService$3.run
(Unknown Source)
[...]

Right, so editing /etc/default/jetty and setting JAVA_HOME=/usr/lib/
jvm/default-java made Jetty use OpenJDK instead, and now everything is
just chipper. - for now.

Thanks for your help again.

On Dec 5, 1:08 pm, Marius marius.dan...@gmail.com wrote:
 Does your boot throw an exception ? If you can;t see anything in logs
 can you wrap your whole boot in a try catch just to see if an
 exception is thrown?

 It looks to me that internal LiftServlet is not created and this can
 happen if something is thrown from boot.

 Br's
 Marius

 On Dec 5, 11:05 pm, Marius marius.dan...@gmail.com wrote:

  What Lift version are you using? Can you attach a zip with a
  minimalistic example of your app when this occurs?

  Br's,
  Marius

  On Dec 5, 10:08 pm, tommycli tommy...@ucla.edu wrote:

   Hi,

   I have a project that works fine when I do: mvn jetty:run, however,
   fails with a 500 error when I mvn:package and upload the jar to my
   Jetty server. Here is the error I get:

   20:04:52.801 ERROR! [SocketListener0-9]
   org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
   593) 11 /:
   java.lang.NullPointerException
      at net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply
   (HTTPProvider.scala:55)
      at net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply
   (HTTPProvider.scala:55)
      at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
      at net.liftweb.http.URLRewriter$.doWith(Req.scala:536)
      at net.liftweb.http.provider.HTTPProvider$class.service
   (HTTPProvider.scala:54)
      at net.liftweb.http.LiftFilter.service(LiftServlet.scala:523)
      at net.liftweb.http.provider.servlet.ServletFilterProvider
   $class.protected$service(ServletFilterProvider.scala:43)
      at net.liftweb.http.LiftFilter.protected$service(LiftServlet.scala:
   523)
   [...]

   Here is my web.xml, it looks okay to me:

   ?xml version=1.0 encoding=ISO-8859-1?

   !DOCTYPE web-app
   PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
   http://java.sun.com/dtd/web-app_2_3.dtd;

   web-app
   filter
     filter-nameLiftFilter/filter-name
     display-nameLift Filter/display-name
     descriptionThe Filter that intercepts lift calls/description
     filter-classnet.liftweb.http.LiftFilter/filter-class
   /filter

   filter-mapping
     filter-nameLiftFilter/filter-name
     url-pattern/*/url-pattern
   /filter-mapping

   /web-app

   I realize this isn't a terribly elucidating complaint... I read an
   earlier post with the same error, but the solution was non-applicable,
   as I am using mvn to both jetty:run locally (it works) and package (it
   doesn't work).

--

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




[Lift] Re: Feature Request: deleteMenuLocParams in CRUDify

2009-11-24 Thread tommycli
Amazing - great. For future reference - what's the preferred method
for asking for code/feature to be integrated?

On Nov 23, 9:46 pm, Ross Mellgren dri...@gmail.com wrote:
 Added an issue for you:http://github.com/dpp/liftweb/issues#issue/205
 and it's on review board:http://reviewboard.liftweb.net/r/121/

 So it will (probably) be in 1.1-SNAPSHOT in a day or two, assuming the change 
 isn't unacceptable for whatever reason.

 -Ross

 On Nov 23, 2009, at 11:50 PM, tommycli wrote:

  Add deleteMenuLocParams to CRUDify.

  Patch below. (I tried github, but you guys don't pull apparently).

  pre
  diff --git a/lift-persistence/lift-mapper/src/main/scala/net/liftweb/
  mapper/CRUDify.scala b/lift-persistence/lift-mapper/src/main/scala/net/
  liftweb/mapper/CR
  index 21e5a3b..5aae123 100644
  --- a/lift-persistence/lift-mapper/src/main/scala/net/liftweb/mapper/
  CRUDify.scala
  +++ b/lift-persistence/lift-mapper/src/main/scala/net/liftweb/mapper/
  CRUDify.scala
  @@ -265,7 +265,7 @@ trait CRUDify[KeyType, CrudType : KeyedMapper
  [KeyType, CrudType]] {

            def defaultValue = Empty

  -          def params = Nil
  +          def params = deleteMenuLocParams

            /**
             * What's the text of the link?
  @@ -297,6 +297,11 @@ trait CRUDify[KeyType, CrudType : KeyedMapper
  [KeyType, CrudType]] {
          }))
    }

  +  /**
  +   * Override to include new Params for the show all menu
  +   */
  +  def deleteMenuLocParams: List[Loc.AnyLocParam] = Nil
  +
    def deleteMenuName = S.??(Delete)+ +displayName

    def deleteTemplate(): NodeSeq = pageWrapper(_deleteTemplate)
  /pre

  --

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

--

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




[Lift] Overriding superclass member objects (specifically mapped fields)

2009-10-04 Thread tommycli

In reference to this problem:

http://www.nabble.com/-scala--Overriding-superclass-object-member...-td15344451.html

This use case in specific:

trait Bar {
  self: Mapper =

  object barField extends StringField
}

class Foo extends Mapper with Bar {
  override barField {
override def dbTableName = fruit_bat
  }
}

Did this problem ever get solved? Is there a way to override the
defined fields of a superclass?

--~--~-~--~~~---~--~~
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] Using plain usernames for authentication

2009-10-01 Thread tommycli

Looking through the book and source for MegaProtoUser, it looks like
the email address is used as the primary identifier for users in the
built-in user system.

What if you want to use plain usernames instead of emails? What do
other people do - do they write their own user system from scratch?

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