• Todor
    January 6, 2016 at 2:58 am #1131

    I’ve got a Data bound to a complex type. I update the data using JS on the client side:

    page.ui.get(“root/Data1”).getData().costCentres.items[1].name = “12” – Data1 is bound to a complex vairable which has an array of other complex objects and one of their attributes is “name”.

    When firing a boundary event, on the server, the variables is not updated.

    I did the same test with a Data bound to a simple variable, and it works as expected, the new value updated on the client side is visible on the server i.e. the variable was updated.

    This is such a fundamental issue which basically stops us using the toolkit.

     

    SPARK Support
    January 6, 2016 at 5:04 am #1132

    Todor:

    Unless I don’t understand your issue completely, it looks to me like you are missing the point of the Data Control.  There is a small word document attached which should explain the processing necessary.

    1. Have a look at the Diagram, and you will see it is really a silly example.  The post processing done in the Test Human Service logs the updated complex variable.
    2. The Coach consists of the Data Control (ctlId=Data1), Two buttons (one which does the update (“Button”) the other to end the Service (“Done”)
    3. The Custom HTML is run when “Button” is clicked.  The updateComplexType function shows how the name of the first entry in the list could be updated.
    4. The issue I believe I see with the code you supplied is that you are never using the setData() method which actually updates the bound variable.

     

    Please let me know if I have this wrong, but I think this should solve your problem.

     

    Regards

     

    John

    Todor
    January 7, 2016 at 1:22 am #1144

    Hi John,

     

    First, thank you for compiling this document. It did help indeed understand the gap in my .. well… understanding how the Data component works in relation with complex types.

    For the record, this expression :

    page.ui.get(“root/Data1”).getData().costCentres.items[1].name = “12” – Data1 is bound to a complex vairable which has an array of other complex objects and one of their attributes is “name”.

    needs to be converted to:

    page.ui.get(“root/Data1”).getData().costCentres.items[1].name = “12”

    page.ui.get(“root/Data1”).setData(page.ui.get(“root/Data1”).getData());

    The idea is that once you update the client side variable, and then assign it to the server side using setData().

    I was tricked into thinking that if the client-side is updated, it would auto-magically update on the server side too.

     

    Thanks,

    Todor

     

    YO
    February 12, 2016 at 7:50 pm #1369

    One tip. I have spent some hours why it is not working with me. Then I found I forgot initializing the complex variable.

    page.ui.get(“DATA”).getData().CurrencyDecimal = 2;

    page.ui.get(“DATA”).setData(page.ui.get(“DATA”).getData());

    alert(page.ui.get(“DATA”).getData().CurrencyDecimal);

    Then, I got “null”.

    This looked me that setData() didn’t work. but it was because I didn’t initialize CurrencyDecimal variable.

     

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search