[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-08 Thread wibblecp
Hi Marius,
I am using version 2.0-M1.

Now it works. This topic could be considered closed for me.
Thanks to all for your replies. Regards,
wibble.


On Feb 6, 6:32 pm, Marius  wrote:
> What Lift version are you using?
>
> If you are using an Ajax form  did not show
> the messages associated with ID's ... messages coming from FieldError.
> This is a defect I fixed about a week ago. Please use the latest lift
> build.
>
> If you just want to render all messages (regardles if they are
> associated with ID's or not) in one place  
> should be fine. But typically for field related message you could use
>  which would render only messages associated
> with "field_id" id. As a side note  only render messages
> that are not associated with any ID.
>
> Br's,
> Marius
>
> On Feb 6, 3:51 pm, wibblecp  wrote:
>
>
>
> > hi Adam,
>
> > thank you. It is exactly what I done
>
> > def validateAndSave (): Unit = currentEntry.validate match {
> >       case Nil => currentEntry.save ; S.notice(currentEntry.title + "
> > SAVED!")
> >       case x => { x map { (e:FieldError) => S.error(e.msg) } }
> >     }
>
> > have a nice day.
> > wibble
>
> > On Feb 6, 2:35 pm, Adam Warski  wrote:
>
> > > Hello,
>
> > > are you submitting the form with ajax?
> > > If so, see this thread:
>
> > >http://groups.google.com/group/liftweb/browse_thread/thread/e25d86a24...
>
> > > In short, check if doing:
>
> > > xs.map {i => S.error(i.msg) };
>
> > > instead of:
>
> > > S.error(xs);
>
> > > works.
>
> > > > Hi Jeppe,
> > > >  does not work. Always the same result.
>
> > > > If the form does not contain errors the data are saved well and the
> > > > browser display S.notice("saved") correctly.
> > > > The S.error method returns a List[FieldError]. I receive a List with
> > > > the format of List(Full(tablename_field) : message)
>
> > > > this is a field of my database class:
> > > > [code]
> > > > object description extends MappedTextarea(this, 255) {
> > > >    override def displayName = "Description"
> > > >    override def validations =  valMinLen(1, S.??("description must
> > > > not be empty")) _ :: super.validations
> > > >  }
>
> > > > [/code]
>
> > > > thanks,
> > > > wibble
>
> > > > On Feb 6, 12:19 pm, Jeppe Nejsum Madsen  wrote:
> > > >> wibblecp  writes:
> > > >>> it does not work even in the case of a single error on the form.
>
> > > >>> the result is always a List(Full(entries_code) : Description must not
> > > >>> be empty)
>
> > > >> Try adding showAll:
>
> > > >> 
>
> > > >> But default, Msgs doesnøt show field-level errors
>
> > > >> /Jeppe
>
> > > > --
> > > > 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 
> > > > athttp://groups.google.com/group/liftweb?hl=en.
>
> > > --
> > > Adam Warskihttp://www.warski.orghttp://www.softwaremill.eu

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



[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-08 Thread wibblecp
Thanks Timothy for your advice.

On Feb 6, 3:16 pm, Timothy Perrett  wrote:
> wow, thats some ugly code man. Why dont you try something like:
>
> def validateAndSave {
>   currentEntry.validate match {
>     case Nil =>
>       currentEntry.save
>       S.notice(currentEntry.title + "SAVED!")
>     case List(fielderror) => S.error(fielderror.msg)
>     case _ =>
>   }
>
> }
>
> I havent tested it of course, but just wanna show you how you could tidy up 
> your code somewhat.
>
> Cheers, Tim
>
> On 6 Feb 2010, at 13:51, wibblecp wrote:
>
>
>
> > def validateAndSave (): Unit = currentEntry.validate match {
> >      case Nil => currentEntry.save ; S.notice(currentEntry.title + "
> > SAVED!")
> >      case x => { x map { (e:FieldError) => S.error(e.msg) } }
> >    }

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



[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-06 Thread wibblecp
hi Adam,

thank you. It is exactly what I done

def validateAndSave (): Unit = currentEntry.validate match {
  case Nil => currentEntry.save ; S.notice(currentEntry.title + "
SAVED!")
  case x => { x map { (e:FieldError) => S.error(e.msg) } }
}

have a nice day.
wibble


On Feb 6, 2:35 pm, Adam Warski  wrote:
> Hello,
>
> are you submitting the form with ajax?
> If so, see this thread:
>
> http://groups.google.com/group/liftweb/browse_thread/thread/e25d86a24...
>
> In short, check if doing:
>
> xs.map {i => S.error(i.msg) };
>
> instead of:
>
> S.error(xs);
>
> works.
>
>
>
> > Hi Jeppe,
> >  does not work. Always the same result.
>
> > If the form does not contain errors the data are saved well and the
> > browser display S.notice("saved") correctly.
> > The S.error method returns a List[FieldError]. I receive a List with
> > the format of List(Full(tablename_field) : message)
>
> > this is a field of my database class:
> > [code]
> > object description extends MappedTextarea(this, 255) {
> >    override def displayName = "Description"
> >    override def validations =  valMinLen(1, S.??("description must
> > not be empty")) _ :: super.validations
> >  }
>
> > [/code]
>
> > thanks,
> > wibble
>
> > On Feb 6, 12:19 pm, Jeppe Nejsum Madsen  wrote:
> >> wibblecp  writes:
> >>> it does not work even in the case of a single error on the form.
>
> >>> the result is always a List(Full(entries_code) : Description must not
> >>> be empty)
>
> >> Try adding showAll:
>
> >> 
>
> >> But default, Msgs doesnøt show field-level errors
>
> >> /Jeppe
>
> > --
> > 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 
> > athttp://groups.google.com/group/liftweb?hl=en.
>
> --
> Adam Warskihttp://www.warski.orghttp://www.softwaremill.eu

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



[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-06 Thread wibblecp
Hi Jeppe,
 does not work. Always the same result.

If the form does not contain errors the data are saved well and the
browser display S.notice("saved") correctly.
The S.error method returns a List[FieldError]. I receive a List with
the format of List(Full(tablename_field) : message)

this is a field of my database class:
[code]
object description extends MappedTextarea(this, 255) {
override def displayName = "Description"
override def validations =  valMinLen(1, S.??("description must
not be empty")) _ :: super.validations
  }

[/code]

thanks,
wibble

On Feb 6, 12:19 pm, Jeppe Nejsum Madsen  wrote:
> wibblecp  writes:
> > it does not work even in the case of a single error on the form.
>
> > the result is always a List(Full(entries_code) : Description must not
> > be empty)
>
> Try adding showAll:
>
> 
>
> But default, Msgs doesnøt show field-level errors
>
> /Jeppe

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



[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-06 Thread wibblecp
it does not work even in the case of a single error on the form.

the result is always a List(Full(entries_code) : Description must not
be empty)

thanks,
wibble.


On Feb 6, 11:00 am, wibblecp  wrote:
> Using  I receive the same result.
>
> S.notice works fine in the browser but S.error with a list of errors
> does not work.
>
> any advice? thanks,
> wibble.
>
> On Feb 6, 10:16 am, wibblecp  wrote:
>
>
>
> > Hi Marius, thanks for your raply
>
> > I am using it in my html page as:
>
> > [code]
> >         
> >             flash_error
> >             errorExplanation
> >             flash_notice
> >         
> > [/code]
>
> > thanks,
> > w.
>
> > On Feb 6, 10:12 am, Marius  wrote:
>
> > > Are you using in your html page  ?
>
> > > Br's,
> > > Marius
>
> > > On Feb 6, 10:45 am, wibblecp  wrote:
>
> > > > Hi all,
> > > > I'm newbie with lifts and I am having a little problem. I am using
> > > > Lift2.0-M1.
>
> > > > I have a snippet that runs the rescue of a model. The method is called
> > > > when the submit the form
>
> > > > [code]
> > > > def validateAndSave (): Unit = currentEntry.validate match {
> > > >       case Nil => currentEntry.save ; S.notice(currentEntry.title + "
> > > > SAVED!")
> > > >       case x => println(x) ; S.error(x);
> > > >     }
> > > > [/code]
>
> > > > I am not able to view the error messages in the browser, but only in
> > > > the shell.
> > > > Instead of using S.error(x) I tried S.error(""+x). Now when I submit a
> > > > form I see the error messages but the message looks like this:
>
> > > > [code]
> > > > List(Full(entries_code) : Description must not be empty,
> > > > Full(entries_title) : Title must not be empty;,
> > > > Full(entries_author_email) : Invalid email address)
> > > > [/code]
>
> > > > So, the message are not displayed as expected and I am not able to
> > > > understand the reason for S.error("" + x) to read something.
>
> > > > Could anyone give me an advice?
>
> > > > Thanks for your helps.
>
> > > > Ragards,
> > > > w.

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



[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-06 Thread wibblecp
Using  I receive the same result.

S.notice works fine in the browser but S.error with a list of errors
does not work.

any advice? thanks,
wibble.

On Feb 6, 10:16 am, wibblecp  wrote:
> Hi Marius, thanks for your raply
>
> I am using it in my html page as:
>
> [code]
>         
>             flash_error
>             errorExplanation
>             flash_notice
>         
> [/code]
>
> thanks,
> w.
>
> On Feb 6, 10:12 am, Marius  wrote:
>
>
>
> > Are you using in your html page  ?
>
> > Br's,
> > Marius
>
> > On Feb 6, 10:45 am, wibblecp  wrote:
>
> > > Hi all,
> > > I'm newbie with lifts and I am having a little problem. I am using
> > > Lift2.0-M1.
>
> > > I have a snippet that runs the rescue of a model. The method is called
> > > when the submit the form
>
> > > [code]
> > > def validateAndSave (): Unit = currentEntry.validate match {
> > >       case Nil => currentEntry.save ; S.notice(currentEntry.title + "
> > > SAVED!")
> > >       case x => println(x) ; S.error(x);
> > >     }
> > > [/code]
>
> > > I am not able to view the error messages in the browser, but only in
> > > the shell.
> > > Instead of using S.error(x) I tried S.error(""+x). Now when I submit a
> > > form I see the error messages but the message looks like this:
>
> > > [code]
> > > List(Full(entries_code) : Description must not be empty,
> > > Full(entries_title) : Title must not be empty;,
> > > Full(entries_author_email) : Invalid email address)
> > > [/code]
>
> > > So, the message are not displayed as expected and I am not able to
> > > understand the reason for S.error("" + x) to read something.
>
> > > Could anyone give me an advice?
>
> > > Thanks for your helps.
>
> > > Ragards,
> > > w.

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



[Lift] Re: Error messages are not displayed - 2.0-M1

2010-02-06 Thread wibblecp
Hi Marius, thanks for your raply

I am using it in my html page as:

[code]

flash_error
errorExplanation
flash_notice

[/code]

thanks,
w.

On Feb 6, 10:12 am, Marius  wrote:
> Are you using in your html page  ?
>
> Br's,
> Marius
>
> On Feb 6, 10:45 am, wibblecp  wrote:
>
>
>
> > Hi all,
> > I'm newbie with lifts and I am having a little problem. I am using
> > Lift2.0-M1.
>
> > I have a snippet that runs the rescue of a model. The method is called
> > when the submit the form
>
> > [code]
> > def validateAndSave (): Unit = currentEntry.validate match {
> >       case Nil => currentEntry.save ; S.notice(currentEntry.title + "
> > SAVED!")
> >       case x => println(x) ; S.error(x);
> >     }
> > [/code]
>
> > I am not able to view the error messages in the browser, but only in
> > the shell.
> > Instead of using S.error(x) I tried S.error(""+x). Now when I submit a
> > form I see the error messages but the message looks like this:
>
> > [code]
> > List(Full(entries_code) : Description must not be empty,
> > Full(entries_title) : Title must not be empty;,
> > Full(entries_author_email) : Invalid email address)
> > [/code]
>
> > So, the message are not displayed as expected and I am not able to
> > understand the reason for S.error("" + x) to read something.
>
> > Could anyone give me an advice?
>
> > Thanks for your helps.
>
> > Ragards,
> > w.

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



[Lift] Error messages are not displayed - 2.0-M1

2010-02-06 Thread wibblecp
Hi all,
I'm newbie with lifts and I am having a little problem. I am using
Lift2.0-M1.

I have a snippet that runs the rescue of a model. The method is called
when the submit the form

[code]
def validateAndSave (): Unit = currentEntry.validate match {
  case Nil => currentEntry.save ; S.notice(currentEntry.title + "
SAVED!")
  case x => println(x) ; S.error(x);
}
[/code]

I am not able to view the error messages in the browser, but only in
the shell.
Instead of using S.error(x) I tried S.error(""+x). Now when I submit a
form I see the error messages but the message looks like this:

[code]
List(Full(entries_code) : Description must not be empty,
Full(entries_title) : Title must not be empty;,
Full(entries_author_email) : Invalid email address)
[/code]

So, the message are not displayed as expected and I am not able to
understand the reason for S.error("" + x) to read something.

Could anyone give me an advice?

Thanks for your helps.

Ragards,
w.


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



[Lift] Re: How to create an rss?

2009-10-23 Thread wibblecp

Hi Glenn
thanks for your reply. It seems to work for me :-) I was confused
between AtomResponse, Box[NodeSeq] and LiftResponse. I am at beginning
of this journey.

regards,
wibblecp.

On 23 Ott, 18:49, glenn  wrote:
> I don't know if this will help, but I use a simple createTag to just
> enclose the full xml so it has a root element:
>
>    def createTag(in: NodeSeq) = {
>        {in}
>
>   }
>
> and then showArticles would call into a feed wrapper, passing in the
> result of yield,  like this for an Atom feed:
>
> //Reacts to Get all reguest
>    def showArticles():AtomResponse = {
>      val eList = for(e <- Content.findAll) yield {
>             e.toAtom
>           }
>
>          AtomResponse(feedWrapper(eList))
>
>    }
>
> Glenn
>
> On Oct 23, 6:24 am, wibblecp  wrote:
>
> > hi guys,
> > I'm looking for a way to generate an rss feed with lift, I'm working
> > on something like this (from lift-book):
>
> > object OwnRssFeed extends XMLApiHelper {
> >   def dispatch: LiftRules.DispatchPF = {
> >     case Req("rss" ::   Nil, "", GetRequest) => () => showArticles()
> >     case Req("rss" :: _ :: Nil, "",  _) => failure _
> >   }
>
> >     def failure() : LiftResponse = {
> >       val ret: Box[NodeSeq] = Full()
> >       NotFoundResponse()
> >     }
>
> >     def createTag(in: NodeSeq) = {
> >       println("[CreateTag] " + in)
> >       
> >           
> >               title
> >               http://example.org
> >               Example.org
> >               en-us
>
> >               Lift WebFramework
> >                   {in}
> >           
> >       
> >     }
>
> >     def showArticles(): LiftResponse = {
> >       val a: Box[NodeSeq] = for(a <- Article.find(By
> > (Article.published, true))) yield {
> >          a.toXML
> >       }
> >       a
> >     }
>
> > }
>
> > obviously the yield into the definition of showArticles method break
> > the cycle to the first one.
>
> > Could you suggest me what I can do? I am evaluating lift and scala
> > just in a while.
> > Thanks for your attention.
> > w.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~--~~~~--~~--~--~---



[Lift] How to create an rss?

2009-10-23 Thread wibblecp

hi guys,
I'm looking for a way to generate an rss feed with lift, I'm working
on something like this (from lift-book):

object OwnRssFeed extends XMLApiHelper {
  def dispatch: LiftRules.DispatchPF = {
case Req("rss" ::   Nil, "", GetRequest) => () => showArticles()
case Req("rss" :: _ :: Nil, "",  _) => failure _
  }


def failure() : LiftResponse = {
  val ret: Box[NodeSeq] = Full()
  NotFoundResponse()
}

def createTag(in: NodeSeq) = {
  println("[CreateTag] " + in)
  
  
  title
  http://example.org
  Example.org
  en-us

  Lift WebFramework
  {in}
  
  
}


def showArticles(): LiftResponse = {
  val a: Box[NodeSeq] = for(a <- Article.find(By
(Article.published, true))) yield {
 a.toXML
  }
  a
}
}

obviously the yield into the definition of showArticles method break
the cycle to the first one.

Could you suggest me what I can do? I am evaluating lift and scala
just in a while.
Thanks for your attention.
w.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~--~~~~--~~--~--~---



[Lift] Re: Newbie question: action beforeSave data

2009-10-22 Thread wibblecp

Ok, I am sorry for my previous rubbish

I solved the issue using vars in my Snippet and passing them to my
Post instance to validate and save.

regards,
wibble

On 22 Ott, 14:26, wibblecp  wrote:
> Hi all,
> this is my first post, but I read you always, so I apologize if it
> appear so simple. I am "tasting" this sensational web framework.
>
> I'll try to explain using a simple and basic example.
>
> Consider a "post" mapper model with a mappedString object named
> "permalink"
> I'd like to set this db field with something like this (defined in my
> snippet)
>
> 
> private def set_permalink(input : String) = {
>         val pattern1 = """\s+""".r
>         val pattern2 = """/[^a-zA-Z0-9_]+/""".r
>         pattern1 replaceAllIn(pattern2 replaceAllIn(input.toLowerCase,
> ""), "-")
>     }
> 
>
> My snippet look like this
>
> 
> class ArticleSnippet extends StatefulSnippet{
>
> 
>
>   var _permalink = S.param("title").map(_.toString) openOr "welcome"
>
>   def add(form: NodeSeq) : NodeSeq = {
>     
>
>      /** I am in wrong here **/
>     val article = Article.create.owner(User.currentUser)
>                         
> .created_at(entryDate).permalink(set_permalink(_permalink))
>
>     .
>
>     def doBind(form: NodeSeq) =
>       bind("article", form,
>            "title" -> post.title.toForm,
>            
>            
>            "submit" -> submit("Save", )
>       )
>
>     
>
>     }
>
> }
>
> 
>
> My saved posts always have "welcome" as value for permalink field.
>
> Could anyone give me any suggestion about it? I appreciate a lot this
> group.
> Thanks in adavce for your replies.
> Regards,
> Wibble

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~--~~~~--~~--~--~---



[Lift] Newbie question: action beforeSave data

2009-10-22 Thread wibblecp

Hi all,
this is my first post, but I read you always, so I apologize if it
appear so simple. I am "tasting" this sensational web framework.

I'll try to explain using a simple and basic example.

Consider a "post" mapper model with a mappedString object named
"permalink"
I'd like to set this db field with something like this (defined in my
snippet)


private def set_permalink(input : String) = {
val pattern1 = """\s+""".r
val pattern2 = """/[^a-zA-Z0-9_]+/""".r
pattern1 replaceAllIn(pattern2 replaceAllIn(input.toLowerCase,
""), "-")
}



My snippet look like this


class ArticleSnippet extends StatefulSnippet{



  var _permalink = S.param("title").map(_.toString) openOr "welcome"

  def add(form: NodeSeq) : NodeSeq = {


 /** I am in wrong here **/
val article = Article.create.owner(User.currentUser)

.created_at(entryDate).permalink(set_permalink(_permalink))

.

def doBind(form: NodeSeq) =
  bind("article", form,
   "title" -> post.title.toForm,
   
   
   "submit" -> submit("Save", )
  )



}


}


My saved posts always have "welcome" as value for permalink field.

Could anyone give me any suggestion about it? I appreciate a lot this
group.
Thanks in adavce for your replies.
Regards,
Wibble


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~--~~~~--~~--~--~---