After some experimenting I have field validation working with JSR 303
annotations. See:


http://wstrange.wordpress.com/2009/12/07/inline-field-validation-in-scalalift-using-jpa-and-jsr-303/




On Dec 5, 10:53 pm, wstrange <warren.stra...@gmail.com> wrote:
> After more experimenting ... I think this approach only works with
> Mapper/Record? It requires afieldid to be set, and validations
> errors to be set on that id ( e.g. S.error("mobilePhone", "bad
> phone...") )
>
> Is there an example of how to do this using JPA and JSR 303 (aka
> Hibernate Validators)?
>
> On Dec 5, 6:38 pm, wstrange <warren.stra...@gmail.com> wrote:
>
> > OK, figured it out.  This should be:
>
> > bind(...
> >  "mobilePhone" -> formField("Mobile Phone", SHtml.text
> > (user.mobilePhone, user.mobilePhone = _) ),
>
> > On Dec 5, 5:39 pm, wstrange <warren.stra...@gmail.com> wrote:
>
> > > Hi Alex
>
> > > Thank you so much for the tip.
>
> > > Just so I am clear (I am a  lift newbie), I assume I would call this
> > > function in my snippet:
>
> > > bind(......
> > > "phoneNumber" -> formField("Phone Number", user.phoneNumber)
> > > )
>
> > > Is that the idea?
>
> > > On Dec 4, 5:06 pm, Alex Siman <aleksandr.si...@gmail.com> wrote:
>
> > > > Checkout my code, especially parts with "cssClass".
>
> > > >         import net.liftweb.http.S._
> > > >         import net.liftweb.http.SHtml._
>
> > > >         // input can be SHtml.text
> > > >         def formField(label: String, input: Elem): NodeSeq = {
> > > >                 val fixedLabel = label match {
> > > >                         case "" => ""
> > > >                         case s: String => s + ":"
> > > >                 }
>
> > > >                 val id = (input \ "@id").toString
> > > >                 val messageList = messagesById(id)(errors)
> > > >                 val hasMessages = messageList.size > 0
> > > >                 val cssClass = if (hasMessages) "ErrorField" else ""
> > > >                 val messages = messageList match {
> > > >                         case list: List[NodeSeq] if hasMessages => {
> > > >                                 <ul>{messageList.map(m => 
> > > > <li>{m}</li>)}</ul>
> > > >                         }
> > > >                         case _ => Nil
> > > >                 }
>
> > > >                 <table class={cssClass} style="width: 100%;">
> > > >                         <tr>
> > > >                                 <td style="text-align: right; 
> > > > vertical-align: top; width: 10em;">
> > > >                                         <b>{fixedLabel}</b>&nbsp;
> > > >                                 </td>
> > > >                                 <td style="text-align: left;">
> > > >                                         {input}{messages}
> > > >                                 </td>
> > > >                         </tr>
> > > >                 </table>
> > > >         }
>
> > > > On 4 дек, 23:22, wstrange <warren.stra...@gmail.com> wrote:
>
> > > > > I have searched the archives, but the answer is not immediately clear
> > > > > to me...
>
> > > > > How does one providefieldvalidationfeedback on a form (e.g. turn
> > > > > the phone numberfieldred if an error is made in data entry)? The
> > > > > S.error approach of collecting all the errors into one big message
> > > > > seems unwieldy, and does not give the user very good feedback.   I am
> > > > > using JPA if that makes any difference.
>
> > > > > Any tips would be appreciated

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to