-1

We're migrating our application from GXT 3 to GXT 4 (and also from GWT 2.5 to 2.8.2) and one of the things that changed is that lot of components' body/text/heading/etc. now have two separate setters. One accepts String param and the other one accepts SafeHtml.

Here's an example:

    public void setToolTip(SafeHtml html) {
        ...
    }

    public void setToolTip(String text) {
        ...
    }

The difference in those is that the method accepting String does not render html elements. The other one, however, does, which is perfectly fine if one uses Java code to build UI. Unfortunately, we do have a lot of our UI built using GWT's XML method and I would like it to stay this way.

The problem is that I cannot figure out how to show e.g. a tooltip with SafeHtml body. When I try to do that I get compilation errors. This is what I put in my XML file:

...
<form:TextArea ui:field="testField" toolTip="{messages.testMesssage}" >
...

And this is the error:

[ERROR] java.lang.String required, but {testMess.test} returns com.google.gwt.safehtml.shared.SafeHtml: <form:TextArea toolTip='{messages.testMesssage}' ui:field='testField'> (:184)

Thanks!

1 Answers1

2

You may want to look at the GXT examples for tooltips in UiBinder. In there, it shows using the ToolTipConfig instead of trying to set "tooltip" directly.

  <ui:with type="com.sencha.gxt.widget.core.client.tips.ToolTipConfig" 
          field="toolTipConfig">
      <ui:attributes title="Information" body="Prints the current document" />
  </ui:with>
  
  ...
  
  <form:TextArea ui:field="testField" toolTipConfig="{toolTipConfig}" />
  • Yes, I've tried that as well, but I get the same error. The problem seems to be that the version I can only use (4.0.0) has two setBody methods - one accepting string and the other one accepting safehtml: https://docs.sencha.com/gxt/4.x/javadoc/gxt-4.0/com/sencha/gxt/widget/core/client/tips/ToolTipConfig.html while the examples probably use the newest one 4.0.4 which has only one method with safehtml as param: https://docs.sencha.com/gxt/4.x/javadoc/gxt-4.0.4/com/sencha/gxt/widget/core/client/tips/ToolTipConfig.html and it seems that this would resolve the issue, however, I can only use 4.0.0. – HiddenHeathen Jun 03 '21 at 21:20
  • That's odd. I went back to 4.0.0-ea (not sure if I have any later version) and the Explorer example for ToolTips is the same. In your 4.0.0 release you have, it should have the explorer demo app with the UiBinder version of tooltips. If all else fails, you could also throw in a @UiFactory in the owning class and just have it create a ToolTipConfig with any argument you want. – Justin Hickman Jun 04 '21 at 17:33
  • Thanks for the suggestions. The easiest/quickest way I found was to extend ToolTipConfig class and "revert" changes Sencha made in 4.0.0-ea, where they removed separate methods for setting String/SafeHTML in body and header. See release notes where they mention that change: [link](https://docs.sencha.com/gxt/4.x/guides/announcements/release_notes.html#announcements-_-release_notes_-_release_4_0_0_ea__9_24_2015_). – HiddenHeathen Jun 16 '21 at 20:24