Child pages
  • JSMethod

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{div:style=display:none}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.\\		\\		Enter additional information related to this 'class' inside the \{div} macro with 'id=description'{div}
{div:id=description}{div}\\ 

{table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Property Summary{th}{tr}{tbody}{tr}{td}[String]{td}{td}[#code]
The full source code of this method (including doc and function declaration).{td}{tr}{tbody}{table}\\ 

{table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[Object]\[]{td}{td}[#getArguments]\()
Gets the argument array for this method if that is set for the specific action this method is taken from.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#getName]\()
The name of the method.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#getScopeName]\()
Get scope name{td}{tr}{tbody}{table}\\ 

{table:id=property|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{tbody:id=code}{tr:id=name}{td}h6.code{td}{tr}{tr:id=des}{td}{div:class=sIndent}The full source code of this method (including doc and function declaration).{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var method = form.newMethod('function original() { application.output("Original function."); }');
application.output('original method name: ' + method.getName());
application.output('original method code: ' + method.code);
method.code = 'function changed() { application.output("This is another function."); }';
method.showInMenu = false;
var button = form.newButton('Click me!', 10, 10, 100, 30, method);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\ 

{table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=getArguments}{tr:id=name}{td}h6.getArguments{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Object]\[]{span}{span:style=font-weight: bold;}getArguments{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Gets the argument array for this method if that is set for the specific action this method is taken from.
Will return null by default. This is only for reading, you can't alter the arguments through this array, 
for that you need to create a new object through solutionModel.wrapMethodWithArguments(..) and assign it again.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Object]\[] -- Array of the arguments, null if not specified.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var frm = solutionModel.getForm("myForm");
var button = frm.getButton("button");
// get the arguments from the button.
// NOTE: string arguments will be returned with quotes (comp.onAction.getArguments()[0] == '\'foo\' evals to true)
var arguments = button.onAction.getArguments();
if (arguments && arguments.length > 1 && arguments[1] == 10) { 
	// change the value and assign it back to the onAction.
	arguments[1] = 50;
	button.onAction = solutionModel.wrapMethodWithArguments(button.onAction,arguments);
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getName}{tr:id=name}{td}h6.getName{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]{span}{span:style=font-weight: bold;}getName{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}The name of the method.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String] -- A String holding the name of this method.{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var method = form.newMethod('function original() { application.output("Original function."); }');
application.output('original method name: ' + method.getName());
application.output('original method code: ' + method.code);
method.code = 'function changed() { application.output("This is another function."); }';
method.showInMenu = false;
var button = form.newButton('Click me!', 10, 10, 100, 30, method);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getScopeName}{tr:id=name}{td}h6.getScopeName{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]{span}{span:style=font-weight: bold;}getScopeName{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Get scope name{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var methods = solutionModel.getGlobalMethods(); 
for (var x in methods) 
	application.output(methods[x].getName() + ' is defined in scope ' + methods[x].getScopeName());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}