Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use style properties on SVGImage in UiBinder #15

Open
jcairney opened this issue Mar 10, 2015 · 3 comments
Open

Can't use style properties on SVGImage in UiBinder #15

jcairney opened this issue Mar 10, 2015 · 3 comments

Comments

@jcairney
Copy link

I'm using lib-gwt-svg 0.5.10 with GWT-2.7.0, and found that when I tried:

<svg:SVGImage ui:field="popoutButton" resource="{my.resourceBundle.mySVGresource}" />

it works fine, but as soon as I try to add style name attributes, I see a null pointer exception when instantiating the UiBinder implementation class due to 'element' var not being set in the UiObject super class of SVGImage (I think. Each debugging method and browser I tested gave me a null pointer assertion or exception in different but related classes in the library). The failing markup looked like this:

<svg:SVGImage ui:field="popoutButton" resource="{my.resourceBundle.mySVGresource}" classNameBaseVal="{style.popoutBtn}"/>

or this:

<svg:SVGImage ui:field="popoutButton" resource="{my.resourceBundle.mySVGresource}" styleName="{style.popoutBtn}"/>

The workaround was to leave the classNameBaseVal attribute there, but set the resource at the java level by calling the SVGResource contructor of SVGImage, and setting @UiField(provided = true) on the popoutButton field.

@laaglu
Copy link
Owner

laaglu commented Mar 13, 2015

Hi,
This problem seems similar to the one for which I recently received a pull request. I propose to merge the discussion of in this issue thead.

I have not been able to reproduce the probem. Here is what I have attempted.
Using a recent build stack (Apache Maven 3.2.3, openjdk version "1.8.0_40", gwt-2.7.0, lib-gwt-svg-0.5.11-SNAPSHOT), I tried to modify the widgets part of lib-gwt-svg-samples in the following way.

Line https://github.com/laaglu/lib-gwt-svg-samples/blob/master/src/main/resources/org/vectomatic/svg/samples/client/widgets/WidgetsSample.ui.xml: 193

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

is changed to:

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

I then rebuilt the code, and looked at the code generated by GWT/UiBinder for this part, in target/gen/org/vectomatic/svg/samples/client/widgets/WidgetsSample_WidgetsSampleBinderImpl.java. Here is the relevant excerpt for the generated code

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.setWidth("355px");
...
return hearts;
}

As can be seen, the resource is clearly set immediately after the constructor is called, which seems in accordance to what is done by the org.vectomatic.dev.svg.impl.gen.SVGImageParser in lib-gwt-svg. NPE cannot occur in this context.

Can you provide more details on the issue or a test case to reproduce ?

@marian486
Copy link

Hello,
I have same problem !
without styleName working properly but after set styleName I get always exception ....

<svg:SVGImage ui:field="imguser" resource="{resources.loginsvg}" styleName="picall"/>

Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot set property 'className' of undefined
at Unknown.$setClassName(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.setStyleName(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.setStyleName_1(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.build_imguser(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.get_imguser(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.build_f_HTMLPanel1(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.get_f_HTMLPanel1(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.createAndBindUi_4(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.createAndBindUi_3(sm.embedded.smbar.SmbarWidgetset-0.js)
at Unknown.NoRegisterDialogUi(sm.embedded.smbar.SmbarWidgetset-0.js)

@marian486
Copy link

I see i have version 0.5.10 !
how i can download lib-gwt-svg-0.5.11-SNAPSHOT ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants