When you use styleName='{style.myStyle}', what happens behind the
curtain is that some UiBinder-generated java code calls
http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/UIObject.html#setStyleName%28java.lang.String,%20boolean%29,
which in turns sets the Element classname javascript property. This does
not work for the SVG DOM, because, though SVG DOM objects also have a
classname property, it is not a string, but an SVGAnimatedString
(because CSS classname can be animated in SVG). Thus, in javascript, one
needs to change the classname.baseVal property to set the CSS className.
This is what is done the
http://www.vectomatic.org/mvn-sites/lib-gwt-svg/apidocs/org/vectomatic/dom/svg/OMSVGElement.html#setClassNameBaseVal%28java.lang.String%29,
a method which is callable by UiBinder-generated code.
What you suggest:
<ui:style>
.searchButton { float: left; padding-left: 10px; width: 25px; height:
25px; }
</ui:style>
...
<svg:SVGImage ui:field='searchButton' resource='{res.glass}'
classNameBaseVal='{style.searchButton}' />
ought to work as it is the same thing I do in my widget sample
http://www.vectomatic.org/gwt/lib-gwt-svg-samples-latest/lib-gwt-svg-samples.html.
Since the sample is based on 2.7.0 and works, I do not think the problem
is related to a migration problem to 2.7.0
The error message you indicate seems to indicate that the resource is
somehow not set (the SVGImage svgElement, which ought to be se by
resource='{res.glass}', is undefined). Do you have a line like:
<ui:with field='res' type='...' />. Does it contain SVGResource or
SVGExternalResource ? In the latter case it probably would not work as
the svgElement would not be immediately available, but later, after the
async call to load the resource has completed.
Could this be a browser or OS problem ? I develop/test on linux
(opensuse13.2)+firefox(36) or chromium(41). Does the widget sample work
on your system ?
Otherwise there has to be a subtle difference someplace accounting for
the different behavior. I do not know how I can help you unless you can
create a minimalistic sample I could debug. Maybe another idea would be
to look at the generated code (in target/gen)
Lukas