application.getStartupArguments

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

application.getStartupArguments

Postby Gordon » Tue May 25, 2010 11:13 am

Hi

I am not certain this function is working as described in the manual. As I understand it this function should return any arguments passed via the URL to a web client in the form of and array. I would therefore expect to get an array returned and be able to split this using the format array[0] for the first item etc

I have done a simple test site which can be accessed at the following address

http://clipper.clickdigital.com/servoy- ... est2|Test3

Note I would expect this code to return an item in each of the boxes using this function:

function startup2() {
var args_array = application.getStartupArguments();
forms.login.Arg1 = args_array[0];
forms.login.Arg2 = args_array[1];
forms.login.Arg3 = args_array[2];
forms.login.arguments_array = args_array;
forms.login.arguments_array_length = args_array.length;
}

ie that args_array would now be an array

The results I am trying to obtain can be seen with this:

function startup1() {
var args_array = ['Arg1','Arg2','Arg3'];
forms.login.Arg1 = args_array[0];
forms.login.Arg2 = args_array[1];
forms.login.Arg3 = args_array[2];
forms.login.arguments_array = args_array;
forms.login.arguments_array_length = args_array.length;
}

Having spent some time fiddling about with this any pointers to obvious errors would be appreciated

best
gordon
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: application.getStartupArguments

Postby mboegem » Tue May 25, 2010 12:29 pm

Hi Gordon,

if I'm not mistaken, the webclient gets the arguments as a string,
the smart client however as an array.

So if your solution should handle both, you should test which client is being used.

Hope this helps!
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: application.getStartupArguments

Postby Gordon » Tue May 25, 2010 12:36 pm

Hi Marc

Although strange that makes sense based on the response I am getting from the web client. The docs suggest its all passed as an array and I would wonder why Servoy would have changed the approach - array seems a lot easier for all concerned !!

Thanks for the reply

best
Gordon
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: application.getStartupArguments

Postby mboegem » Tue May 25, 2010 1:15 pm

We've been using both web and smart client since v3.5. It's always been like this.
It will be very unlikely to change.

Anyway, if you just pass your arguments with a separator you know (I believe you now use '|'), your code can look something like this:

Code: Select all
function startup1()
{
var args_array = ('' + application.getStartupArguments()).split('|');
forms.login.Arg1 = args_array[0]
etc.
etc.
}
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: application.getStartupArguments

Postby Gabi Boros » Mon May 31, 2010 12:16 pm

starting from version 5, getStartupArguments can return null,
if no arguments are used, or an array with 2 elements : the first
element is the value of the 'argument' used in the startup link,
and the second element is a javascript object containing all the
startup arguments identified by names

in case of your url:
'http://clipper.clickdigital.com/servoy-webclient/ss/s/TestArgs/m/startup2/a/Test1|Test2|Test3'
var startup_args = application.getStartupArguments();
var argument = startup_args[0]; // it is 'Test1|Test2|Test3'
var starup_args_object = startup_args[1]; // startup_args_object.a is also 'Test1|Test2|Test3'

you can pass multiple named arguments using an url of this form:
'http://clipper.clickdigital.com/servoy-webclient/ss/s/TestArgs/m/startup2/a/defaultArgumentValue/argName1/argValue1/argName2/argValue2'
var startup_args = application.getStartupArguments();
var argument = startup_args[0]; // it is 'defaultArgumentValue'
var starup_args_object = startup_args[1]; // startup_args_object.a is also 'defaultArgumentValue', startup_args_object.argName1 is 'argValue1', startup_args_object.argName2 is 'argValue2'
Gabi Boros
Servoy
Gabi Boros
 
Posts: 399
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: application.getStartupArguments

Postby Gordon » Thu Jun 03, 2010 2:25 pm

Hi Gabi

Thanks for this - it makes sense and explains the object in argument 2 that was being returned

This whole revisit of the arguments started with the intention of using Servoy to listen for IPN returns from Paypal. They send a string in the form paypal.com?arg=x&etc - I concluded that it was therefore not possible to get Servoy to listen for this response and have instead used a PHP listner and had it pass the details to Servoy as it prefers ie your suggested format.

Best
Gordon
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: application.getStartupArguments

Postby mboegem » Thu Jun 03, 2010 3:11 pm

Please note:

using application.getStartupArguments() do not always return the correct arguments.
This occurs whenever you have an active session already.
for Mac users this is real easy as Safari doesn't close by default, windows users experience this for example clicking a 2nd link when there's already a webclient connected in another tab of your browser.

Anyway when using something like this: 'http://clipper.clickdigital.com/servoy-webclient/ss/s/TestArgs/m/startup2/a/Test1|Test2|Test3'

You'd better ask for the arguments like this:
var startup_args = arguments;

This way you always get the correct arguments into your var.
This ONLY works when having a method specified in the link ('/m/startup2/')

All credits to Paul Bakker who helped me out on this yesterday.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: application.getStartupArguments

Postby Marco R. » Fri Oct 15, 2010 6:42 pm

Hi all,

I would to pass a number as argument and following the Marc example I've tried with:

"http://localhost:9090/servoy-webclient/solutions/solution/file_solution|877"

and with:

"http://localhost:9090/servoy-webclient/solutions/solution/file_solution?var1=877"

but without result.

Can you tell me the correct way to pass an argument to a servoy web application?

thanks in advace

Marco
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: application.getStartupArguments

Postby Gordon » Fri Oct 15, 2010 7:52 pm

Marco R. wrote:"http://localhost:9090/servoy-webclient/solutions/solution/file_solution|877"



You might like to try this

"http://localhost:9090/servoy-webclient/ss/s/file_solution/m/yourstartupmethod/a/877"


ss/s are a shortcut for solutions/solution that makes the URL easier to read
a = arguments ? wont work with Servoy
m = the method that receives the arguments and this needs to be a global

HTH
Gordon
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: application.getStartupArguments

Postby Marco R. » Sat Oct 16, 2010 4:07 pm

Clear gordon.



Thanks for your time :)


Marco
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: application.getStartupArguments

Postby tysonj » Tue Sep 27, 2011 1:41 pm

Hi,

When I am trying to call a global method in my Web Solution using the below URL the argument I send to the function is not received by the method.
example of URL :- "http://localhost:8080/servoy-webclient/solutions/solution/MySolution/method/SomeMethod/arguments/001"

the function defination :-
/**
* @param {String} arg
*
* @properties={typeid:24,uuid:"BAF06510-68E4-4A2D-8D56-803F4FE0CA66"}
*/
function SomeMethod(arg)
{
application.output('Success :- '+ arg);
}

but arguments was not received by the global method in the solution. It was displaying the message as Success :- undefined.
I don't know were am going wrong please help me out...???
User avatar
tysonj
 
Posts: 47
Joined: Tue Sep 28, 2010 2:07 pm
Location: Paris, France.

Re: application.getStartupArguments

Postby tysonj » Wed Sep 28, 2011 2:12 pm

Found the answer for the above... :)
used argument instead of arguments in the URL to pass the parameter.
User avatar
tysonj
 
Posts: 47
Joined: Tue Sep 28, 2010 2:07 pm
Location: Paris, France.

Re: application.getStartupArguments

Postby Gordon » Wed Sep 28, 2011 2:17 pm

The short version of of the URL makes this a lot easier i.e. the ss/s and m and a - especially in my case where I am dreadful at spelling :roll:

"http://localhost:9090/servoy-webclient/ss/s/file_solution/m/yourstartupmethod/a/877"
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK


Return to Web Development

Who is online

Users browsing this forum: No registered users and 4 guests