Friday, September 6, 2013

Re: Help on defered binding with Internet Explorer



On Friday, September 6, 2013 11:49:25 AM UTC+2, Thomas Lefort wrote:
I have two cases of defered binding not working the way I thought it would. The problem I have is with IE.

1) I have the following rule:
  <replace-with class="com.metaaps.webapps.libraries.client.widget.PasswordTextBoxIE8">
    <when-type-is class="com.metaaps.webapps.libraries.client.widget.PasswordTextBox"/>
    <when-property-is name="user.agent" value="ie8" />
  </replace-with>

My assumption is that the class would be replaced ONLY for IE8 browsers, however it is replaced for ALL IE versions.

Do "ALL IE versions" include IE6/IE7? or only IE8/IE9/IE10/etc. ?
What matters is not much the "browser version", but the "document mode" it uses (for IE8+).
There's also the case that ie8 is the fallback for the ie9 permutation, so maybe even if your IE9/IE10 uses the ie9 permutation, it'll fallback to that rule ebcause you don't have any rule targetting the ie9 permutation. Try adding either:

<replace-with class="com.metaaps.webapps.libraries.client.widget.PasswordTextBox">
  <when-type-is class="com.metaaps.webapps.libraries.client.widget.PasswordTextBox"/>
  <when-property-is name="user.agent" value="ie9" />
</replace-with>

or a:

<not>
  <when-property-is name="user.agent" value="ie9"/>
</not>

to your existing rule.
 
2) I have the following rule:
  <replace-with class="com.metaaps.webapps.earthimages.client.ui.widget.ResourceWidgetIE9">
<when-type-is class="com.metaaps.webapps.earthimages.client.ui.widget.ResourceWidget"/>
    <any>
      <when-property-is name="user.agent" value="ie6"/>
      <when-property-is name="user.agent" value="ie8"/>
      <when-property-is name="user.agent" value="ie9"/>
    </any>
  </replace-with>

ResourceWidget is actually a Generic class.

In this case, the ResourceWidget is never replaced by the ResourceWidgetIE9 in the classes that extend ResourceWidget.

I don't understand.

Is there any obvious mistake in my rules or any limitations of defered binding I overlooked?

  1. using deferred binding at the widget level is error-prone. You'd generally extract/abstract differences into an "Impl" class that you GWT.create() *within* your widget, so that it works whether your widget is GWT.create()d or new'd.
  2. deferred binding is about instantiating a different class than the one you passed to GWT.create(). It doesn't mess with class hierarchies (if something extends ResourceWidget, it won't be "rewritten" to extend ResourceWidgetIE9). GWT.create() is a factory, not a "code-rewriting" or "bytecode-rewriting" tool.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment