0

I am writing a RAP application using Eclipse RAP. The client may be any brower, an iPad or an android tablet (using Tabris). Is there any chance to find out which client has sent a request?

The background for my question is: Tabris does not support SashForms until now. For this reason, I want to render a SashFrom in case I am serving a web client but don't want to create a SashForm if serving the android client. I could do something like this:

public static boolean isAndroid() {
    return getUserAgent().contains(Constants.ID_ANDROID);
}

private static String getUserAgent() {
    return RWT.getRequest().getHeader(Constants.USER_AGENT);
}

public static boolean isIos() {
    return getUserAgent().contains(Constants.ID_IOS);
}

public static boolean isWeb() {
    return !isAndroid() && !isIos();    
}

But I'd like to avoid this approach, because it uses internal API and since I am using standalone RAP I need to add a the servlet-api.jar to WEB-INF/lib folder to get this running, which is also not very nice.

Thanks in advance for your help and information, Tobias.

baumato
  • 358
  • 3
  • 13

2 Answers2

2

I think this can help: https://github.com/eclipsesource/tabris/blob/master/com.eclipsesource.tabris/src/com/eclipsesource/tabris/ClientDevice.java

Holger
  • 437
  • 2
  • 4
  • This one works: https://github.com/eclipsesource/tabris/blob/master/com.eclipsesource.tabris/src/com/eclipsesource/tabris/device/ClientDevice.java – Holger Sep 05 '13 at 06:47
0

One alternative approach instead of using ClientDevice is to use RWT.getClient().

if( RWT.getClient() instanceof WebClient ) { .... }

This is sometimes useful because ClientDevice can be null if the web client accesses the application. It's a client service that is only valid for the mobile client atm.

Holger
  • 437
  • 2
  • 4