[Seaside] Refresh list / combos when another has been selected?

Mariano Martinez Peck marianopeck at gmail.com
Tue Dec 10 16:47:39 UTC 2013

On Tue, Dec 10, 2013 at 7:27 AM, Diego Lont <diego.lont at delware.nl> wrote:

> Hi Mariano,
> A bit longer answer.
Thanks for your detailed answer.

> I added an example to the QC Magritte Demo to show how this can be done. I
> added it to the last demo (form demo).
> There are actual several ways to do this in QC Magritte, but I implemented
> what I think is the most elegant one for this problem.
> First you need to make sure the QC Magritte stuff is used, so in the
> domain object we implement to following 2 methods:
> mementoClass
> ^QCAjaxMemento
> The normal memento is not aware of the class and will not process and
> domain rules, other than validations set in the descriptions. We need to
> update the values of other objects as well, so this allows for influences
> and hidden fields.
> setDefaultsFor: aContainer
> <magritteContainer>
> ^aContainer
>  componentRenderer: QCGroupedFormRenderer;
> componentClass: QCContainerComponent;
> descriptionBuilder: QCDescriptionFlattener;
>  yourself
> This basically overrides the default component class, component renderer
> and adds a description builder.
> The component renderer adds the AJAX stuff. This renderer adds a callback
> to each element of a group, that re renders the group when it is changed.
> Also it allows for groups to be collapsed by the user.

OK, I understand. One problem I have right now is that
QCGroupedFormRenderer and its superclass changes the way things are
rendered, add bootstrap CSS classes etc...Moreover, I have my own subclass
of MATableRenderer where I change a few things. I have #myAsComponent which

^ self magritteDescription
componentRenderer: MyTableRendered "QCGroupedFormRenderer";
  asComponentOn: self

QCGroupedFormRenderer does what I need but also much more. So...do you know
what is the easiest way so that I can reuse the ajax for the groups? I just
need that I can group things and that when one of them is changed, all the
rest of the group are re-rendered. So all #renderEditorOn: html ajaxScript:
aScript are very useful. The key part I think it is this:

| script |
 groupDescriptions ifNil: [ script := self createUpdaterFor: aDescription
id: anId serialize: (childComponent serializeScriptOn: html) ]
 ifNotNil: [ self halt. script := self createUpdaterForList:
groupDescriptions id: anId serialize: (childComponent serializeScriptOn:
html) group: group ].
 childComponent renderContentOn: html ajaxScript: script ]

soo any idea how could I plug that into say MATableRenderer (then I take
care of my subclass)?  I am not sure where I should get the
groupDescriptions from...
I think that having a subclass of MATableRenderer with *ONLY* that ability
would be super awesome.

> The component class makes sure the description builder is used to process
> the description. The description builder you probably don't need, but it
> processes the description, before it is shown, allowing for defaults,
> security and such. The descriptionFlattener is expanding relations to
> groups, allowing to use nested objects. I.E. a person has an address, and
> you want to model this as a different object. But when you edit a person,
> you usually want to be able to change the address, without switching pages.
> If you do not want to use the description builder, setting the component
> renderer will suffice.
Indeed. I want to start with something very simple and just be able to
re-render other descriptions when one is modified.

Thanks Diego,

> For more information on QC Magritte see:
> http://smalltalkhub.com/#!/~DiegoLont/QCMagritte
> Cheers,
> Diego
> On Dec 9, 2013, at 9:28 PM, Mariano Martinez Peck wrote:
> Hi guys. I have lots of seaside forms with magritte. One problem I have
> now is that I want to refresh the form once an item from a combo list has
> been selected. For example, the typical set country / state (or provice).
> In other words...I want to refresh the form once certain fields are choose.
> I did not find this functionality available in Magritte-Seaside. I am
> missing something?
> Thanks in advance,
> --
> Mariano
> http://marianopeck.wordpress.com
>  _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20131210/8a912c76/attachment.htm

More information about the seaside mailing list