I'm currently working on adding HTML5 offline support to my web application, and am mostly following the same approach of mgwt:
My question involves step 2: In my servlet, I want to detect which permutation to serve for a certain request. The way I do this now is:
Map this (using simple string operations (e.g. userAgent.contains("safari")
) to the 'agent id', which I can map using a mapping file to the permutation strong name. In other words, map Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)
to ie6
, which I can map (using the generated mapping file, see example below) to 15B454D690F2CCAD57F1DD809429BF42
.
<permutation name="15B454D690F2CCAD57F1DD809429BF42">
<user.agent>ie6</user.agent>
</permutation>
The problem I'm facing: I want to use the same method of linking a user agent string to a permutation as GWT uses (i.e. map Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)
to ie6
). This way I don't have to fix my code whenever my GWT gets updated with other permutations/browser versions. In other words, I don't like my current solution of naively matching the complete user agent string in the servlet with the user agent 'id' (in my example 'ie6') in my permutation mapping.
The solutions I thought about were:
You can take advantage of the HTML5Manifest solution provided with mgwt. They have a linker which produces a file which can be read by the servlet they provide, and return the appropriate list of files to cache by the browser based on the user-agent header.
If you want to do it by yourself, you can figure out the most suitable permutation per browser, based on the http user-agent header, and on the compilation-mappings.txt
file which is generated by the gwt compiler if you are using xsiframe
linker.