My cup runneth over...

Derek Chen-Becker wrote:
> Or a third idea. Use a hidden to execute your processing function. From 
> the first example:
> 
> <lift:My.snippet form="POST">
>   <input type="submit" value="Hit Me!" />
>   <form:name />
>   <form:desc />
>   <form:call />
>   <input type="submit" value="Hit Me!" />
> </lift:My.snippet>
> 
> And your snippet would look like:
> 
> class My {
>   var name = ""
>   var desc = ""
> 
>   def snippet (xhtml : NodeSeq) : NodeSeq = {
>     def process() {
>       ...
>     }
>  
>     bind("form", xhtml,
>            "name" -> SHtml.text(name, name = _),
>            "desc" -> SHtml.text(desc, desc = _),
>            "call" -> SHtml.hidden(process _))
>   }
> }
> 
> Not sure which approach I like best...
> 
> Derek
> 
> On Sat, Apr 25, 2009 at 2:54 PM, Derek Chen-Becker 
> <[email protected] <mailto:[email protected]>> wrote:
> 
>     I just had another idea. You could add a "guard" field in your form
>     using SHtml.hidden and have it set a var to true:
> 
>     var doForm = false
>     bind(...
>           "guard" -> SHtml.hidden(() => doForm = true),
>           "submit" -> SHtml.submit(...))
> 
>     Then the submission function *would* get called twice, but you could
>     use the guard to check to make sure that other elements had been
>     processed first.
> 
>     Derek
> 
> 
>     On Sat, Apr 25, 2009 at 2:52 PM, Derek Chen-Becker
>     <[email protected] <mailto:[email protected]>> wrote:
> 
>         If you were going to do that I would suggest a hybrid approach.
>         Use regular HTML input tags for the submit in your form in the
>         template and make your last bound function execute the form
>         processing function. So the template could look like:
> 
>         <lift:My.snippet form="POST">
>           <input type="submit" value="Hit Me!" />
>           <form:name />
>           <form:desc />
>           <input type="submit" value="Hit Me!" />
>         </lift:My.snippet>
> 
>         And your snippet would look like:
> 
>         class My {
>           var name = ""
>           var desc = ""
> 
>           def snippet (xhtml : NodeSeq) : NodeSeq = {
>             def process(in : String) {
>               desc = in
>               ...
>             }
>          
>             bind("form", xhtml,
>                    "name" -> SHtml.text(name, name = _),
>                    "desc" -> SHtml.text(desc, process(_)))
>           }
>         }
> 
>         I'm cutting corners on the snippet (probably want validation,
>         ReqestVar or StatefulSnippet for the vars, etc), but I think
>         that covers the general idea.
> 
>         Derek
> 
> 
>         On Sat, Apr 25, 2009 at 1:27 PM, Charles F. Munat
>         <[email protected] <mailto:[email protected]>> wrote:
> 
> 
>             So if I wanted to put a submit button at the top of the form
>             instead of
>             (or in addition to) the bottom, how would I do that?
> 
>             Chas.
> 
>             marius d. wrote:
>              > Just a small clarification if I may.The binding order do
>             not really
>              > matter in terms of user's functions mapping. However the
>             functions
>              > mapped are called in the HTTP parameters order sent by
>             the browser.
>              >
>              > Br's,
>              > Marius
>              >
>              > On Apr 25, 3:53 pm, Derek Chen-Becker
>             <[email protected] <mailto:[email protected]>> wrote:
>              >> Ah, yes. The bindings are processed in order, so the
>             submit button has to
>              >> come last or it will fire before other bindings.
>              >>
>              >> Derek
>              >>
>              >> On Sat, Apr 25, 2009 at 12:38 AM, [email protected]
>             <mailto:[email protected]> <
>              >>
>              >> [email protected] <mailto:[email protected]>>
>             wrote:
>              >>
>              >>> Oh...I think I found the reason...Thanks for the help....
>              >>> The reason is in my code
>              >>> The binding to submit button is previous to binding to
>             checkbox.....
>              >>> if the order is changed...it would work correctly
>              > >
> 
> 
> 
> 
> 
> 
> > 

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