Menu

Passing Parameters from the Browser

2007-02-09
2013-04-25
  • Paul Cappa, New Earth

    I'm really enjoying using Tersus.  I can see how I could easily get hooked on this application.

    I checked the forum but didn't find any reference to passing paramters from the browser to the an application.  I'm trying to pass an ID to the app, but can't seem to figure out how to do it.

    Is this possible?  And if so, how do I go about doing it?

    Thanks,

    Paul

     
    • Youval Bronicki

      Youval Bronicki - 2007-02-09

      Hi Paul.  Thanks for the feedback!

      You can use the plugin 'Get View Parameters':

      The normal URLs used by the system look like: http://<Host>:8080/Project/#Perspective=<Perspective>&View=<View>
      The <Perspective> and <View> parameters tell the platform which view should be displayed.

      You can add additional parameters e.g. http://localhost:8080/Project/#Perspective=<Perspective>&View=<View>&ID=<ID>
      And access the Id in the model using Get View Parameters.   Each exit of 'Get View Parameters' is identified with a parameter from the url (so in this case you would add an exit called ID).  The type of the exit can be textual or numeric (dates and booleans should also work, but I don't remember testing it).

      Regards,

      Youval

       
    • Paul Cappa, New Earth

      That is priemo!  Wow.

      It's obvious that the ID is passed to view.  How do the other veiws get access to it?

      Thanks,

      Paul

       
      • David Davidson

        David Davidson - 2007-02-09

        As you've probably discovered your parameters (such as ID) are dropped from the url once you switch to another view.
        I think the easiest method to pass your parameters to another view would be to save the parameter values to the database (probably when you 'Get View Parameters' on init of first view), and read it from the database on init of the second view.

        Regards,
        David - support@tersus.org

         
    • Paul Cappa, New Earth

      David,

      That's exactly what I discovered.  I tried implementing a cookie, but I think I was doing something wrong.  I thought of the database approach too.  Either way, I think the issue that I have is where to put the action. 

      When I come back to the view, it will create the cookie or store the data in the database again and again.  Is there a way to know the first time a view is opened?  Or, would it make sense to have a view (this seems to be an oxymoron) that is invisible.  That would be what my browser first calls, but then I switch to a "visible view".

      Regards,

      Paul

       
      • David Davidson

        David Davidson - 2007-02-09

        Paul,

        What you could do is the following:
        On init of the first view, after parsing the parameters from the URL, replace the URL with a new one, by using a 'Display Actions/Create Location' with no triggers (creating the basic tersus URL for the view) and sending the <URL> to a 'Display Actions/Go To URL' with an additional <Relative> trigger receiving a "Yes" constant. Note that both templates mentioned have comments which explain these and other possible triggers.

        Regards,

        David - support@tersus.org

         
    • Youval Bronicki

      Youval Bronicki - 2007-02-11

      I would rather use the following solution:

      In the initialization of your views, use a common action 'Get Id' that works as follows:

      - If the view parameter exists, save its value in a cookie and return it
      - Otherwise, retrieve the value from the cookie

      See http://downloads.tersus.com/support/get_parameter_or_cookie.gif

      If you use a database record instead of a cookie, you probably want to include the user id in the record's primary key.

      Regards,

      Youval

       
    • Paul Cappa, New Earth

      Youval,

      That sounds like a great solution (using the cookie).  For what I'm trying to do, the database solution would be very complicated - since the application is multi-user, and it's possible to have someone logged in from two diffrent positions.  With the cookie, it is local to the machine they are on.

      Much appreciated,

      Paul

       
    • Paul Cappa, New Earth

      Youval,

      I implemented your cookie recommendation and it works well.  There was one slight change that had to be made to get it to work.  "Set Cookie" also requires a "control".  I created a flow from the "Exits/<Yes>" to the "control" I created on "Set Cookie".

      Nice solution ... thank you.

      Paul

       
      • David Davidson

        David Davidson - 2007-02-14

        Set Cookie/<Value> is non-mandatory by default but can be set as mandatory, making the additional Control trigger redundant.

        Regards,

        David - support@tersus.org

         

Log in to post a comment.