On Tue, Aug 25, 2009 at 9:46 AM, marius d. <[email protected]> wrote:

>
> The topic was brought up in the discussion.
>
> Br's,
> Marius
>
> On Aug 25, 7:32 pm, David Pollak <[email protected]>
> wrote:
> > On Tue, Aug 25, 2009 at 9:23 AM, marius d. <[email protected]>
> wrote:
> >
> > > 1. I just pushed a little change that allows:
> >
> > > <lift:MySnippet form="post" action="/search">
> > > ...
> > > </lift:MySnippet>
> >
> > > 2. You can also do
> >
> > > <form method="post" action="/search">
> > > <lift:mysnippet>
> >
> > >  <f:inputSearch/>
> > >  <f:submit/>
> >
> > > </mysnippet>
> >
> > > </form>
> >
> > I'm not overly keen on the change (I'm not asking for it to be removed).
> > The reason for the "form" attribute was that it's common to do postbacks
> and
> > the generation of S.uri as part of the URL was a bunch of boilerplate.
>
> This commit does not contradict this rule. People can use action only
> if they really need to without the boiler plate of typing the form
> tag.


Right, but it's a place where Lift is mutating the result of the snippet
call.  This should only be done if there is a compelling reason.  I see no
compelling reason here.  This case is a fringe case and can easily be
handled with a static form tag.  The reason for the form attribute is that
it's the common case for wrapping a snippet in a post-back form and the URL
of the postback would require yet another snippet to calculate... and the
feature made it into Lift before attribute snippets.

So, the rules are: (1) Lift does not mutate what the snippet returns except
under extremely compelling situations and (2) we don't add "reserved word"
attributes except under compelling situations.


>
>
> > That's the reason I made the exception to the "snippets result in
> whatever
> > is returned from the snippet rather than having magic intervention" rule.
>
> I really don't see how this implies a "magic intervention" since all
> this applies only if user explicitly adds action attribute. I mean if
> users explicitly points to a new page they expect that page to be
> rendered naturally which is what is happening.


Except for the "form='xxx'" attribute, I know of no other attribute that's
baked into Lift's snippet handling mechanism.  The use of this attribute is
the only time that I know of that Lift's snippet handler mutates the result
of the snippet by putting a <form/> tag around it.

In all other cases, it's up to the snippet itself to interpret the
attributes.  If we keep adding attributes that cause something to happen if
the attribute appears, it will reduce the attributes available for use by
snippets themselves.


>
>
> > In the future, let's not mutate what the snippet returns without a
> > discussion and a very strong justification.
>
> I really don't see the problem. The form attribute tells the user that
> a form will be rendered. Since a form will be rendered why can't the
> user change the action in exceptional cases since this doesn't induce
> side effects. If it does please let me know what are those side
> effects.


It removes an attribute that's available for generic use by snippets.  If
there's code out there that uses the action attribute as part of the
snippet, what are the impacts on that snippet?


>
>
> If you want to I have no problem removing it but I really don't see
> what the issue is.
>
> >
> > Thanks,
> >
> > David
> >
> >
> >
> >
> >
> > > In both cases you can use Lift's html abstractions such as SHtml.text
> > > etc. and bind your function. In the second example we used a snippet
> > > that has no idea about form ... it is just wrapped by a form. So in
> > > both cases you don't really need to call S.attr to manually get
> > > parameters.
> >
> > > Br's,
> > > Marius
> >
> > > On Aug 25, 6:24 pm, David Pollak <[email protected]>
> > > wrote:
> > > > On Tue, Aug 25, 2009 at 12:38 AM, Ulises <[email protected]>
> > > wrote:
> >
> > > > > Hey people,
> >
> > > > > I'm trying to have a form be submitted to a different page (so, not
> a
> > > > > POST/GET back). The scenario is a search form which renders on a
> front
> > > > > page as well as on the search page.
> >
> > > > > E.g.:
> >
> > > > > /index
> > > > >  should include a form that submits to /search
> >
> > > > > /search
> > > > >  form that submits to itself
> >
> > > > <form method="post" action="/search"><input type="text" name="search"
> > > > value=""/><input type="submit" value="Search"/></form>
> >
> > > > In the snippet that handles the search page:
> >
> > > > val searchTerm = S.param("search") openOr {S.error("no search term");
> > > > S.redirectTo(S.referer openOr "/")}
> >
> > > > > Any hints on how to do this/were to look to learn how to do this? I
> > > > > guess that the form on the front page could be just static HTML
> > > > > however I'm not entirely sure how /search would deal with the form
> > > > > submission from a static form ...
> >
> > > > > Cheers,
> >
> > > > > Ulises
> >
> > > > --
> > > > 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
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to