0
我使用MVP和我有公共視圖界面的移動和桌面。然後,我爲移動設備實現一次視圖界面,併爲桌面實現一次視圖界面。我使用延遲綁定來替換接口與類的實際實現。視圖在ClientFactory中實例化。GWT代碼拆分
我該如何做代碼拆分,以便所有的移動視圖都包含在一個文件中,並在另一個文件中的桌面的所有視圖?
我使用MVP和我有公共視圖界面的移動和桌面。然後,我爲移動設備實現一次視圖界面,併爲桌面實現一次視圖界面。我使用延遲綁定來替換接口與類的實際實現。視圖在ClientFactory中實例化。GWT代碼拆分
我該如何做代碼拆分,以便所有的移動視圖都包含在一個文件中,並在另一個文件中的桌面的所有視圖?
這是gwt.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!--
When updating your version of GWT, you should also update this DTD reference,
so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='apllo'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<inherits name="com.google.gwt.resources.Resources" />
<inherits name="com.google.gwt.user.Debug"/>
<inherits name="com.google.gwt.activity.Activity"/>
<inherits name="com.google.gwt.place.Place"/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name="com.google.gwt.visualization.Visualization"/>
<inherits name='com.apllo.client.FormFactor'/>
<entry-point class='com.apllo.client.Apllo'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<!-- Specify public paths -->
<public path="files"/>
<!-- Use ClientFactoryImpl by default -->
<replace-with class="com.apllo.client.factory.ClientFactoryImpl">
<when-type-is class="com.apllo.client.factory.ClientFactory"/>
</replace-with>
<!-- Use ClientFactoryImplMobile for mobile form factor. -->
<replace-with class="com.apllo.client.factory.ClientFactoryMobileImpl">
<when-type-is class="com.apllo.client.factory.ClientFactory"/>
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
<!-- 1.Use HeaderViewImpl by default -->
<replace-with class="com.apllo.client.view.computer.HeaderViewImpl">
<when-type-is class="com.apllo.client.view.HeaderView"/>
</replace-with>
<replace-with class="com.apllo.client.view.mobile.HeaderMobileViewImpl">
<when-type-is class="com.apllo.client.view.HeaderView"/>
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
<!-- 2 -->
<replace-with class="com.apllo.client.view.computer.StatusViewImpl">
<when-type-is class="com.apllo.client.view.StatusView"/>
</replace-with>
<replace-with class="com.apllo.client.view.mobile.StatusMobileViewImpl">
<when-type-is class="com.apllo.client.view.StatusView"/>
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
<!-- 3 -->
<replace-with class="com.apllo.client.view.computer.PublicViewImpl">
<when-type-is class="com.apllo.client.view.PublicView"/>
</replace-with>
<replace-with class="com.apllo.client.view.mobile.PublicMobileViewImpl">
<when-type-is class="com.apllo.client.view.PublicView"/>
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
<!-- 4 -->
<replace-with class="com.apllo.client.view.computer.MessageViewImpl">
<when-type-is class="com.apllo.client.view.MessageView"/>
</replace-with>
<replace-with class="com.apllo.client.view.mobile.MessageMobileViewImpl">
<when-type-is class="com.apllo.client.view.MessageView"/>
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
<!-- 5 -->
<replace-with class="com.apllo.client.view.computer.ContactsViewImpl">
<when-type-is class="com.apllo.client.view.ContactsView"/>
</replace-with>
<!-- 6 -->
<replace-with class="com.apllo.client.view.computer.AdvertisementViewImpl">
<when-type-is class="com.apllo.client.view.AdvertisementView"/>
</replace-with>
<!-- 7 -->
<replace-with class="com.apllo.client.view.computer.NewEditAdViewImpl">
<when-type-is class="com.apllo.client.view.NewEditAdView"/>
</replace-with>
<!-- 8 -->
<replace-with class="com.apllo.client.view.computer.AccountViewImpl">
<when-type-is class="com.apllo.client.view.AccountView"/>
</replace-with>
<replace-with class="com.apllo.client.view.mobile.AccountMobileViewImpl">
<when-type-is class="com.apllo.client.view.AccountView"/>
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
<!-- 9 -->
<replace-with class="com.apllo.client.view.computer.UtilityViewImpl">
<when-type-is class="com.apllo.client.view.UtilityView"/>
</replace-with>
</module>
解決方案:在formfactor.gwt.xml中,我註釋掉了
等待 - 如果你正在使用延遲綁定(?基於一些屬性值,我假設)換出的意見進行移動或桌面,那麼你已經在不同的排列 - 什麼需要分裂超越?你確定移動排列中有桌面類嗎?你看過SOYC報告,看看爲什麼它有這種情況,如果在你的設置中有其他錯誤? – 2013-04-30 22:25:38
您是對的我使用基於屬性值的延遲綁定,但SOYC報告指出僅生成桌面,平板電腦和手機的常見排列!一個大文件包含所有代碼。 **排列0('formfactor':'desktop','user.agent':'gecko1_8')('formfactor':'mobile','user.agent':'gecko1_8')('formfactor':'tablet' ,'user.agent':'gecko1_8')**我如何改變這個,併爲移動和桌面電腦有不同的排列? – 2013-05-01 19:22:20
要回答這個問題,你需要發佈模塊本身 - 描述你如何創建排列並以這種方式摺疊它們的細節。請爲您的應用程序發佈'.gwt.xml'文件 - 可能有多個文件,但重要的是看到任何提及'formfactor'的東西(儘管看到其他屬性也會有所幫助)。 – 2013-05-01 19:50:17