When I create a dynamic form with a formvariable and set the defaultValue property then these variables are null when I show the newly created form.
I created a case for this: #215220
Version 4.1.3 -build 672
Java version 1.5.0_16 (Mac OS X)
When I create a dynamic form with a formvariable and set the defaultValue property then these variables are null when I show the newly created form.
I created a case for this: #215220
Version 4.1.3 -build 672
Java version 1.5.0_16 (Mac OS X)
checked it out but cant reproduce it:
var form = solutionModel.newForm("newform",x.controller.getServerName(),x.controller.getTableName(),null,true,600,400);
var fv = form.newFormVariable("formvariable",SM_VARIABLETYPE.TEXT);
fv.defaultValue = "10";
form.newField(fv,SM_DISPLAYTYPE.TEXT_FIELD,50,50,80,20);
forms.newform.controller.show();
i tried with 2 kinds of variable types (integers and above string)
Hi Johan,
Your example does work for me too, which puzzled me. After some investigation it turns out that when you use anything other than numerical values then the default value is not set.
But also when you set the default value of a media variable with, lets say, a JS Array object it stays null.
When I set a JS Date value as defaultvalue in a datetime variable it also turns up to be null.
So yes, numerical data (-only) works with integers and strings but anthing else doesn’t…at least for me.
Hope this helps.
what you want to do is piecies of javascript.
If you want to create those through the solution model you need to see them as stuff that are get evaluated later on:
/**
var fv = form.newFormVariable(“formarray”,SM_VARIABLETYPE.MEDIA);
fv.defaultValue = “new Array(2009,10,25)”;
forms.newform.controller.show();
}
/**
so make the strings…
You cant assign just an array or a data object to a variable that expects it to be a string or number
Hi Johan,
Ahhh…and to use a string I need to use the following code:
fv.defaultValue = '"a string"';
But it’s a shame that when I have existing JS objects I need to write them out as a string in order to pass them into these form variables. Bit of a pain.
Hi
I guess, my problem is related to this topic: I try to initialize a global variable to an instance of a self defined class. E.g.
var city = new City();
One problem: There is no appropriate type for the variable available.
Second problem: The variable turns out to be null.
A solution would be appreciated a lot.
Regards
Birgit
that new City() which is i guess a function in the same file will not work.
in servoy variables (globals or form) are generated/constructed before the functions. So at the time a variable is instantiated there arent any functions yet.
Thank you.
Best regards
Birgit
this works fine:
var array = new Array(1,2,3,4,5,6,7);
al standaard js things are working fine, you only shouldnt try to touch sevoy stuff in the init of the variable.
in the onload you can set the (form) variables just fine yes.