Problem with SVGImage and uibinder

40 views
Skip to first unread message

Doc19537

unread,
Nov 15, 2016, 8:57:05 AM11/15/16
to lib-gwt-svg

Hi,

I using lib-gwt-svg 0.5.12 with GWT 2.8.
I have notice that on SVGImage,  if setClassNameBaseVal is called before setResource, it's failed because the svg element doesn't exist.

I am using uibinder with
<svgui:SVGImage resource="{resources.tabstandardSvg}" classNameBaseVal="tabIconeSize" />

If i am in SDM the generated code is:
      f_SVGImage2.setResource(get_resources().tabstandardSvg());
      f_SVGImage2.setClassNameBaseVal("tabIconeSize");

But in production mode the generated code is:
      f_SVGImage2.setClassNameBaseVal("tabIconeSize");
      f_SVGImage2.setResource(get_resources().tabstandardSvg());

So my program got an javascript exception in production

I will create my own SVGImage to fix the bug but i think that the library need a fix.


Lukas Laag

unread,
Nov 16, 2016, 3:52:31 AM11/16/16
to lib-gwt-svg
Hi
Thanks for reporting this. I think this can probably be fixed by tweaking SVGImageParser a little (maybe by calling UiBinderWriter.addInitStatement instead of UiBinderWriter.addStatement or something along those lines). I will test this and get back to you. If you want you can raise an issue at https://github.com/laaglu/lib-gwt-svg/issues, otherwise I will do that myself
Regards
Lukas

Lukas Laag

unread,
Nov 23, 2016, 5:08:06 AM11/23/16
to lib-gwt-svg
Hi,

I have tried to reproduce your problem but I was not able to.
For this I have used https://www.vectomatic.org/libs/lib-gwt-svg/samples where the 'widgets' contains code very close to yours, notably this UiBinder declaration:

<svgui:SVGImage ui:field="hearts" resource="{resources.hearts}" classNameBaseVal="{style.hearts}"/>

which yields the corresponding code in production mode (with lib-gwt-svg 0.5.12 and openjdk version "1.8.0_101")


private org.vectomatic.dom.svg.ui.SVGImage build_hearts() {
    // Creation section.
    final org.vectomatic.dom.svg.ui.SVGImage hearts = (org.vectomatic.dom.svg.ui.SVGImage) GWT.create(org.vectomatic.dom.svg.ui.SVGImage.class);
    // Setup section.
    hearts.setResource(get_resources().hearts());
    hearts.setClassNameBaseVal("" + get_style().hearts() + "");

hearts.addMouseOutHandler(handlerMethodWithNameVeryUnlikelyToCollideWithUserFieldNames1);

hearts.addMouseOverHandler(handlerMethodWithNameVeryUnlikelyToCollideWithUserFieldNames2);

    this.owner.hearts = hearts;

    return hearts;
}


There is probably a subtle difference between your test case and mine. I am going to need more input to try to understand it.

Lukas

Reply all
Reply to author
Forward
0 new messages