[Seaside] Dynamically adding children
Francois Beausoleil
francois.beausoleil at gmail.com
Tue Oct 3 03:13:37 UTC 2006
Hi all !
I'm still learning my way around Smalltalk / Seaside. I have the
regular Address Book application running. I have Name, Address, Phone
and Contact model objects. I have corresponding *Editor classes too.
I can edit objects which already have addresses, and now I'm ready to
tackle adding new addresses from the UI.
A Contact has many Addresses, and Contact sports these methods to access them:
#addresses
#addressAt:
#addressAt:put:
What I want to achieve is on the contact editor form, I want a place
where I can type the name/location of the new address, and after
submitting the form, a new, blank, AddressEditor should be appended to
the general form.
Here is my incomplete solution:
html form: [
html fieldsetWithLegend: 'Contact' do: [
html render: nameEditor.
html divNamed: 'addresses' with: [
html label: 'New address named' input: [
html textInputWithCallback: [:name |
self model addressAt: name put: Address new.
subcomponents add: (self addressEditorFor: (self model addressAt:
name) named: name)].
html submitButton.
addressEditors keysAndValuesDo: [:location :editor |
html divClass: 'address' with: [html render: editor]]]].
html submitButtonWithAction: [self save]]]
I don't even know if it's valid to change subcomponents (which is
returned by #children) while callbacks are being processed. I found a
thread[1] which explained a similar problem, except the OP was doing
it with live updates. I'm not ready for that yet.
Anyway, it's probably something simple, and I'm not finding it. I
must also be using the wrong query in GMail, because I can't find
anything remotely resembling what I want.
Thanks !
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/
[1] http://lists.squeakfoundation.org/pipermail/seaside/2006-July/008377.html
More information about the Seaside
mailing list