[REBOL] dynamically set labels and choices in view
From: mgh520::yahoo::com at: 6-Sep-2001 21:49
I have a layout contained within an object, like this:
REBOL[]
context-spec: [
name: "Edna Crabapple"
page-layout: layout [
size 640x480
below
h2 "Test"
return
label name
button "Print Value" [print ["name in
button action:"
name]]
]
]
myview: make object! context-spec
myview/name: "Homer Simpson"
print myview/name
; will always show "Edna Crabapple" in the label
view myview/page-layout
My original problem was with the action of the button
always printing "Edna Crabapple", but that was
resolved (thanks to help from this list) by creating a
context-spec to make the object from.
But now the problem is the label. The label will
always get displayed as "Edna Crabapple" because the
value is determined the first time the layout block is
evaluated and then never again. So even though I
change the name variable, I can't get that name to
display the first time I "view myview/page-layout".
What I want is to have labels and the options of a
choice field populated from the "outside" of myview
rather than hard coded in there. Any ideas or
suggestions would be appreciated.
mike
p.s. extra detail:
what I really have here is a layout with many choice
fields, each with a label and several options. So I
retrieve xml from a server, where the xml contains
something like:
<Fields>
<Field name="firstName" labelText="First Name"/>
<Field name="state" labelText="State">
<Option text="Alabama"/>
<Option text="Arkansas"/>
...
</Field>
</Fields>
Then this xml will be used to set the labels and
options for the layout. But my problem is the values
for those things are set in stone once REBOL evaluates
the layout block.