Hello folks,
I try to improve my webui which already use qooxdoo.
My webui is above an embedded system and it is used to change the config
and display status.
For now, I get back the different config sets and status in json with a
RPC call, do a JSON.parse() and manually, for each form and page, I set
the different values needed.
Lot of code, so I want to improve it.
I want to use the power of model, view and controller using
qx.data.controller.Form class.
I did some try, created a static model represented a part of the user
config, set it to the form controller. My form is fill by the model.
--------------------------------
var data_obj = {
trigger: {
enabled: true,
pre: "3",
post: "4",
mode: "Level",
maxlen: "300",
chan: "XYZ",
logic: "OR",
level: {
x: "10",
y: "10",
z: "10"
}
}
};
var data_model = qx.data.marshal.Json.createModel(data_obj);
this.__data_form_controller = new qx.data.controller.Form(data_model,
this.__ui_form, true);
--------------------------------
But now, I've some concerned about how organize all the stuff.
Especially, the part where I send back the modification done by the user
by a RPC call.
I followed the feedreader example. I created my models (under
mystuff.model.*), a rpc loader (under mystuff.io) and views (under
mystuff.view.*). I began to write each page in a singleton class.
* 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();
}
});
--------------------------------
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);
--------------------------------
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 ?
* Second question. How can I give the model to the page ? Is there a
good way to do that ?
* 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 ?
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 ?
Regards,
Viallard Anthony.
------------------------------------------------------------------------------
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