问题描述
如果用户通过移动网络浏览器或桌面网络浏览器访问,我希望在我的GWT应用程序中加载不同的用户界面。我想知道如何编辑我的Application.gwt.xml文件,根据外形因素更改哪个入口点类加载。我认为这可能是沿着这些线,但我只是黑客,所以我想知道如果有人有任何想法?
< entry-point class =webapp.client.WebAppEntryPoint>
< when-property-is name =formfactorvalue =desktop/>
< / entry-point>
< entry-point class =webapp.client.MobileAppEntryPoint>
< when-property-is name =formfactorvalue =mobile/>
< / entry-point>
干杯。
已解决:
好的,谢谢大家的回复。我用一点点的答案来解决问题!首先我跟踪了SSR并查看了示例FormFactor.gwt.xml文件。我将其复制到我的项目中,并在我的App.gwt.xml文件中引用它。然后我跟着Colins,并将下面的代码添加到我的App.gwt.xml文件中,以便基于表单因子加载不同的EntryPoint:
< entry-point class =webapp.client.AbstractEntryPoint/>
< replace-with class =webapp.client.WebAppEntryPoint>
< when-type-is class =webapp.client.AbstractEntryPoint/>
< when-property-is name =formfactorvalue =desktop/>
< / replace-with>
< replace-with class =webapp.client.MobileAppEntryPoint>
< when-type-is class =webapp.client.AbstractEntryPoint/>
< when-property-is name =formfactorvalue =mobile/>
< / replace-with>
Im looking to load a different user interface in my GWT application if the user is accessing from a mobile web browser or desktop web browser. I was wondering how I would edit my Application.gwt.xml file change which entry point class is loaded based on the the form factor. I thought it might be something along these lines but i'm kind of just hacking so I was wondering if anyone had any ideas?
<entry-point class="webapp.client.WebAppEntryPoint">
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<entry-point class="webapp.client.MobileAppEntryPoint">
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
Cheers.
SOLVED:
Okay, thanks to everyone who replied. I used a little bit of everyones answer to get to the solution! Firstly I followed SSRs and had a look at the example FormFactor.gwt.xml file. I copied this into my project and referred to it in my App.gwt.xml file. I then followed Colins and added the following code to my App.gwt.xml file in order to load a different EntryPoint based upon form factor:
<entry-point class="webapp.client.AbstractEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</replace-with>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</replace-with>
这篇关于根据形状因子更改入口点类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!