20090522 Scalaユーザー会#1
- 28. •
<p><lift:helloWorld.howdy
/></p>
class
HelloWorld
{
def
howdy
=
<span>Welcome
to
helloworld
at
{new
_root_.java.util.Date}</span>
}
2009 5 22
- 32. •
<p>
<lift:helloWorld.howdy
/>
</p>
2009 5 22
- 33. •
class
HelloWorld
{
def
howdy
=
<span>
Welcome
to
helloworld
at
{new
_root_.java.util.Date}
</span>
}
2009 5 22
- 34. •
<lift:SampleSnipet.add
form=quot;POSTquot;>
<entry:description
/>
<entry:amount
/>
<br
/>
<entry:submit
/>
</lift:
SampleSnipet.add
>
2009 5 22
- 35. •
class
SampleSnipet
def
add
(xhtml
:
NodeSeq)
:
NodeSeq
=
{
var
desc
=
quot;quot;
var
amount
=
quot;0quot;
def
processEntryAdd
()
{
...
}
bind(quot;entryquot;,
xhtml,
quot;descriptionquot;
->
SHtml.text(desc,
desc
=
_),
quot;amountquot;
->
SHtml.text(amount,
amount
=
_),
quot;submitquot;
->
SHtml.submit(Add,
processEntryAdd))
}
}
2009 5 22
- 38. •
‣
‣
‣
•
‣
‣
‣
2009 5 22
- 39. •
class
Expense
extends
LongKeyedMapper[Expense]
with
IdPK
{
def
getSingleton
=
Expense
object
dateOf
extends
MappedDateTime(this)
object
description
extends
MappedString(this,100)
object
amount
extends
MappedDecimal(this,
MathContext.DECIMAL64,
2)
object
account
extends
MappedLongForeignKey(this,
Account)
}
2009 5 22
- 40. •
object
Expense
extends
Expense
with
LongKeyedMetaMapper[Expense]
{
override
def
fieldOrder
=
List(dateOf,
description,
amount)
}
2009 5 22
- 41. •
val
myEntries1
=
Expense.findAll
val
myEntries2
=
Expense.findAll(By_>(Expense.amout,5)
)
val
recentEntries
=
Expense.findAll(
BySql(quot;dateOf
>
(CURRENT_DATE
-
interval
’30
days’)quot;,
IHaveValidatedThisSQL(quot;dchenbeckerquot;,quot;2008-12-03quot;))
2009 5 22
- 42. •
var
myEntr=
Expense.create
myEntry.dateOf(new
Date).description(quot;A
sample
entryquot;)
myEntry.amount(BigDecimal(quot;127.20quot;))
myEntry.save
myEntry.delete
2009 5 22