问题描述
我知道如何使用延迟绑定来为不同的用户代理编译一个GWT应用程序,但是这似乎并没有提供一种在桌面+移动浏览器之间进行distingiush的方法。
$ b $除了通过制作一个基于gwt-mobile-webkit的新应用之外,您将如何将现有的GWT应用转换为拥有重新设计的移动界面? 解决方案
我知道如何使用延迟绑定来为不同的用户代理编译一个GWT应用程序,但是这似乎并没有提供一种在桌面+移动浏览器之间进行distingiush的方法。
如果您使用
I am aware of how to use deferred binding to compile a GWT app for different user agents, but this does not seem to offer a way to distingiush between desktop + mobile browsers.
Other than by making a new app based on gwt-mobile-webkit, how would you convert an existing GWT app to have a restyled mobile interface?
If you use the MVP pattern described here, you can switch the views' implementations based on the user agent.
You can have a ClientFactoryImpl and ClientFactoryMobileImpl. Then you use GWT.create(ClientFactory.class) to create the implementation defined into the .gwt.xml file.
Here is an example of the .gwt.xml file
<replace-with class="com.bell.cts.e911.ers.web.client.ClientFactoryImpl">
<when-type-is class="com.bell.cts.e911.ers.web.client.ClientFactory" />
<when-property-is name="user.agent" value="ie6" />
</replace-with>
<replace-with class="com.bell.cts.e911.ers.web.client.ClientFactoryMobileImpl">
<when-type-is class="com.bell.cts.e911.ers.web.client.ClientFactory" />
<when-property-is name="user.agent" value="mobilesafari" />
</replace-with>
You can always set up user.agents using the technique described here : http://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties
这篇关于GWT - 如何编译移动排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!