Lift 3.0 findVisibleTemplate needs surround?

66 views
Skip to first unread message

AK

unread,
May 13, 2013, 7:26:19 AM5/13/13
to lif...@googlegroups.com
At Lift 3.0 def findVisibleTemplate was changed.

later it was returning
Templates(splits, S.locale)

At 3.0 it is returning:
Templates(splits, S.locale).map {
      case e: Elem if e.label == "html" => e
      case e: Elem if hasSurround(e) => e
      case x => <lift:surround with="default" at="content">
        {x}
      </lift:surround>
    }


So it needs that template should be <html>...</html> or to be surrounded.

But what if I just want to return a part of html for ajax requests (not surrounded with html)?
What is a good reason insisting on surround?


Thanks,
Alexander

AK

unread,
May 13, 2013, 7:30:25 AM5/13/13
to lif...@googlegroups.com
Oh, didn't notice a similar problem at neighbor talk.

But anyway the problem is still there, and advise is needed.

Thanks,
Alexander

понедельник, 13 мая 2013 г., 15:26:19 UTC+4 пользователь AK написал:

David Pollak

unread,
May 13, 2013, 10:08:16 AM5/13/13
to liftweb
findVisibleTemplate is used by Lift to find a top-level template for use in composing a full HTML page.

There are plenty of other mechanisms for finding templates. If findVisibleTemplate's new behavior doesn't work for you, use one of the other mechanisms.


--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net

AK

unread,
May 15, 2013, 8:27:01 AM5/15/13
to lif...@googlegroups.com
The point is that earlier I was able just to put template for ajax page into webapp folder and have added path to sitemap.
And it was serviced using findVisibleTemplate.

Now I should write additional service for templates without html top tag?

понедельник, 13 мая 2013 г., 18:08:16 UTC+4 пользователь David Pollak написал:

David Pollak

unread,
May 15, 2013, 11:53:14 AM5/15/13
to liftweb
Doing a non-Lift Ajax request to get a page that Lift thinks is a full page load is a super ultra mega bad thing. All of the machinery that Lift has to deal with GUIDs on the page, etc. get broken.


AK

unread,
May 17, 2013, 12:22:47 AM5/17/13
to lif...@googlegroups.com
Yes. It's very bad, and I didn't want to do it.

But what is solution to service page that is not surrounded with html?

I digged a little into and now I understand that Lift is adding comets and lift_page for GC at the end of body tag, and this could be a good reason to insist on surround.

But, there could be walkaround by adding pages and lift_watch at partial ajax pages.
And I think it could be discussed, because servicing just full html pages isn't very nice.

What do you think?

Thanks,
Alexander

среда, 15 мая 2013 г., 19:53:14 UTC+4 пользователь David Pollak написал:

Antonio Salazar Cardozo

unread,
May 17, 2013, 7:25:29 AM5/17/13
to lif...@googlegroups.com
You should be able to use S.runTemplate via a Lift ajax call (e.g., ajaxButton and such).
Thanks,
Antonio

David Pollak

unread,
May 17, 2013, 12:38:42 PM5/17/13
to liftweb
To reinforce that Antonio said... all the right lift_watch, etc. stuff happens on the Lift Ajax calls because the page GUID gets passed around with the Lift Ajax call, so any GUID related items are rendered in the scope of the original page.

AK

unread,
May 17, 2013, 9:46:56 PM5/17/13
to lif...@googlegroups.com
To summaraize.

Loading ajax page via regular request is bad. Because of loosing original page GUID (renderVersion), and will need extra hacks to fix it.
Lift 3.0 also make it impossible to do insisting on top html tag be presented at rendered template.

The good way to go is to load content via Lift ajax call and rendering template with S.runTemplate.

But if partial page contains comets it is also needed to peek up S.cometAtEnd manually at ajax call processing and to add this elements to rendered template (cometAtEnd are snippets and should be rendered before adding)
Also it is needed to update lift_toWatch js variable to add new comets (and to remove old if loaded page replaces page part that contained comets).
Moreover to force new loaded comets to start working immediately after ajax page loading, it is needed to emit a comet response just after lift_toWatch was updated.
It will make client to make a new request according to updated lift_toWatch and to bootstrap new comets at client side.
This part could be easily done with lift roundtrip by calling helper function like this:

def doCallback(data: JValue, func: RoundTripHandlerFunc): Unit = func.done
val jscmd = JsCrVar("ajaxNavCallBack", sess.buildRoundtrip(List[RoundTripInfo](
          "cometUpdate" -> doCallback _
        ))).toJsCmd


That's it.



пятница, 17 мая 2013 г., 20:38:42 UTC+4 пользователь David Pollak написал:

Antonio Salazar Cardozo

unread,
May 20, 2013, 4:19:56 AM5/20/13
to lif...@googlegroups.com
You'll run into page GUID issues no matter what you do, unless you either (a) intercept the GUID generation very early in the request process and replace it with the original page's (I'd need to take a pretty deep look at the LiftServlet code to figure out if there's even a hook point where you could do that) or (b) run Lift's GC handling on multiple page GUIDs and pass down the partially rendered template's GUID/GC id with the request response (which I have done before, attaching it to the returned top-level element's data-lift-gc attribute). I've made posts about the latter process on this list before.
Thanks,
Antonio

David Pollak

unread,
May 20, 2013, 9:31:18 AM5/20/13
to liftweb
Antonio,

If you render the page during a Lift Ajax call, then the page has the same GUID info as the original page. The GUID for the page is included in the Ajax call.

Thanks,

David

Reply all
Reply to author
Forward
0 new messages