Hi Naftoli and David! Thanks for your input.
(I'm not sure I've understood you correctly. I'm very new to Lift.)
Naftoli Gugenheim wrote:
> On Tue, Nov 30, 2010 at 10:02 PM, Magnus Lindberg <
lindberg.mag...@gmail.com
> > wrote:
> > instead it extracts the <form>
> > element from the
> > Reply html page,
>
> You extract it via Javascript? Why not have a template that has the ajax
> subset of the static Reply page as its entire contents? Then I think it
> would include the javascript just like any page.
Then I'd need both a static Reply page (for people with no JavaScript)
and an Ajax version of the Reply page?
-- That'd be twice as much code and stuff to test? (That's why
I'd prefer having only one non-ajax Reply form and nothing else.)
Anyway, I suppose it's a good solution (with an Ajax version too),
since the static HTML Reply form costs more bandwidth.
***
> David Pollak wrote:
> Why not compose the page on the server? If you request the HTML to overlay
> on your page via a Lift Ajax call, the new page will be composed in the
> context of the page that the Ajax request came from and will be properly
> GCed when the rest of the page's functions are GCed.
That means I'd construct the Reply stuff with calls to
SHtml.ajaxCall ?
Then, if I also want the static Reply form page (for people without
JavaScript),
I'd need two implementations?
I suppose it's the best approach performance/bandwidth wise,
with both a static page and an Ajax version.
***
Perhaps this is another possible solution:
(No server side state, no timeouts, (almost) no XSRF attacks.)
When the client user clicks Reply, the server replies with a
*stateless* plain HTML reply form.
(With <input> names mapped to *no* server-side-functions.)
Which the client inserts into the main Discussion Page (using jQuery).
The user then enters a reply, and clicks a certain "Preview" button,
and the client POSTs the form to the server, which saves [the preview
of the reply]
in the database, and assigns it a unique GUID.
(XSRF attacks possible, but the preview is not published so perhaps
this is acceptable.)
The server replies with the HTML form, which now includes the
preview and the GUID.
The client extracts the GUID from the reply (with jQuery).
Later, when the user clicks "Publish reply",
the client uploads the GUID to the server, which then publishes the
post.
Since all forms are stateless, they won't time out.
And since the server generates the GUID,
no one but the client can ask the server to *publish* the preview
(no XSRF attacks).
Kind regards, Magnus