I think this particular use case is very interesting.  There should be a
flexible (LiftRules or in the Msgs snippet) mechanism for making this
behavior flexible... doing it for all users, doing it on a user-by-user
basis.

Please open a ticket at http://github.com/dpp/liftweb/issues referencing
this thread and we'll add the feature.

Thanks!

On Wed, Dec 9, 2009 at 4:56 AM, Xuefeng Wu <ben...@gmail.com> wrote:

> It's not make sense for my project.
> I separate business  transaction from UI logic.
> When create or update business model will occur notice or error,
> and then do something for UI by the business transaction
>
> for example:
> business:
> def MyBusinessTransaction(v: String) : Option[MyModel] = {
>       val myModel = MyModel.create.title(v)
>       myModel.validate match {
>           case Nil => {myModel.save();Some(myModel)}
>           case xs => {S.error(xs);None}
>       }
> }
>
>
> Snippet
> def doSomething(): JsCmd = MyBusinessTransaction(v) match {
>     case Some(v) => //do something for UI, such as replace the old value
>     case None => //notice what's wrong. *I could code ** fadeOutErrors(5
> seconds, 1 second) if want, but should I code every where?*
> }
>
>
> Or there're any other practice for separate business from UI?
>
>
> On Wed, Dec 9, 2009 at 7:45 PM, Philippe Monnaie <
> philippe.monn...@gmail.com> wrote:
>
>> You could try:
>>
>> object Config{
>>  def error(xs) = {
>>     S.error(xs)
>>    fadeOutErrors(5 seconds, 1 second)
>>  }
>> }
>>
>> and call Config.error(xs) instead of S.error(xs)
>>
>> or something similar. I'm sure someone can come up with a more elegant
>> solution than this. Just the first thing that popped into my head.
>>
>> - Philippe
>>
>> On Tue, Dec 8, 2009 at 2:26 PM, Xuefeng Wu <ben...@gmail.com> wrote:
>> > I think It's better I could configure it, but not code every where.
>> > On Tue, Dec 8, 2009 at 9:23 PM, Marius <marius.dan...@gmail.com> wrote:
>> >>
>> >> Yes you need to send down fadeOut... call
>> >>
>> >> def myFunc: JsCmd = {
>> >>  // do some DB stuff
>> >>  vmyMapper.validate match {
>> >>    case Nil => Noop
>> >>    case xs => S.error(xs); fadeOutErrors(5 seconds, 1 second)
>> >>  }
>> >>
>> >> }
>> >> On Dec 8, 3:01 pm, Xuefeng Wu <ben...@gmail.com> wrote:
>> >> > Yes, I do something like
>> >> >  // do the DB stuff
>> >> >  vmyMapper.validate match {
>> >> >    case Nil =>
>> >> >    case xs => S.error(xs)
>> >> > }
>> >> >
>> >> > But I should always add fadeOutErrors(5 seconds, 1 second)?
>> >> >
>> >> > I want lift highlight every error/notice information.
>> >> >
>> >> >
>> >> >
>> >> > On Tue, Dec 8, 2009 at 5:56 PM, Marius <marius.dan...@gmail.com>
>> wrote:
>> >> > > Are you using field validate into an Ajax context or not? If not
>> using
>> >> > > something like:
>> >> >
>> >> > > def howdy = {
>> >> > >    S.error("howdy error")
>> >> > >    <span>Hello there</span> ++
>> >> > >    <head>{Script(OnLoad(fadeOutErrors(5 seconds, 1 second)))}
>> >> > >    </head>
>> >> > >  }
>> >> >
>> >> > > from your snippet should be ok.
>> >> >
>> >> > > If you are using validate from an Ajax invocation, then you just
>> need
>> >> > > to return fadeOutErrors(5 seconds, 1 second) from your Ajax
>> function.
>> >> >
>> >> > > So I guess your ajax function would looks something like:
>> >> >
>> >> > > def myDBAjax: JsCmd = {
>> >> >
>> >> > >  // do the DB stuff
>> >> > >  val errors = myMapper.validate
>> >> > >  S.error(errors)
>> >> > >   fadeOutErrors(5 seconds, 1 second)
>> >> > > }
>> >> >
>> >> > > Br's,
>> >> > > Marius
>> >> >
>> >> > > On Dec 8, 10:53 am, Xuefeng Wu <ben...@gmail.com> wrote:
>> >> > > > But I use field validate, the notice and error are wrap by lift.
>> >> > > > Should I
>> >> > > > append fadeOutErrors(5 seconds, 1 second)?
>> >> >
>> >> > > > On Tue, Dec 8, 2009 at 4:50 PM, Marius <marius.dan...@gmail.com>
>> >> > > > wrote:
>> >> > > > > You don't need to configure anything in boot.
>> >> >
>> >> > > > > Assume this is an Ajax function:
>> >> >
>> >> > > > >  def howdy: JsCmd = {
>> >> > > > >    S.error("howdy error")
>> >> > > > >    fadeOutErrors(5 seconds, 1 second)
>> >> > > > >  }
>> >> >
>> >> > > > >  ... in your snippet you can say:
>> >> >
>> >> > > > >  SHtml.a(Text("Click me")(howdy _)
>> >> >
>> >> > > > >  If you want to fade out errors in a page and not via Ajax you
>> can
>> >> > > > > use this:
>> >> >
>> >> > > > >  def howdy = {
>> >> > > > >    S.error("howdy error")
>> >> > > > >    <span>Hello there</span> ++
>> >> > > > >    <head>{Script(OnLoad(fadeOutErrors(5 seconds, 1 second)))}
>> >> > > > >    </head>
>> >> > > > >  }
>> >> >
>> >> > > > >  which basically says after the page is rendered that after 5
>> >> > > > > seconds
>> >> > > > > the error notices will be faded out.
>> >> >
>> >> > > > > Br's,
>> >> > > > > Marius
>> >> >
>> >> > > > > On Dec 8, 9:50 am, Xuefeng Wu <ben...@gmail.com> wrote:
>> >> > > > > > Yes, it's my wanted.
>> >> > > > > > How could I configure it at boot?
>> >> >
>> >> > > > > > On Tue, Dec 8, 2009 at 3:44 PM, Marius <
>> marius.dan...@gmail.com>
>> >> > > wrote:
>> >> > > > > > > Please see this:
>> >> >
>> >> > >
>> http://groups.google.com/group/liftweb/browse_thread/thread/972562da2.
>> >> > > > > ..
>> >> >
>> >> > > > > > > If you are using Ajax, notices could easily fade out.
>> >> >
>> >> > > > > > > Br's,
>> >> > > > > > > Marius
>> >> >
>> >> > > > > > > On Dec 8, 8:02 am, Xuefeng Wu <ben...@gmail.com> wrote:
>> >> > > > > > > > Hi,
>> >> >
>> >> > > > > > > >     I want to highlight the lift notice and it will hide
>> >> > > > > > > > when
>> >> > > > > timeout.
>> >> > > > > > > > Should I code every request or only to config lift some
>> >> > > > > > > > where?
>> >> >
>> >> > > > > > > > For example:
>> >> > > > > > > > When use put items into the shopping cart, highlight the
>> >> > > > > > > > items
>> >> > > some
>> >> > > > > > > seconds
>> >> > > > > > > > to notice the user.
>> >> >
>> >> > > > > > > > --
>> >> > > > > > > > Scala中文社区:  http://groups.google.com/group/scalacn
>> >> >
>> >> > > > > > > --
>> >> >
>> >> > > > > > > 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<liftweb%2bunsubscr...@googlegroups.com>
>> <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
>> >
>> >> > >
>> >> > > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
>> <liftweb%252bunsubscr...@googlegroups.com<liftweb%25252bunsubscr...@googlegroups.com>
>> >
>> >> >
>> >> > > > >
>> >> > > > > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
>> <liftweb%252bunsubscr...@googlegroups.com<liftweb%25252bunsubscr...@googlegroups.com>
>> >
>> >> > >
>> >> > > <liftweb%252bunsubscr...@googlegroups.com<liftweb%25252bunsubscr...@googlegroups.com>
>> <liftweb%25252bunsubscr...@googlegroups.com<liftweb%2525252bunsubscr...@googlegroups.com>
>> >
>> >> >
>> >> > > > > > > .
>> >> > > > > > > For more options, visit this group at
>> >> > > > > > >http://groups.google.com/group/liftweb?hl=en.
>> >> >
>> >> > > > > > --
>> >> > > > > > Scala中文社区:  http://groups.google.com/group/scalacn
>> >> >
>> >> > > > > --
>> >> >
>> >> > > > > 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<liftweb%2bunsubscr...@googlegroups.com>
>> <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
>> >
>> >> > >
>> >> > > <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
>> <liftweb%252bunsubscr...@googlegroups.com<liftweb%25252bunsubscr...@googlegroups.com>
>> >
>> >> >
>> >> > > > > .
>> >> > > > > For more options, visit this group at
>> >> > > > >http://groups.google.com/group/liftweb?hl=en.
>> >> >
>> >> > > > --
>> >> > > > Scala中文社区:  http://groups.google.com/group/scalacn
>> >> >
>> >> > > --
>> >> >
>> >> > > 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<liftweb%2bunsubscr...@googlegroups.com>
>> <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
>> >
>> >> > > .
>> >> > > For more options, visit this group at
>> >> > >http://groups.google.com/group/liftweb?hl=en.
>> >> >
>> >> > --
>> >> > Scala中文社区:  http://groups.google.com/group/scalacn
>> >>
>> >> --
>> >>
>> >> 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<liftweb%2bunsubscr...@googlegroups.com>
>> .
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/liftweb?hl=en.
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Scala中文社区:  http://groups.google.com/group/scalacn
>> >
>> > --
>> >
>> > 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<liftweb%2bunsubscr...@googlegroups.com>
>> .
>> > For more options, visit this group at
>> > http://groups.google.com/group/liftweb?hl=en.
>> >
>>
>> --
>>
>> 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<liftweb%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/liftweb?hl=en.
>>
>>
>>
>
>
> --
> Scala中文社区:  http://groups.google.com/group/scalacn
>
> --
> 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<liftweb%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>



-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

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