On May 15, 10:18 pm, Scalanewbie <[email protected]> wrote:
> Hi,
> as a lift-scala-newbie i am trying out various things with lift to see
> advantages etc. to other frameworks (rails, grails,...)
>
> I am now trying to integrate a third party java validation library and
> i want to embed the results into my webapp. First i want to put all
> localized error messages into the error object, which seems to be
> straightforward and i am not expecting any problems there.
>
> my second step would be a integration with the binding to visualize
> input/textareas depending on their validation results. My problem is
> now the lifecycle of my snippet.
>
> object name extends RequestVar("")
>
> //someCode
>
> def submit() { //validation would happen here }
>
> bind("myobject", xhtml, "name" ->
>   SHtml.text(name.is, name(_),
> ("class","dependsOnTheValidationResult"),
>   "submit" -> SHtml.submit("submit", submit)
> )
>
> My problem is, that the binding to the form happens at the same time
> as the binding to the request vars. So it seems like there is no
> simple way to:
>
> 1. read the vars
> 2. bind them to an object
> 3. validate the object
> 4. bind the validation result to the css attributes of the elements
>
> AND: This should only happen when the user submits. Because there is
> no need to validate when the user hits the page the first time. Should
> i create 2 pages (one for the first view, one for the validation
> cycle, separate binding methods,...). This seems not to be a DRY way.

In fact it is very easy to do this:


1. For the function bound to the form fields you onyl accumulate the
data and put it in whatever structure you want
2. Do the validation in the submit function
3. You can easily use <lift:msg> built in snippet to show error
message near by th fields that failed to validate.

For Ajax forms you can very easily use JSON forms (http://
wiki.liftweb.net/index.php/HowTo_do_use_JSON_forms)

... All this of course without using any validations supported by
Mapper and Record frameworks.

>
> Any suggestions or best practices?
>
> thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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