質問

In my GWT 2.5 application, I got two entry points. EntryPoint A is the main application and EntryPoint B provides a widget version of my application.

Depending on a startup parameter, which I supply to the container, I want to enable/disable EntryPoint B. How can I achieve that? I know how to disable an EntryPoint completely during compile time by removing the correspondig declaration from my *.gwt.xml file.

役に立ちましたか?

解決

Seems like you could create two modules, where each provide a different entry point. Both would inherit from the common logic module. Each then has a different boostrap JavaScript URL (the .nocache.js). Disadvantage is that those will be completely different scripts to browser, so no caching benefits if you switch between widget and full version.

You can also do simple test within entry point method whether the entry point should be executed - just return if not. You can for instance check whether expected container element exists in DOM, or URL, or whatever. There is no much problem if two entry points are executed in a single module.

他のヒント

An GWT application can have only one Entrypoint. So instead of 2 Applications you can create 2 containers say ContainerA and ContainerB. In Entrypoint's onModuleLoad method you do an RPC call to fetch the Container deciding parameter. And based on the parameter you do

public void onModuleLoad()
{ 
      getRPCService.getStartUpParameter( AsyncCallBack<Parameter>
      { 
             public void onFailure()
             {
             }

             public void onSuccess(Parameter parameter)
             {
                   if( ContainerARequired( parameter ) )
                   {
                          RoolLayoutPanel.get().add( ContanerA )
                   }
                   else
                   {
                          RoolLayoutPanel.get().add( ContanerB )
                   }
             }
      });
}

With this method your js size will increase. So use code splitting and Run Async concepts to split the big js file in to smaller ones. And with this you can load only required js in to the browser.

In your gwt.xml

<define-property name="disableEntryPoint" values="true,false" />

<!-- Provide a default -->
<set-property name="alternateFeatures" value="false" />


<replace-with class="com.example.EntryPoint1">
  <when-type-is class="com.example.EntryPoint2" />
  <when-property-is name="disableEntryPoint" value="false" />
</replace-with>

Refer this :http://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties

maybe, it's better to have one application by own one entry point. in result, you will have 2 modules with own context and access paths:

  • /entryA
  • /entryB

also, two files:

  • EntryA.gwt.xml
  • EntryB.gwt.xml

those will include common stuff from Application.gwt.xml

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top