Specify WebToolBarButton selection in App URL?

Hi all,

I’ve been working on my first Web 2.0 App for the last week or so, and I’m almost finished with it. It’s a pretty simple app that does a HTTP GET to a commercial product’s API every 60 second, parses the returned JSON, processes the data and display the statistics in a pie chart which is used on the shop floor displayed on a 65" TV so that management and machine operators can view the current performance of the machine over the past hour.

There are two machines that each have a TV assigned to it and the app WebToolBar has two WebToolBarButtons, one for each machine. I have set Chrome to load the app on startup in full screen mode, but I would also like to be able to specify the machine to load in the URL so no one ever need to select ether of the two buttons. Managers from their desk accessing the app would select the button for the machine they want to view and currently the app by default sets the WebToolBarButton for machine 1 as pressed when shown and loads the Machine 1 view.

With that as background, Is there a way in the app URL that I can specify which of the two machines to load on startup/application WbePage.Shown and what would be the best way to go about doing that?

One way would be If your webtoolbar buttons show different pages when they are clicked, then just show the appropriate page in Session.Open.

Otherwise, just put the code from the Pressed event into a method and call the methods from the Pressed event using, say, the caption of the button as a parameter to the method. Then you can call that same method from Session.Open depending on the URL parameters.

Hi Greg,

Thanks for the response. Since the only difference in what the two WebToolbarButtons do is to change the machine ID in the HTTP GET only one page is needed so I’d rater try the second option.

However I’m unfamiliar with how to format the URL parameters and capture that on launch. Can you be more specific by giving a simple URL example including a parameter and how that would be captured to call the method at Session.Open?

This app runs on a local server:
http://servername.domain.com:9901

It would look like https://servername.domain.com:9901?machine_id=2

In session open you can check me.urlparameter("machine_id") to see which one to pull up.

2 Likes

Thanks for the tip on how to do this Tim! However using the code below in the Session.Opening it doesn’t appear to work when I include a parameter. I use the parameter press instead of Machine ID but it doesn’t do anything. It does work when I don’t include a parameter because the default is selected. Funny thing, when I paste the URL in to chrome and press enter chrome adds a / between the port number and the parameter. http://servername.domain.com:9901?press=115 gets converted to http://servername.domain.com:9901/?press=115. Is that a problem?

Sub Opening() Handles Opening
  If Self.URLParameterCount > 0 Then
    Var parameterName, value As String
    For i As Integer = 0 To Self.URLParameterCount - 1
      parameterName = Self.URLParameterName(i)
      value = Self.URLParameter(parameterName)
      If Self.URLParameter(parameterName) = "press" Then
        If value = "114" Then
          PressSelected = "114"
          ToolbarButtonPressed(PressSelected)
        ElseIf value = "115" Then
          PressSelected = "115"
         ToolbarButtonPressed(PressSelected)
        Else
          PressSelected = "114"
          ToolbarButtonPressed(PressSelected)
        End If
      End If
    Next
  // No parameter included, load the default press
  Else
    PressSelected = "114"
    ToolbarButtonPressed(PressSelected)
  End If
End Sub

Never mind.

If Self.URLParameter(parameterName) = "press" Then

Should have been

If parameterName = "press" Then

Now it is working.

Thanks again.