If I try to set a property of the embedded object like:
documentCircleSeqBackup.seq.sequenceNoNew = 7;
I get the following error.:
Exception Object: org.mozilla.javascript.EcmaError: TypeError: Cannot set property "sequenceNoNew" of undefined to "7"
MSG: TypeError: Cannot set property "sequenceNoNew" of undefined to "7"
<null>
Why does this seem wrong to me? I should not have to declare all properties of a JS object at initialization.
var o = {propA: 'string'};
o.propB = 'another string'; // this should be OK in JS but generates a warning in Servoy. Why?
Declaring all properties at initialization may create problems with program flow in some cases (for example when there is a “for (var in obj) loop” it would require an extra “if”).
sergei.sheinin:
Why does this seem wrong to me? I should not have to declare all properties of a JS object at initialization.
var o = {propA: 'string'};
o.propB = ‘another string’; // this should be OK in JS but generates a warning in Servoy. Why?
Actually that code doesn’t generate any warnings at all.
You don’t have to declare the properties of a JS object. It’s just so that that the JS Editor can do the code completion of these objects and give you helpful warnings when you made a typo somewhere.
But you could also ignore any of these warnings, it won’t change the behavior of the code when you execute it.
Also you can suppress certain warnings by right-clicking on the warning marker on the left gutter. This will show a popup menu with options that may include the option to suppress a certain warning.
Using your example I can reproduce it.
[attachment=0]Screen Shot 2014-09-09 at 11.10.58.png[/attachment]
But only when I enter that last line. When you leave that out the warning doesn’t show.
It seems the parser gets confused by the fact you re-initialize the whole object.