Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Passing parameter to Cloud App

  1. #1
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185

    Passing parameter to Cloud App

    I thought I read something about this and can't find it.

    What I want to do is make a call like this from a browser (or link):

    Code:
    http://localhost:8001/myapp?mybase64encodedquerystring
    and pick it up in the INIT of the app, where I will then do things with it before anything else happens in the app.

    The app would be set to public access, so the login screen would not appear. The querystring would be used for validation and other purposes.

    I tried using:

    $_SERVER["querystring"] in the INIT of the app without success. The code that checked for $_SERVER being defined and not null skipped right around the Lianja.showMessage I was using to test.

    thanks,

    Hank

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Hank

    $_SERVER is a server side array. It cannot be accessed in the client.

    if you need to access the uri which was called to run the app from inside the app itself in the client you should access the uri from the ready delegate on the client.

    if (typeof LianjaAppBuilder !== ‘undefined’) return; // ignore in dev mode
    var url = window.location.href;
    // now extract the args and do as you will with them
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi hank

    One other solution would be to add a server side delegate that gets called when an app is run e.g call a validaterequest.prg if it exists in the app directory.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Hi Barry,

    thanks.

    Is there any way to retrieve the _server.query_string from the server? The idea is to be able to pass a parameter to an app.

    The Use Case is the user clicks a button in an email with a magic token as the query_string and goes directly into what is actually a Lianja App but looks like a fancy web page -- and of course is responsive so can run on mobile.

    thanks,

    Hank

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Hank,

    In your ready delegate you have that information available to you:

    Code:
    var query_string = "";
    var href = window.location.href;
    var pos = href.indexOf("?");
    if (pos > 0) query_string = href.substring(pos+1);
    var argv = query_string.split("&");
    for (var i=0; i<argv.length; ++i)
    {
        arg = argv[i].split("=");
        argname = arg[0];
        argvalue = arg[1];
    }
    



    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Wonderful! That does the trick. If you hadn't had a chance to respond, I was going to follow up on window.location to see what else was there, but I was tied up for the evening.

    I said many kind and true things about you tonight to a couple friends/developers. I hope you noticed. We're in the process of forming a cooperative of small shops of data experts, like us, and meet weekly on Zoom.

    thanks,

    Hank

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Glad it’s useful
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Senior Member
    Join Date
    Oct 2012
    Posts
    239
    hi Barry,
    is there such a possibility for desktop apps as well?
    Quote Originally Posted by barrymavin View Post
    ...
    In your ready delegate you have that information available to you:

    Code:
    var query_string = "";
    var href = window.location.href;
    var pos = href.indexOf("?");
    if (pos > 0) query_string = href.substring(pos+1);
    var argv = query_string.split("&");
    for (var i=0; i<argv.length; ++i)
    {
        arg = argv[i].split("=");
        argname = arg[0];
        argvalue = arg[1];
    }
    




  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    In Lianja 6 you can specify args like this and get them using Lianja.args

    lianja --app yourapp --args "'hello world', 10, false"

    or when using

    Lianja.openApp("appname?args")

    and reference Lianja.args in the ready delegate. Desktop only.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #10
    Senior Member
    Join Date
    Oct 2012
    Posts
    239

    thak you Barry

    I'm looking forward to 6.0

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us