Improve queue system to solve some use case
ronanker Sep 8, 2009 1:39 PMHI !
I have a complex issue with queued request that become invalid and i don't know how can i solve it without changing the way queues works :
the use case :
in a page i have a form in wich i choose objects to be added on a list that is on an other form with a 'save' button.
in the list, each object shows its properties editable.
when i click on my items to add them in the list i have ignoredupresponse and send once the request to add objects in the list and rerender on the list.
if during this request i click on 'save button' it's added to the queue and executes when the first finish but the content of the form that's sent in the request doesn't contains those inputs that have just been added by first request. and then on the server it saves 'null' value in all my objects overwriting their defaults values...
note that if i rerender the page then user see all objects empty, if not then user may just exit the page without knowing what he saw wasn't what have been saved...
if one of the inputs is required, the user gets a message saying it's not set but can see a value in it...
etc...
do you understand my problem ?
a way to solve it :
I think, it's not the 'serialisation' of the request that should be in the queue but (how to say) the parameters that permit to construct the request :
here is what you do :
A4J.AJAX.Submit = function( containerId, formId, event , options ) { var domEvt = A4J.AJAX.CloneEvent(event); var query = A4J.AJAX.PrepareQuery(containerId, formId, domEvt, options); if (query) { var queue = A4J.AJAX.EventQueue.getOrCreateQueue(options, formId); if (queue) { queue.push(query, options, domEvt); } else { A4J.AJAX.SubmitQuery(query, options, domEvt); } } return false; };
and here is what i think we could do :
A4J.AJAX.Submit = function( containerId, formId, event , options ) { var domEvt = A4J.AJAX.CloneEvent(event); var futureQuery = A4J.AJAX.futureQuery(containerId, formId, domEvt, options); var queue = A4J.AJAX.EventQueue.getOrCreateQueue(options, formId); if (queue) { queue.push(futureQuery, options, domEvt); } else { var query = A4J.AJAX.PrepareQuery(futureQuery); A4J.AJAX.SubmitQuery(query, options, domEvt); } return false; };
and when poping the futureQuery from the queue then prepare it (var query = A4J.AJAX.PrepareQuery(futureQuery);)
where futureQuery is only a simple container for containerId, formId, domEvt and options.
i've thought about this change since RF-3.3.0 for several other use cases, but now i think it become more and more interesting.
doing that make the execution of the 'onsubmit' of the form occuring just before sending the request, it's really better for my use case. In current code it's executing at the time it's put in the queue, and that's not what i want.
If we want to execute something when the request is put in the queue, we should have a "onPushedInQueue" attribute on the form.
Maybe you have use cases where your code is better, so, the best is to have some parameters to choose whether request have to be constructed at 'queue.push' or at 'queue.pop'.
Thanks in advance for the time you'll send thinking about that and replying me.
(if you aggree and if you can do it for 3.3.2, you're really the best but if you plan it only for 4.0, i won't blame you, i know you've got lots of work)