[Lift] Snippets and Requests

2009-06-06 Thread Lance Walton

Hi.

>From my various readings, I believed that a single instance of a
snippet will be used for a particular request. I am trying to make use
of this in order to implement a search feature in my app. So I have a
template that looks like this:


  Search
  
Name:   
  

  Results
  

  


And my snippet looks like this:

class SearchSnippet {
  var results : List[Result] = List()

  def nameSearch(xhtml : NodeSeq) : NodeSeq = {
var name = ""

def process() {
  results = ... some stuff to get the results ...
}

bind("search", xhtml,
 "name" -> SHtml.text(name, name = _),
 "submit" -> SHtml.submit("Search", process))
  }

  def searchResults(xhtml : NodeSeq) : NodeSeq =
results.flatMap(f => bindResult(f)(chooseTemplate("results",
"list", xhtml)))

  def bindResult(result : Result)(xhtml : NodeSeq) =
bind("result", xhtml,
  "name" -> result.name)
}

What I expected is that when the form is submitted, an instance of
SearchSnippet will be created and 'results' will be populated. Then,
when the results sectionof the template is processed, the
'searchResults' method can bind the results. However, I never see any
results, and a bit of debugging suggests that different instances are
in play. Is this as expected?

I don't think I want a StatefulSnippet because that seems to have
session 'scope'.

What to do?

Regards,

Lance

--~--~-~--~~~---~--~~
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 to serve html fragments

2009-06-06 Thread fatu

Thanks a lot for the info David, then I'll consider reverting to 2.7.4
until Lift integrates the latest Scala Actors lib (and fixes).

Fabio

On 6 Giu, 15:58, David Pollak  wrote:
> Lift is 2.7.4.  We have not upgraded to 2.7.5 as the delta is actor fixes in
> response to lift-related tickets that we solved with our own actor impl.
> I'm talking to Philipp Haller today at the Lift Off about how to proceed.
>
> On Jun 6, 2009 6:49 AM, "fatu"  wrote:
>
> 2.7.5 right now (and a fresh maven repo too) but I think (not sure
> though) I had it with 2.7.4 as well. Seems to expect a refSet field in
> ActorGC which i couldn't find in 2.7.5 sources.
>
> Fabio
>
> On 5 Giu, 18:10, David Pollak  wrote: > Are
> you using Scala 2.7.4 or...
>
> > On Fri, Jun 5, 2009 at 7:37 AM, fatu  wrote: > > >
>
> Fantastic, it works great! > ...

--~--~-~--~~~---~--~~
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: fall-through redirect

2009-06-06 Thread Joe Wass

Tim --

Thanks, yes that was very useful; it's certainly helped me understand
working with parameters in urls. For the moment I'm working round the
requirement to match at the root of the url but eventually it would be
nice to be able to do it. David, any guidance on this would be much
appreciated!

Cheers

Joe

On Jun 6, 12:28 am, Timothy Perrett  wrote:
> Joe,
>
> You might enjoy my article on URL rewriting:http://is.gd/wq4K
>
> Does that help?
>
> Cheers, Tim
>
> On Jun 5, 6:37 pm, Joe Wass  wrote:
>
> > I'm after re-writing, not a re-direct (although I'd compromise to a
> > redirect if re-writing isn't possible).
>
> > In Rails I seem to recall it wasn't re-writing but binding after all
> > other attempts to bind had failed. For comparison, here's the Rails
> > version:
>
> > [rails routes.rb]
> > # normal mappings etc
> > map.connect '/search', :controller => 'view', :action => 'search'
>
> > ...
>
> > # fallback find member after everything else has failed
> > map.connect "/:tag", :controller => "view", :action => "member"
> > [/rails]
>
> > which would bind the portion after the slash to 'tag'
>
> > Sorry to drag another framework into it, but I think it's the best way
> > to explain.
>
> > Joe
>
> > On Jun 5, 3:13 pm, David Pollak  wrote:
>
> > > Joe,
> > > Do you want a redirect (HTTP 304) or do you want the URL rewritten so that
> > > Lift sees site.com/user/member, but the browser still thinks in sent
> > > site.com/member ?
>
> > > Thanks,
>
> > > David
>
> > > On Fri, Jun 5, 2009 at 1:47 AM, Joe Wass  wrote:
>
> > > > Hello everyone,
>
> > > > I want to be able to handle requests that don't fall within the
> > > > sitemap. I have a site with members, and, providing that a user id
> > > > doesn't conflict with any part of a sitemap path, I want site.com/
> > > > member to redirect to site.com/user/member. I've done this kind with
> > > > Rails, but the Lift model doesn't quite seem to match Rails so I'm a
> > > > little unsure about how to go about doing it... suggestions?
>
> > > > TIA!
>
> > > > Joe
>
> > > --
> > > 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 to serve html fragments

