Message from discussion
Screen-specific function before nextScreen in Wizard
Received: by 10.204.149.65 with SMTP id s1mr5861412bkv.3.1351440209301;
Sun, 28 Oct 2012 09:03:29 -0700 (PDT)
X-BeenThere: liftweb@googlegroups.com
Received: by 10.204.131.72 with SMTP id w8ls5851104bks.3.gmail; Sun, 28 Oct
2012 09:03:21 -0700 (PDT)
Received: by 10.204.148.22 with SMTP id n22mr5860067bkv.0.1351440201647;
Sun, 28 Oct 2012 09:03:21 -0700 (PDT)
Received: by 10.204.148.22 with SMTP id n22mr5860066bkv.0.1351440201611;
Sun, 28 Oct 2012 09:03:21 -0700 (PDT)
Return-Path: <jonas.vauthe...@gmail.com>
Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46])
by gmr-mx.google.com with ESMTPS id v13si722656bkw.0.2012.10.28.09.03.21
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 28 Oct 2012 09:03:21 -0700 (PDT)
Received-SPF: pass (google.com: domain of jonas.vauthe...@gmail.com designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jonas.vauthe...@gmail.com designates 209.85.215.46 as permitted sender) smtp.mail=jonas.vauthe...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-la0-f46.google.com with SMTP id h6so3812154lag.5
for <liftweb@googlegroups.com>; Sun, 28 Oct 2012 09:03:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:sender:in-reply-to:references:date
:x-google-sender-auth:message-id:subject:from:to:content-type;
bh=hXFsUeks+b5Kzr9bQ0zo6jmYmfbQfh6Vz0VhRLimgbY=;
b=MmrYvEoIJmXKaX8eB/a72rfwvC4Cs6h6l0LSj9arF/UKo8EhWMCI51YSlWw6ZxE30D
nW+HlNMXXncd/BJDNEzxYOUbsMyh/ihhYMp9C7PCtEE6NkbBJDstkkoRdaX1wNmYvu+f
+FatoDvB/Sp84wBKMjxTqv2WTBNFI736kroDXmErO+GFtNDl7y0UbdJMll9bQd2v2Nj/
a1SgZuhB5Zlsw7oakcFVE+ojn1mQhX100Z9EnTu1S9KmKxu7xeqNPrRoefu7gFZiY409
u3MIRZmi1SaWhafBR4YZ9gbLlWyWmgiWW0tW7CDJ3PKzFBweR77dZxmPef3gCDBtualU
iCrw==
MIME-Version: 1.0
Received: by 10.112.42.41 with SMTP id k9mr10770342lbl.126.1351440200945; Sun,
28 Oct 2012 09:03:20 -0700 (PDT)
Sender: jonas.vauthe...@gmail.com
Received: by 10.114.63.109 with HTTP; Sun, 28 Oct 2012 09:03:20 -0700 (PDT)
In-Reply-To: <CAEyb4nHDV48C8DvERP2QuXzE5EdzrW86MjPnrK6AW-fXK1v...@mail.gmail.com>
References: <CAEyb4nHUMO0YJQTcL3Ex-uf+QkrZNviF_uNJU1YMEpPn=0C...@mail.gmail.com>
<CAH6e9Lj5CLx1T1PsAN5ktcc+nPoYMvSmZm8TDhM8Jxikffi...@mail.gmail.com>
<CAEyb4nG4b67ob4OEwBaROzs5CAw7AFf-s1wvaZCKNaSzD4i...@mail.gmail.com>
<CAEyb4nEi=1U=XUN1NP_L6+no_JDrJg2ON0nWNBZJwTqftL5...@mail.gmail.com>
<CAEyb4nHDV48C8DvERP2QuXzE5EdzrW86MjPnrK6AW-fXK1v...@mail.gmail.com>
Date: Sun, 28 Oct 2012 17:03:20 +0100
Message-ID: <CAEyb4nHVfCtw+pujJ9ftwNitcMv92X01_NBUSu9UUNKNOcj...@mail.gmail.com>
Subject: Re: [Lift] Screen-specific function before nextScreen in Wizard
From: Jones <mistic.warr...@gmail.com>
To: liftweb@googlegroups.com
Content-Type: multipart/alternative; boundary=e0cb4efe33a41ccf5304cd20b18f
--e0cb4efe33a41ccf5304cd20b18f
Content-Type: text/plain; charset=ISO-8859-1
I read the implementation of wizard and eventually found some elements.
One can override those functions: transitionIntoFrom(from: Box[Screen]),
transitionOutOfTo(to: Box[Screen]), localSetup().
*When "Next" is pressed, localSetup() of the next screen is called first,
then transitionOutOfTo, then transitionIntoFrom.*
Sorry for the inconvenience then, I missed it in the API documentation (if
we don't "open" the full description of the transitionX functions, they
only speak about notifications and it was not clear to me).
I still could not lock a field (editable_? = false is simply ignored) and
my integration of Autocomplete doesn't work with the screens (it is simply
ignored by the wizard actually).
Anyway, sorry for all those questions
On Sun, Oct 28, 2012 at 2:32 PM, Jones <mistic.warr...@gmail.com> wrote:
> Okay, two things here. First of all, *I still cannot find a function that
> is called when "Next" is pressed. *
>
> Second, I realized that I could access a field in "override def
> nextScreen". Say I had an Int field called "age", I could do:
>
>
>> override def nextScreen = if (age.is < 18) parentsScreen else petScreen
>
>
> But in my example my customer_field customized field cannot be accessed
> with customer_field.is. Probably because of the autocomplete widget? Does
> anybody know how I could deal with this?
>
> Thanks for your help!
> Jones
>
> PS: moreover, even if I set "override def editable_? = false", my fields
> always are editable...
>
> On Sat, Oct 27, 2012 at 2:50 PM, Jones <mistic.warr...@gmail.com> wrote:
>
>> Hello,
>>
>> sorry to come back on this, but I still cannot find a solution. Here is
>> my code:
>>
>> object addEntryWizard extends Wizard {
>>> object complete extends WizardVar(false)
>>> val prodScreen = new Screen {
>>> object prod extends WizardVar(Product.find(1) openOr Product.create)
>>> addFields(() => prod.name)
>>> val customers = Customer.findAll.map(_.name.is) // TODO: more
>>> intelligent autocomplete...
>>>
>>>
>>> val customer_field = new Field {
>>> type ValueType = String
>>> override def name = "Customer"
>>> override implicit def manifest = buildIt[String]
>>> override def default = ""
>>> override def toForm: Box[NodeSeq] = AutoComplete("",
>>> (current:String, limit:Int) =>
>>> customers.filter(_.toLowerCase.startsWith(current.toLowerCase)), x =>
>>> println("done" + x))
>>> }
>>> override def nextScreen = {
>>> Customer.find(By(Customer.name, "test")) match {
>>> case Empty => println("empty")
>>> case Full(_) => println("full")
>>> }
>>> customerScreen
>>> }
>>> override def finish() {
>>> }
>>> }
>>
>>
>> The idea here is that before going to the next screen
>> ("customerScreen"), I would like to check if what the user has entered in
>> the form is already existing in the database or not. If it is not, then the
>> user needs to enter it and therefore the screen "customerScreen" will be
>> required. But if it already exists in the database, I don't want to go to
>> this screen.
>>
>> How can I achieve this? I cannot find a function that is executed after
>> the user has clicked on next but before the next screen...
>>
>> Sorry for the inconvenience and thanks for your help!
>> Jones
>>
>> On Thu, Oct 25, 2012 at 6:45 PM, Jones <mistic.warr...@gmail.com> wrote:
>>
>>> Yes, there is. But from my observations, I believe it is not called
>>> before the end of the wizard, is it? What if I want to save something in
>>> the database between Screen1 and Screen2?
>>>
>>> Thanks for your help,
>>> Jones
>>>
>>>
>>> On Thu, Oct 25, 2012 at 5:56 PM, David Pollak <
>>> feeder.of.the.be...@gmail.com> wrote:
>>>
>>>> THere's a finish() method on each screen as well.
>>>>
>>>> On Thu, Oct 25, 2012 at 8:52 AM, Jones <mistic.warr...@gmail.com>wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I am using persistence in a Wizard, and I am editing a specific entity
>>>>> "Entity1" in a screen "Screen1". Before going to "Screen2", I would like to
>>>>> call "Entity1.save()" (I am using Mapper). But postFinish() and finish()
>>>>> both are executed at the end of the main wizard. How can I bind a function
>>>>> to the end of a chosen screen?
>>>>>
>>>>> Thanks in advance,
>>>>> Jones
>>>>>
>>>>> --
>>>>> --
>>>>> Lift, the simply functional web framework: http://liftweb.net
>>>>> Code: http://github.com/lift
>>>>> Discussion: http://groups.google.com/group/liftweb
>>>>> Stuck? Help us help you:
>>>>> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Telegram, Simply Beautiful CMS https://telegr.am
>>>> Lift, the simply functional web framework http://liftweb.net
>>>> Follow me: http://twitter.com/dpp
>>>> Blog: http://goodstuff.im
>>>>
>>>>
>>>> --
>>>> --
>>>> Lift, the simply functional web framework: http://liftweb.net
>>>> Code: http://github.com/lift
>>>> Discussion: http://groups.google.com/group/liftweb
>>>> Stuck? Help us help you:
>>>> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
--e0cb4efe33a41ccf5304cd20b18f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I read the implementation of wizard and eventually found some elements.=A0<=
div><br></div><div>One can override those functions: transitionIntoFrom(fro=
m: Box[Screen]), transitionOutOfTo(to: Box[Screen]), localSetup().=A0</div>=
<div>
<br></div><div><b>When "Next" is pressed, localSetup() of the nex=
t screen is called first, then transitionOutOfTo, then transitionIntoFrom.<=
/b>=A0</div><div><br></div><div>Sorry for the inconvenience then, I missed =
it in the API documentation (if we don't "open" the full desc=
ription of the transitionX functions, they only speak about notifications a=
nd it was not clear to me).</div>
<div><br></div><div>I still could not lock a field (editable_? =3D false is=
simply ignored) and my integration of Autocomplete doesn't work with t=
he screens (it is simply ignored by the wizard actually).=A0</div><div><br>
</div><div>Anyway, sorry for all those questions</div>
<div><br><br><div class=3D"gmail_quote">On Sun, Oct 28, 2012 at 2:32 PM, Jo=
nes <span dir=3D"ltr"><<a href=3D"mailto:mistic.warr...@gmail.com" targe=
t=3D"_blank">mistic.warr...@gmail.com</a>></span> wrote:<br><blockquote =
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid=
;padding-left:1ex">
Okay, two things here. First of all, <b>I still cannot find a function that=
is called when "Next" is pressed.=A0</b><div><br></div><div>Seco=
nd, I realized that I could access a field in "override def nextScreen=
". Say I had an Int field called "age", I could do:</div>
<div><div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border=
-left-style:solid;padding-left:1ex">override def nextScreen =3D if (<a href=
=3D"http://age.is" target=3D"_blank">age.is</a> < 18) parentsScreen else=
petScreen</blockquote>
<div><br></div><div>But in my example my customer_field customized field ca=
nnot be accessed with <a href=3D"http://customer_field.is" target=3D"_blank=
">customer_field.is</a>. Probably because of the autocomplete widget? Does =
anybody know how I could deal with this?=A0</div>
<div><br></div><div>Thanks for your help!</div><span><font color=3D"#888888=
"><div>Jones</div></font></span><div><br></div><div>PS: moreover, even if I=
set "override def editable_? =3D false", my fields always are ed=
itable...</div>
<div><div><br><div class=3D"gmail_quote">
On Sat, Oct 27, 2012 at 2:50 PM, Jones <span dir=3D"ltr"><<a href=3D"mai=
lto:mistic.warr...@gmail.com" target=3D"_blank">mistic.warr...@gmail.com</a=
>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,=A0<div><br></div><div>sorry to come back on this, but I still cannot=
find a solution. Here is my code:</div><div><br></div><div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;=
border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex=
">
object addEntryWizard extends Wizard {<br>=A0 object complete extends Wizar=
dVar(false)<br>=A0 val prodScreen =3D new Screen {<br>=A0 =A0 object prod e=
xtends WizardVar(Product.find(1) openOr Product.create)<br>=A0 =A0 addField=
s(() =3D> <a href=3D"http://prod.name" target=3D"_blank">prod.name</a>)<=
br>
=A0 =A0 val customers =3D Customer.findAll.map(_.<a href=3D"http://name.is"=
target=3D"_blank">name.is</a>) // TODO: more intelligent autocomplete... =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <br>
=A0<br>
=A0 =A0 val customer_field =3D new Field {<br>=A0 =A0 =A0 type ValueType =
=3D String<br>=A0 =A0 =A0 override def name =3D "Customer"<br>=A0=
=A0 =A0 override implicit def manifest =3D buildIt[String]<br>=A0 =A0 =A0 =
override def default =3D ""<br>
=A0 =A0 =A0 override def toForm: Box[NodeSeq] =3D AutoComplete(""=
, (current:String, limit:Int) =3D> customers.filter(_.toLowerCase.starts=
With(current.toLowerCase)), x =3D> println("done" + x))<br>=A0=
=A0 }<br>=A0 =A0 override def nextScreen =3D {<br>
=A0 =A0 =A0 Customer.find(By(Customer.name, "test")) match {<br>=
=A0 =A0 =A0 =A0 case Empty =3D> println("empty")<br>=A0 =A0 =
=A0 =A0 case Full(_) =3D> println("full")<br>=A0 =A0 =A0 }<br>=
=A0 =A0 =A0 customerScreen<br>=A0 =A0 }<br>
=A0 =A0 override def finish() {<br>=A0 =A0 }<br>=A0 }</blockquote><div><br>=
</div><div>=A0The idea here is that before going to the next screen ("=
customerScreen"), I would like to check if what the user has entered i=
n the form is already existing in the database or not. If it is not, then t=
he user needs to enter it and therefore the screen "customerScreen&quo=
t; will be required. But if it already exists in the database, I don't =
want to go to this screen.</div>
<div><br></div><div>How can I achieve this? I cannot find a function that i=
s executed after the user has clicked on next but before the next screen...=
</div><div><br></div><div>Sorry for the inconvenience and thanks for your h=
elp!</div>
<span><font color=3D"#888888">
<div>Jones</div></font></span><div><div><br><div class=3D"gmail_quote">On T=
hu, Oct 25, 2012 at 6:45 PM, Jones <span dir=3D"ltr"><<a href=3D"mailto:=
mistic.warr...@gmail.com" target=3D"_blank">mistic.warr...@gmail.com</a>>=
;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Yes, there is. But from my observations, I believe it is not called before =
the end of the wizard, is it? What if I want to save something in the datab=
ase between Screen1 and Screen2?=A0<div><br></div><div>Thanks for your help=
,=A0</div>
<span><font color=3D"#888888">
</font></span><div><span><font color=3D"#888888">Jones</font></span><div><d=
iv><br><div><br><div class=3D"gmail_quote">On Thu, Oct 25, 2012 at 5:56 PM,=
David Pollak <span dir=3D"ltr"><<a href=3D"mailto:feeder.of.the.bears@g=
mail.com" target=3D"_blank">feeder.of.the.be...@gmail.com</a>></span> wr=
ote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">THere's a finish() method on each screen=
as well.<br><br><div class=3D"gmail_quote"><div><div>On Thu, Oct 25, 2012 =
at 8:52 AM, Jones <span dir=3D"ltr"><<a href=3D"mailto:mistic.warrior@gm=
ail.com" target=3D"_blank">mistic.warr...@gmail.com</a>></span> wrote:<b=
r>
</div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div><div>Hello,<div><br></div><=
div>I am using persistence in a Wizard, and I am editing a specific entity =
"Entity1" in a screen "Screen1". Before going to "=
Screen2", I would like to call "Entity1.save()" (I am using =
Mapper). But postFinish() and finish() both are executed at the end of the =
main wizard. How can I bind a function to the end of a chosen screen?</div>
<div><br></div><div>Thanks in advance,=A0</div><div>Jones</div></div></div>=
<span><font color=3D"#888888">
<p></p>
-- <br>
-- <br>
Lift, the simply functional web framework: <a href=3D"http://liftweb.net" t=
arget=3D"_blank">http://liftweb.net</a><br>
Code: <a href=3D"http://github.com/lift" target=3D"_blank">http://github.co=
m/lift</a><br>
Discussion: <a href=3D"http://groups.google.com/group/liftweb" target=3D"_b=
lank">http://groups.google.com/group/liftweb</a><br>
Stuck? Help us help you: <a href=3D"https://www.assembla.com/wiki/show/lift=
web/Posting_example_code" target=3D"_blank">https://www.assembla.com/wiki/s=
how/liftweb/Posting_example_code</a><br>
=A0<br>
=A0<br>
=A0<br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r><div>Telegram, Simply Beautiful CMS <a href=3D"https://telegr.am" target=
=3D"_blank">https://telegr.am</a></div>Lift, the simply functional web fram=
ework <a href=3D"http://liftweb.net" target=3D"_blank">http://liftweb.net</=
a><div>
Follow me: <a href=3D"http://twitter.com/dpp" target=3D"_blank">http://twit=
ter.com/dpp</a><br>Blog: <a href=3D"http://goodstuff.im" target=3D"_blank">=
http://goodstuff.im</a><span><font color=3D"#888888"><br></font></span></di=
v>
<span><font color=3D"#888888"><div><br></div><br>
<p></p>
-- <br>
-- <br>
Lift, the simply functional web framework: <a href=3D"http://liftweb.net" t=
arget=3D"_blank">http://liftweb.net</a><br>
Code: <a href=3D"http://github.com/lift" target=3D"_blank">http://github.co=
m/lift</a><br>
Discussion: <a href=3D"http://groups.google.com/group/liftweb" target=3D"_b=
lank">http://groups.google.com/group/liftweb</a><br>
Stuck? Help us help you: <a href=3D"https://www.assembla.com/wiki/show/lift=
web/Posting_example_code" target=3D"_blank">https://www.assembla.com/wiki/s=
how/liftweb/Posting_example_code</a><br>
=A0<br>
=A0<br>
=A0<br>
</font></span></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>
--e0cb4efe33a41ccf5304cd20b18f--