Hi Viallard,
don't know if I understood everything of your post but I'll try my best to
answer them anyway.
Am 08.10.2013 um 11:24 schrieb Viallard Anthony
<[email protected]>:
> * How can I write the apply code for each form ? Here the code I did
> for my apply button for now :
>
> --------------------------------
>
> ui_button_apply.addListener("execute", function() {
> if (this.__ui_form.validate()) {
> var model;
>
> model = this.__data_form_controller.getModel();
> }
> });
exactly, you perform your code in the execute-handler of the according
submit-button.
>
> --------------------------------
>
> I don't want to send all the config each time the user modify the
> config. Do I need to create an object with the config and do a JSON
> stringify like this ?
>
> --------------------------------
>
> var trigger_model = model.getTrigger();
> var data = {
> trigger : {
> enabled : trigger.getEnabled(),
> pre : trigger.getPre(),
> /* ....*/
> }
> };
>
> var text = JSON.stringify(data);
>
> --------------------------------
You don't have to. There are three layers:
Form <---> Model <---> Backend
The data-binding-concept of FormController only takes care of keeping the form
and the model in sync. If, when and how often you sync your data with the
backend is only up to you.
Also you don't have to send everything. You could for example serialize the
model to a native object with qx.util.Serializer.toNativeObject(), modify it
and then only sync the portions needed. But be aware that this has to be done
manually, so you have to take care about conflicts, merges etc.
>
> Furthermore, I don't want to write in each page the rpc call and analyze
> the call answer. So, how can I organize the code ?
As above, you don't have to. You can collect all needed models from each page,
perform actions on it and finally send them all at once. You can also have a
look at qooxdoo's concept of data-stores. Unfortunately, there is no store for
RPCs, so if you have to stick to RPCs and cannot switch to HTTP-requests, you
have to implement the logic yourself.
>
> * Second question. How can I give the model to the page ? Is there a
> good way to do that ?
Intuitively via the method-call setModel(model).
>
> * Third question. How can I update the model ? As you can see above,
> when I instanciate a qx.data.controller.Form, I tell him I want to be in
> charge of calling updateModel() to update the model with the new values.
> I guess I have to add the call when the apply call is a success, right ?
Exactly, it happens in the handler, see also:
http://demo.qooxdoo.org/devel/demobrowser/#data~FormController.html
>
> But, I need another way to update the model. For example, if the user
> stay on the webui a long time and come back, perhaps the model is
> outdated because some other user on another computer has modified the
> config. I think about a cache timeout. The model will be valid for XX
> seconds. So, when the user come back, go to another page, I force a new
> RPC call. What do you think about this system ? Is there an example of
> this elsewhere on the internet ?
As said above, the data-binding doesn't help you here. If you need RPCs, you
have to implement the timeout-logic and everything else dealing with the
backend by your own.
Best
Andreas
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel