Refresh list / combos when another has been selected?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Refresh list / combos when another has been selected?

Mariano Martinez Peck
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, 

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Refresh list / combos when another has been selected?

Stephan Eggermont-3
Mariano wrote
>I did not find this functionality available in Magritte-Seaside. I am missing something?

Yes. QCMagritte.

QCDynamicSelectComponent I think.

Stephan
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

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

DiegoLont
In reply to this post by Mariano Martinez Peck
Hi Mariano,

A bit longer 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.

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.

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, 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

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

Mariano Martinez Peck



On Tue, Dec 10, 2013 at 7:27 AM, Diego Lont <[hidden email]> 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 does:

^ 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, 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki