Search code examples
tabris

add/read parameters to/from the url


If I add parameters to the url in the Objective-C code, is it possible to read it from the client?

Example:

- (NSURL *)serverURL {
    return [NSURL URLWithString:@"http://rap.eclipsesource.com/demo?parametername=value"];
}

In the Client-JavaCode I can get the value of the parameter like this:

String parameter = RWT.getRequest().getParameter("parametername");

If I access the "app" with the browser I get a value for the parameter. If I access the app with the TabrisClient the value is null.

Is there a way to get the value also in the TabrisClient?


Solution

  • Update:

    The server does not directly extract the query string from the request URL, but from the first JSON message received from the client. The web client provides the parameter queryString in the head part of the first UI request. Example:

    { "head": { "queryString": "foo=23&bar=42", "requestCounter": ... }, "operations": [ ... ] }

    You would have to fake this behavior in your Tabris client. I'd suggest that you file an issue against Tabris to provide API to set startup parameters.

    Original answer:

    If you're going to hard-code the parameter in the tabris client anyway, you could set the variable based on the connected client:

    parameter = (RWT.getClient() instanceof WebClient)
              ? RWT.getRequest.getParameter("parametername")
              : "tabris-value";
    

    BTW, access to request parameters is going to change in RAP 3.0. Instead of RWT.getRequest().getParameter(), a ClientService will provide the parameters.