2009-06-06 Thread David Pollak
Lift is 2.7.4.  We have not upgraded to 2.7.5 as the delta is actor fixes in
response to lift-related tickets that we solved with our own actor impl.
I'm talking to Philipp Haller today at the Lift Off about how to proceed.

On Jun 6, 2009 6:49 AM, "fatu"  wrote:


2.7.5 right now (and a fresh maven repo too) but I think (not sure
though) I had it with 2.7.4 as well. Seems to expect a refSet field in
ActorGC which i couldn't find in 2.7.5 sources.

Fabio

On 5 Giu, 18:10, David Pollak  wrote: > Are
you using Scala 2.7.4 or...

> On Fri, Jun 5, 2009 at 7:37 AM, fatu  wrote: > > >
Fantastic, it works great! > ...

--~--~-~--~~~---~--~~
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: Lift Jquery autocomplete

2009-06-06 Thread David Pollak
I think I'm using in one place in one project so my api breakage factor is
low.  I'm okay with moving it unless someone else is going to feel real
pain.

On Jun 6, 2009 12:24 AM, "Marius"  wrote:


Is there a reason why the JQuery autocomplete is not a Lift widget but
instead it lives in http/jquery package? .. I remember a long time ago
me putting it in the jquery package to separate SHtml stuff that is
dependent on JQuery to the others.

Thoughts?

Br',
Marius

--~--~-~--~~~---~--~~
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 to serve html fragments

2009-06-06 Thread fatu

2.7.5 right now (and a fresh maven repo too) but I think (not sure
though) I had it with 2.7.4 as well. Seems to expect a refSet field in
ActorGC which i couldn't find in 2.7.5 sources.

Fabio

On 5 Giu, 18:10, David Pollak  wrote:
> Are you using Scala 2.7.4 or 2.7.5?
>
>
>
> On Fri, Jun 5, 2009 at 7:37 AM, fatu  wrote:
>
> > Fantastic, it works great!
>
> > I'm getting an unrelated exception, perhaps that's something in flush
> > (looks a bit like it from the trace) and you already know but just in
> > case:
>
> > java.lang.NoSuchFieldException: refSet
> >        at java.lang.Class.getDeclaredField(Class.java:1882)
> >        at net.liftweb.http.PointlessActorToWorkAroundBug$$anonfun$act$1$
> > $anonfun$apply$1.apply(LiftServlet.scala:715)
> >        at net.liftweb.http.PointlessActorToWorkAroundBug$$anonfun$act$1$
> > $anonfun$apply$1.apply(LiftServlet.scala:707)
> >        at scala.actors.Reaction.run(Reaction.scala:78)
> >        at net.liftweb.http.ActorSchedulerFixer$$anon$1$$anonfun$execute
> > $1.apply(LiftServlet.scala:668)
> >        at net.liftweb.http.ActorSchedulerFixer$$anon$1$$anonfun$execute
> > $1.apply(LiftServlet.scala:668)
> >        at net.liftweb.http.ActorSchedulerFixer$$anonfun$20$$anon$2.run
> > (LiftServlet.scala:626)
> >        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask
> > (ThreadPoolExecutor.java:886)
> >        at java.util.concurrent.ThreadPoolExecutor$Worker.run
> > (ThreadPoolExecutor.java:908)
> >        at java.lang.Thread.run(Thread.java:619)
>
> > Thanks again.
>
> > Fabio
>
> > On 5 Giu, 10:58, fatu  wrote:
> > > I've had a look at your commit and skipDocType should now remove the
> > > decl. as well. I'll try it out as soon as I can get a snapshot build
> > > of it.
>
> > > Many many thanks so far.
>
> > > Fabio
>
> > > On 4 Giu, 19:06, David Pollak  wrote:
>
> > > > On Thu, Jun 4, 2009 at 10:04 AM, Timothy Perrett
> > wrote:
>
> > > > > Have you pushed this change? Its not showing on github?
>
> > > > I pushed, but forgot to commit... :-)  That's me, I just can't commit.
>
> > > > All committed and pushed.
>
> > > > > Cheers, Tim
>
> > > > > On 04/06/2009 17:33, "David Pollak" 
> > wrote:
>
> > > > > Okay... checked in a change that removes the  XML header as
> > well
>
> > > > --
> > > > 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: Vscaladoc not grokking new documentation

