| 例: 単純な RecordForm | |
![]() | |
{let people:RecordSet =
{RecordSet
{RecordFields
{RecordField "First", domain = String},
{RecordField "Last", domain = String},
{RecordField "Age", domain = int}
},
{RecordData First = "John", Last = "Smith", Age = 25},
{RecordData First = "Jane", Last = "Smith", Age = 29},
{RecordData First = "Jane", Last = "Jones", Age = 28}
}
}
{let rf:RecordForm =
{RecordForm
record-source = people,
{VBox
{TextDisplay {bind value to "First" }},
{TextDisplay {bind value to "Last"}},
{TextDisplay {bind value to "Age"}}
}
}
}
{value rf}
|
| 例: RecordForm のデータの追加と変更 | |
![]() | |
{let people:RecordSet =
{RecordSet
{RecordFields
{RecordField "First", domain = String},
{RecordField "Last", domain = String},
{RecordField "Age", domain = int}
},
{RecordData First = "John", Last = "Smith", Age = 25},
{RecordData First = "Jane", Last = "Smith", Age = 29},
{RecordData First = "Jane", Last = "Jones", Age = 28}
}
}
{let rf:RecordForm =
{RecordForm
record-source = people,
{on crc:CurrentRecordChangeRequest at rf:RecordForm do
{if-non-null {rf.update} then
{if {popup-question
{message
There were one or more errors on this form.
Continue to new record and lose changes?
}
} == Dialog.no
then
{crc.consume}
}
}
},
{Table
{row-prototype "First Name:",
{TextField {bind value to "First"}}},
{row-prototype "Last Name:",
{TextField {bind value to "Last"}}},
{row-prototype "Age:",
{TextField {bind value to "Age"}}}
}
}
}
{value
{VBox
rf,
{HBox
{CommandButton
width = 3.25cm, label = "append record",
{on Action do
{people.append {RecordData}}
}
},
{CommandButton
width = 3.25cm, label = "update record",
{on ac:Action do
{if-non-null {rf.update} then
{if {popup-question
{message
There were one or more errors on this form.
Continue?
}
} == Dialog.no
then
{ac.consume}
}
}
}
},
{CommandButton
width = 3.25cm, label = "commit changes",
bound-command = {rf.get-command "commit"}
},
{CommandButton
width = 3.25cm, label = "revert records",
bound-command = {rf.get-command "revert"}
}
}
}
}
|
| 例: 電子メール アドレスの解析 | |
![]() | |
{let people:RecordSet =
{RecordSet
{RecordFields
{RecordField "First", domain = String},
{RecordField "Last", domain = String},
{RecordField "Email", domain = String}
},
{RecordData First = "John", Last = "Smith",
Email = "johnsmith@smith.com"},
{RecordData First = "Jane", Last = "Smith",
Email = "janesmith@smith.com"},
{RecordData First = "Jane", Last = "Jones",
Email = "janejones@jones.com"}
}
}
{let rf:RecordForm =
{RecordForm
record-source = people,
{on crc:CurrentRecordChangeRequest at rf:RecordForm do
let err:any = {rf.update}
{if-non-null err then
{if {popup-question err.value} == Dialog.no
then {crc.consume}
}
}
},
{Table
{row-prototype "First Name:",
{TextField
{bind value to "First",
{parse str:String as{str.to-upper-clone}}
}
}
},
{row-prototype "Last Name:",
{TextField
{bind value to "Last",
{parse str:String as{str.to-upper-clone}}
}
}
},
{row-prototype "Email:",
{TextField
{bind value to "Email",
{parse str:String as
{if {str.find '@'} == -1 then
{DataBindingValidationFailure
"Doesn't look like an email address. Continue?"}
else str}
}
}
}
}
}
}
}
{value
{VBox
rf,
{HBox
{CommandButton
width = 3.25cm, label = "append record",
{on Action do
{people.append {RecordData}}
}
},
{CommandButton
width = 3.25cm, label = "update record",
{on ac:Action do
let err:any = {rf.update}
{if-non-null err then
{if {popup-question err.value} == Dialog.no
then {ac.consume}
}
}
}
},
{CommandButton
width = 3.25cm, label = "commit changes",
bound-command = {rf.get-command "commit"}
},
{CommandButton
width = 3.25cm, label = "revert records",
bound-command = {rf.get-command "revert"}
}
}
}
}
|
| 例: 画像 URL のフォーマット | |
![]() | |
{let maritime-signal-flags:RecordSet =
{evaluate
{url "../../default/support/flag-data.scurl"}
}
}
{let rv:RecordView =
{RecordView
maritime-signal-flags,
sort = "letter"
}
}
{value
{RecordForm
record-source = rv,
{VBox
{TextDisplay
{bind value to "letter"}
},
{TextDisplay
{bind value to "phonetic"}
},
{Frame
height = 42px,
width = 53px,
{bind background to "flag",
{format data:String as
{if data != "" then
{url data}
else
DataBinding.unset
}
}
}
}
}
}
}
|
| 例: RecordForm の RichTextString のバインド | |
![]() | |
{let messages:RecordSet =
{RecordSet
{RecordFields
{RecordField "Recipient", domain = String},
{RecordField "Message", domain = #any}
},
{RecordData Recipient = "Recipient",
Message = {RichTextString.from-string "Message"}}
}
}
{let rf:RecordForm =
{RecordForm
record-source = messages,
{VBox
{TextArea {bind value to "Recipient"}},
{RichTextArea
height = 2cm,
{bind value to "Message"}
}
}
}
}
{value
{VBox
rf,
{HBox
{CommandButton
width = 3.25cm, label = "append record",
{on Action do
{messages.append
{RecordData Recipient = "Recipient",
Message = {RichTextString.from-string "Message"}}}
}
},
{CommandButton
width = 3.25cm, label = "update record",
{on ac:Action do
{if-non-null {rf.update} then
{if {popup-question
{message
There were one or more errors on
this form. Continue?
}
} == Dialog.no
then
{ac.consume}
}
}
}
},
{CommandButton
width = 3.25cm, label = "commit changes",
bound-command = {rf.get-command "commit"}
},
{CommandButton
width = 3.25cm, label = "revert records",
bound-command = {rf.get-command "revert"}
}
}
}
}
|
| 例: CurrentRecordChangeRequest の使用 | |
![]() | |
{let rd:RecordData =
{RecordData Recipient = "Recipient",
Message = "Message"
}
}
{let messages:RecordSet =
{RecordSet
{RecordFields
{RecordField "Recipient", domain = String},
{RecordField "Message", domain = #any}
},
rd
}
}
{let rm:bool = false}
{let rf:RecordForm =
{RecordForm
record-source = messages,
{VBox
{TextArea
{bind value to "Recipient"}
},
{TextArea
height = 2cm,
{bind value to "Message"}
}
},
{on e:CurrentRecordChangeRequest at rf:RecordForm do
{if rf.pending-update? then
{if {popup-message
cancel? = true,
"Save changes to this record?"
} == Dialog.ok
then
{rf.update}
else
{e.consume}
}
}
}
}
}
{value
{VBox
rf,
{HBox
{CommandButton
width = 3.25cm, label = "append record",
{on Action do
{messages.append rd}
}
},
{CommandButton
width = 3.25cm, label = "update record",
{on ac:Action do
{if-non-null {rf.update} then
{if {popup-question
{message
There were one or more errors on
this form. Continue?
}
} == Dialog.no
then
{ac.consume}
}
}
}
},
{CommandButton
width = 3.25cm, label = "commit changes",
bound-command = {rf.get-command "commit"}
},
{CommandButton
width = 3.25cm, label = "revert records",
bound-command = {rf.get-command "revert"}
}
}
}
}
|