Hi,
This is incorrect
model.setUserName = result.UserName;
model.setPassWord = result.PassWord;
and this is correct
model.setUserName(result.UserName);
model.setPassWord(result.PassWord);
Now, handler looks like this:
if (exc == null) {
model.setUserName(result.UserName);
model.setPassWord(result.PassWord);
}
else
{
alert("Exception during async call: " + exc);
}
Controller binds model to form (or vice versa?), so if you change the
model's property then controller changes textfield widget.
The second solution works too
var myNewModel = qx.data.marshal.Json.createModel(result);
controller.setModel(myNewModel);
Make you choose!
On 19 July 2012 00:22, bobiblazeski <[email protected]> wrote:
> Apologies for possible double posting, my orginal post hangs not accepted.
>
>
> I'm having problem setting form data retrieved from RPC call.
> I don't understand what should I do with received data from the server and
> how to change the form values.
> The part that I don't understand is in the handler after I receive the
> result:
>
> var form = new qx.ui.form.Form();
> form.add(new qx.ui.form.TextField(), "Username", null,
> "UserName");
> form.add(new qx.ui.form.TextField(), "Password", null,
> "PassWord");
> var saveButton = new qx.ui.form.Button("Save");
> saveButton.setWidth(70);
> form.addButton(saveButton);
> this.getRoot().add(new qx.ui.form.renderer.Single(form));
> var controller = new qx.data.controller.Form(null, form);
> var model = controller.createModel();
> model.setUserName("Some Username");
> model.setPassWord("Some Password");
> var rpc = new qx.io.remote.Rpc(
> "http://localhost:58027/Wage/PersonHandler.ashx",
> "JayrockWeb.PersonHandler"
> );
> var handler = function (result, exc) {
> if (exc == null) {
> alert(result.UserName);
> alert(result.PassWord);
> // How should I set data here ??
> model.setUserName = result.UserName;
> model.setPassWord = result.PassWord;
> alert(result);
> var model = qx.data.marshal.Json.createModel(result);
> alert(model);
> controller.setModel(model);
> } else {
> alert("Exception during async call: " + exc);
> }
> };
> saveButton.addListener("execute", function () {
> if (form.validate()) {
> alert("You are saving: " +
> qx.util.Serializer.toJson(model));
> rpc.callAsync(handler, "decorateCredential",
> qx.util.Serializer.toJson(model));
> }
> }, this);
>
>
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/How-to-set-data-retrieved-by-RPC-to-form-tp7580674.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel