[Seaside] Re: Help with dependent components.

fritz schenk intrader.intrader at gmail.com
Mon May 10 17:10:59 UTC 2010

Lukas Renggli <renggli <at> gmail.com> writes:

I definitely appreciate you taking the time to answer my request. 
> > I have implemented the following use case using Javascript and ASP.net:
> ASP.net?
Yes, ASP.net with AJAX using Visual Studio 10. I want to explore doing similar
use case in Seaside.
> > The solution entails setting up a publish/subscribe pattern - the textbox
> > and listbox B suscribe from a publisher that watches for changes on listbox
> > A.
A concrete example:
1. Listbox A displays Loan Types. Depending on the loan type dynamically compute
the values for the textbox (read only).
2. The textbox contains the points to be charged to customer. This entail
invoking a service that examines the credit worthiness of the borrowers
according to pricing rules. These change sometimes hourly or more often (in the
subprime frenzy).
3. The listbox B displays a collection of loan programs corresponding to the
loan type selected in A which also changes often as market conditions dictate.
> >
> > I have looked at Announcements, and envision a possible solution using
> > Announcements.
Where listbox A announces its change and the textbox and listbox a subscribers
to the announcement. 
> I suggest that you implement some model for your form fields that
> models the dependencies between each other and know how to update
> themselves. Magritte could be a good starting point here.
That makes sense and indeed, the loan points expresses by the textbox is
modelled by a class. And so does the collection of collections of loans
(determined by a web service) are modelled by a collection of instances of loan
> > However, a server trip seems to be inevitable with the callbacks (apart from
> > the listbox B AJAX contents); also, if more than one callback is involved,
> > they are sequentially executed at the server. The requirement suggests that
> > this should operate at the client without server trip.
> This is not true. Multiple AJAX callbacks can (and always should) be
> combined into one single request. Combining callbacks into one request
> does not only guarantee a deterministic execution order, but is also
> ways faster than multiple requests. One should never trigger two AJAX
> requests after each other, that always leads to serious problems.
Yes, this is desirable. However in the case of the textbox, and listbox B or
dynamically filled by one AJAX call initiated by the occurrence of change in
listbox A.
> > is an incorrect version of two views of gender which should ideally be
> > synchronized. However the callbacks execute sequentially, while the closure
> > in the dropdown obtains previous values, an do not see the new value set by
> > the callback of the radioButton.
> I do not understand what you mean by sequentially and how this is
> related to the above? If you write the same field with two callbacks
> they will inevitably override each other. That has nothing to do with
> AJAX or Seaside. You probably need to somehow capture the state of
> these two fields independently, and merge the input into your model.
I this incorrect example we have two views of the same object (the contact): the
radio button view, and the listbox view. I see where the callbacks override each
other (as they are incorrectly coded). 
As to the sequential behaviour I notice, is that the callbacks are saved to be
executed when the submit occurs. The callback for the radio button is executed
first and changes 'gender', and the callback for the listbox is executed next
trampling the value of gender again since the closure of the listbox block
captured the value of gender at the time of the submit.
The behaviour I want is for the radio button and listbox to be mutually and
reflexively active.
> > I would like suggestions on how to approach this common use case. There are
> > many such cases while implementing a complex 1003 form.
> What is a 1003 form?
This is an enormous form used in loan processing
https://www.efanniemae.com/sf/formsdocs/forms/1003.jsp. The form identifies a
collection of borrowers, their individual assets and liabilities, the location
of the property or properties.These and much more is use to provide selections
of loans and prices. It is implemented by most major providers of loans as well
as Fannie Mae. 
> Lukas

More information about the seaside mailing list