DEK4
July 5, 2012, 6:33am
1
Hello!
I have a problem… i try to create a new method with newMethod() and it doesn’t work…
_method = globals._dynamicForm.newMethod('function _nextStep_' + globals.getUUID() + '() { application.output("Method _nextStep"); }')
_button = globals._dynamicForm.newButton('Continua >',0+_marginLeftDTL,globals._hRowDTL*_currentRowDTL,globals._wColumnLabelDTL+globals._wColumnDataDTL,globals._hRowDTL*2,_method)
_button.onAction = _method;
_button.name = "_nextStep_" + globals.getUUID()
_button.enabled = true
thanks
Hi,
You are using a UUID in the method name. This UUID has hyphens (-) in there and those are not supported in a function name so you should strip them out.
In fact hyphens are not really supported in any object name.
Try the following code instead:
_method = globals._dynamicForm.newMethod('function _nextStep_' + utils.stringReplace(globals.getUUID(), "-","") + '() { application.output("Method _nextStep"); }')
_button = globals._dynamicForm.newButton('Continua >',0+_marginLeftDTL,globals._hRowDTL*_currentRowDTL,globals._wColumnLabelDTL+globals._wColumnDataDTL,globals._hRowDTL*2,_method)
_button.onAction = _method;
_button.name = "_nextStep_" + utils.stringReplace(globals.getUUID(), "-","")
_button.enabled = true
Hope this helps.
DEK4
July 5, 2012, 8:18am
3
Hi, thanks for your answer…but it doesn’t work…
i try also without the getUUID but nothing…
Joas
July 5, 2012, 9:41am
4
Did you call controller.recreateUI() on your changed form?
DEK4
July 5, 2012, 10:34am
5
Yes but nothing…
_method = globals._dynamicForm.newMethod('function aMethod(event){application.output("Hello world!");}');
_button = globals._dynamicForm.newButton('Continua >',0+_marginLeftDTL,globals._hRowDTL*_currentRowDTL,globals._wColumnLabelDTL+globals._wColumnDataDTL,globals._hRowDTL*2,_method)
_button.onAction = _method;
_button.name = "_nextStep_" + utils.stringReplace(globals.getUUID(), "-","")
_button.enabled = true
controller.recreateUI()
return false
Hi,
What exactly doesn’t work ?
The button doesn’t show up ? Or clicking the button doesn’t seem to trigger the method, i.e. you don’t see the application.output ?
omar
July 5, 2012, 1:15pm
7
Hi,
I simplified your example and was able to reproduce your problem when the global form var did not contain a valid object. Like this it works:
if (!globals._dynamicForm) {
globals._dynamicForm = solutionModel.getForm('frmWhatEver');
}
var method = globals._dynamicForm.newMethod('function myMethod(event) { plugins.dialogs.showInfoDialog("Test","Hello World");}');
servoyDeveloper.save(globals._dynamicForm);
var button = globals._dynamicForm.newButton('Hello World',250,250,80,20,method);
button.name = 'myNewButton';
currentcontroller.recreateUI();
Perhaps the assumption that globals.dynamicForm is filled is mistaken?