2009-06-06 Thread David Bernard
Hi,

It's a bug, I'll try to add a test case. (you could open issue at
http://github.com/davidB/vscaladoc/issues)
>From the source code of the page the doc is present. I suggest you remove
the  tag from the comment (at least the first pair).

a side note. you could have "colorized" code if you use
   or 
instead of simple
  

/davidB

PS: I'm was off-line several days.

On Mon, Jun 1, 2009 at 00:05, Timothy Perrett wrote:

>
> Try shooting David B a mail offline – he’s the vscaladoc master Not
> sure that he watches the lift list too much these days. Having said that
> I’ve not seen him on Gtalk for sometime so not sure what his movements are.
>
> Cheers, Tim
>
> On 31/05/2009 22:50, "Derek Chen-Becker"  wrote:
>
> No, because they're intended to be formatting for the Scaladoc. Note that I
> escape entities within the table that should be displayed.
>
>
> >
>

--~--~-~--~~~---~--~~
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 version of master.pdf for the Lift Book

2009-06-06 Thread Randall R Schulz

On Friday June 5 2009, Timothy Perrett wrote:
> Excellent work Derek - great to see you guys still
> soldering on with the book effort post publication :-)

It's a hardware project now?


> Cheers, Tim


RRS

--~--~-~--~~~---~--~~
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: date management

2009-06-06 Thread g-man

I now have the due date arriving OK from the jQuery datepicker, and I
cobbled together some ugliness to give days left until the ToDo due
date, so that is good.

My problem now is since we are not using the 'magic' of the _toForm
methods for the form elements, I have to set each var value for the
model field from the input SHtml data, as was done in the PocketChange
app AddEntry.scala file.

What is happening is that the initialization for each var is resetting
the form if validation fails, so I guess I need to institute some
RequestVars to remember the form values for resubmission, right?

All my questions will take take the form of 'how to' recipes of
foundational webapp elements, as you can see. My plan is to develop
them for a 'cookbook' section of the wiki, so that's why I am asking
one simple conceptual thing at a time.

Therefore, what I have to learn now is all about form binding and
recalling form value state if validation fails, so please break that
down for me.

Thanks as always!


