[REBOL] Re: dynamically set labels and choices in view
From: carl:cybercraft at: 7-Sep-2001 18:28
On 07-Sep-01, Mike wrote:
> I have a layout contained within an object, like this:
> context-spec: [
> name: "Edna Crabapple"
> page-layout: layout [
Remove 'layout (just the word) from the above and...
> size 640x480
> h2 "Test"
> label name
> button "Print Value" [print ["name in
> button action:"
> myview: make object! context-spec
> myview/name: "Homer Simpson"
> print myview/name
> ; will always show "Edna Crabapple" in the label
> view myview/page-layout
...place it after the 'view above.
I think that should work. (My understanding of context is pretty
limited.) As you had it, your layout would've been built when the
myview object was made and so 'name in the layout would've been
pointing to "Edna Crabapple". (Well, I think that's what would've
Hope this helps - is right. (:
> 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.
> 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:
> <Field name="firstName" labelText="First Name"/>
> <Field name="state" labelText="State">
> <Option text="Alabama"/>
> <Option text="Arkansas"/>
> 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.