开发者

gwt define-property doesn't generate new compilation permutation

开发者 https://www.devze.com 2023-01-06 02:01 出处:网络
I added the following to myModule.gwt.xml. I expected it wou开发者_高级运维ld generate 6*2 permutations when compile. However, it still only generated six permutation. Did I miss anything there?

I added the following to myModule.gwt.xml. I expected it wou开发者_高级运维ld generate 6*2 permutations when compile. However, it still only generated six permutation. Did I miss anything there?

<define-property name="mobile.user.agent" values="mobile, not_mobile" />

<property-provider name="mobile.user.agent"><![CDATA[
{
 var ua = window.navigator.userAgent.toLowerCase();
 if ( ( ua.indexOf('android') != -1) || 
   ( ua.indexOf('iphone') != -1) || 
   ( ua.indexOf('midp') != -1) || 
   ( ua.indexOf('opera mobi') != -1) || 
   ( ua.indexOf('opera mini') != -1) || 
   ( ua.indexOf('blackberry') != -1)  )
 { return 'mobile'; }

 else { return 'not_mobile';}
}
 ]]></property-provider>

I can see the myModule.nocache.js file contain the following:

u[sb]=function(){{var a=window.navigator.userAgent.toLowerCase();if(a.indexOf(tb)!=-1||(a.indexOf(ub)!=-1||(a.indexOf(vb)!=-1||(a.indexOf(wb)!=-1||(a.indexOf(xb)!=-1||a.indexOf(yb)!=-1))))){return zb}else{return Ab}}};t[sb]={mobile:0,not_mobile:1};


If you leave it like this, nothing will happen. You need to make a Deferred Binding rule based upon your property. So for your mobile browsers you'll likely want to have other implementations for some interfaces than for the desktop browsers (most likely view-related interfaces). This could play nicely with the MVP pattern where you can choose different View implementations based on the module property.

0

精彩评论

暂无评论...
验证码 换一张
取 消