On Jun 3, 10:25 pm, Derek Chen-Becker  wrote:
> Box is the base class. What you want is Full("2").
>
> Derek
>
> On Wed, Jun 3, 2009 at 8:53 PM, g-man  wrote:
>
> > Very good!
>
> > I did a little homework, rearranged some things, and am getting some
> > nice results with the 'manual method'...
>
> > Since I am following the PocketChange app now rather than the ToDo
> > example, there is no 'todo' val in scope to bind, so the
> > todo.priority.toForm method will not work.
>
> > I have SHtml.select working with a mapping for my choices, and I can
> > use Empty for my default, but how do I get a Box["2"] as my default?
>
> > On Jun 3, 7:21 am, Derek Chen-Becker  wrote:
> > > The only issue I would mention is that there's currently an open ticket
> > > because MappedDateTime won't save the time portion when you use Derby. I
> > > haven't had time to triage this yet.
>
> > > Derek
>
> > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett  > >wrote:
>
> > > > Greg,
>
> > > > I dont really use toForm; have you explored "doing it manually"? It
> > > > seems like that would be able to tell you if there is a problem with
> > > > toForm on MappedDateTime.
>
> > > > I use mapped date time quite a bit and have no problems at all
> > > > persisting the dates :-)
>
> > > > Cheers, Tim
>
> > > > On Jun 3, 3:09 am, g-man  wrote:
> > > > > Are there no ideas for my problem?
>
> > > > > I have many more questions saved up, but would like to clear each out
> > > > > before starting a new one.
>
> > > > > Thanks again!
>
> > > > > On May 31, 1:57 pm, g-man  wrote:
>
> > > > > > As I proceed to enhance the ToDo example, I have added a new field
> > to
> > > > > > the ToDo.scala model:
>
> > > > > > object dueOn extends MappedDateTime(this) {
> > > > > >     final val dateFormat = DateFormat.getDateInstance
> > > > > > (DateFormat.SHORT)
> > > > > >     override def asHtml = Text(dateFormat.format(is))}
>
> > > > > > Next, I added a binding in the TD.scala snippet within the add
> > method
> > > > > > of the TD class:
>
> > > > > > def doBind(form: NodeSeq) = {
> > > > > >       bind("todo", form,  "desc" -> todo.desc.toForm,
> > > > > >                           "priority" -> todo.priority.toForm,
> > > > > >                           "dueOn" -> todo.dueOn.toForm,
> > > > > >                           "submit" -> submit("create new Task",
> > > > > > checkAndSave)}
>
> > > > > > Then, the todo.html template gets a bind point:
>
> > > > > > 
> > > > > >       ...
> > > > > >       
> > > > > >       
> > > > > >     
>
> > > > > > When I check the database, the record does save, and all the other
> > > > > > fields are OK, but the date itself is .
>
> > > > > > Somehow, it seems the text of the input field is not getting
> > changed
> > > > > > into a Date object for the database to handle, right?
>
> > > > > > When I look at the PocketChange app from the book, everything is
> > done
> > > > > > completely differently from the ToDo example (no use of _toForm,
> > for
> > > > > > instance).
>
> > > > > > I know dates and times are convoluted in Java, so what am I
> > missing?
>
> > > > > > 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] Fading out notices

2009-06-06 Thread Marius

Hi there,

I just committed a simple support to fade out notices. For instance
sometimes we just want to render a notice somewhere in the page but we
want it to disappear after a few seconds. Say we have a form that
saves a record and then was want to say to the user that the item was
saved and we want this message to vanish after a little while.

This code is dependent on JQuery hence we have 3 functions in
net.liftweb.http.jquery.JqSHtml

A few examples:

fadeOutErrors(5 seconds, 1 second)
fadeOutWarnings(5 seconds, 1 second)
fadeOutNotices(5 seconds, 1 second)

All these functions return a JsCmd. This means that you can use this
as well for Ajax & Comet. But for Non Ajax here is a dummy example:

Assume a simple snippet:

  def howdy = {
S.error("howdy error")
Hello there ++
{Script(OnLoad(fadeOutErrors(5 seconds, 1 second)))}

  }

So we set an error, return whatever the snippet returns (in this case
a simple span) and then concatenate the head tag where on load tell
lift to hide all errors after 5 seconds and the fade out time to be 1
second.

Br's,
Marius
--~--~-~--~~~---~--~~
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] Lift Jquery autocomplete

2009-06-06 Thread Marius

Is there a reason why the JQuery autocomplete is not a Lift widget but
instead it lives in http/jquery package? .. I remember a long time ago
me putting it in the jquery package to separate SHtml stuff that is
dependent on JQuery to the others.

Thoughts?

Br',
Marius
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---