DOM.setStyleAttribute(getElement(), "background-image",
" url(http://localhost:8888/com.suffolksoft.ImageTest/images/
toprepeat.PNG);");
to work.
getElement() is invoked on a FlowPanel.
Here is what I know:
1) If I do getElement().toString() right after the above call (hosted
mode), the html representation
I get is what I expect, ie:
<DIV style="background-image: url(http://localhost:8888/
com.suffolksoft.ImageTest/images/toprepeat.PNG);"><IMG
class=CloseButton height=14 src="images/close-static.png" width=14
__eventBits="98429" onchange="null"></DIV>
2) If I run this in either IE or firebox, I don't see the background
I expect.
3) If I run under firefox and look at HTML using firebug, the style
attribute
does not appear on <div> tag, in spite of (1) above.
4) When I edit with firebug and type style attribute as above, naming
url of image I desire (as in (1), I get what I expect. That is, image
becomes background of <div> that is rendering of FlowPanel.
At some level, setStyleAttribute works (per (1)) but somehow browser
is
ignoring/stripping style attribute.
What I am trying to do is set a background on a panel without
having to use CSS files. I don't want to use CSS files because
I am packaging image with a component in a jar so I have to
reference image with GWT.getModuleBaseURL().
I am open to other approaches but I am
curious why this one does not work.
Thanks
Rob
I am trying to get :
DOM.setStyleAttribute(getElement(), "background-image",
toprepeat.PNG);");
to work.
getElement() is invoked on a FlowPanel.
Here is what I know:
1) If I do getElement().toString() right after the above call (hosted
mode), the html representation
I get is what I expect, ie:
<DIV style="background-image: url( http://localhost:8888/
com.suffolksoft.ImageTest/images/toprepeat.PNG);"><IMG
class=CloseButton height=14 src="images/close-static.png" width=14
__eventBits="98429" onchange="null"></DIV>
2) If I run this in either IE or firebox, I don't see the background
I expect.
3) If I run under firefox and look at HTML using firebug, the style
attribute
does not appear on <div> tag, in spite of (1) above.
4) When I edit with firebug and type style attribute as above, naming
url of image I desire (as in (1), I get what I expect. That is, image
becomes background of <div> that is rendering of FlowPanel.
At some level, setStyleAttribute works (per (1)) but somehow browser
is
ignoring/stripping style attribute.
What I am trying to do is set a background on a panel without
having to use CSS files. I don't want to use CSS files because
I am packaging image with a component in a jar so I have to
reference image with GWT.getModuleBaseURL().
I am open to other approaches but I am
curious why this one does not work.
Thanks
Rob
--
Ian
http://roughian.com
5) If I try camel case, backgroundImage" I get an exception
in hosted mode.
[ERROR] Unable to load module entry point class
com.gwtsolutions.client.ImageTest
com.google.gwt.core.client.JavaScriptException: JavaScript Error
exception: Invalid argument.
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:
435)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeVoid(ModuleSpaceIE6.java:
320)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:
141)
at
com.google.gwt.user.client.impl.DOMImpl.setStyleAttribute(DOMImpl.java:
338)
at com.google.gwt.user.client.DOM.setStyleAttribute(DOM.java:881)
On Mar 2, 9:31 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> camelCase
>
> so "backgroundImage"
>
> On 03/03/07, suffolks...@gmail.com <suffolks...@gmail.com> wrote:
>
>
>
>
>
> > I am trying to get :
>
> > DOM.setStyleAttribute(getElement(), "background-image",
> > " url(http://localhost:8888/com.suffolksoft.ImageTest/images/
> > toprepeat.PNG);");
>
> > to work.
>
> > getElement() is invoked on a FlowPanel.
>
> > Here is what I know:
> > 1) If I do getElement().toString() right after the above call (hosted
> > mode), the html representation
> > I get is what I expect, ie:
>
> > <DIV style="background-image: url(http://localhost:8888/
I am trying to get :
DOM.setStyleAttribute(getElement(), "background-image",
" url(http://localhost:8888/com.suffolksoft.ImageTest/images/
toprepeat.PNG);");
to work.
getElement() is invoked on a FlowPanel.
Here is what I know:
1) If I do getElement().toString() right after the above call (hosted
mode), the html representation
I get is what I expect, ie:
<DIV style="background-image: url(http://localhost:8888/
com.suffolksoft.ImageTest/images/toprepeat.PNG);"><IMG
class=CloseButton height=14 src="images/close- static.png" width=14
FlowPanel p =
new FlowPanel();DOM.setStyleAttribute(p.getElement(),
"backgroundImage", "url(image.jpg)" );DOM.setStyleAttribute(p.getElement(),
"backgroundColor", "yellow" );p.add(
new HTML("x"));RootPanel.get().add(p);
It was, of all things, the semicolon.
D*mn.
Thanks
Rob
On Mar 2, 10:48 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> Well, what you see in the toString() is not reliable, but you have to use
> camelCase and you probably aren't helping with the spaces and semicolon
> (dunno for sure, but I do know it's not required.
>
> But...the following works for definite:
>
> FlowPanel p = *new* FlowPanel();
>
> DOM.*setStyleAttribute*(p.getElement(), "backgroundImage", "url(image.jpg)"
> );
>
> DOM.*setStyleAttribute*(p.getElement(), "backgroundColor", "yellow");
>
> p.add(*new* HTML("x"));
>
> RootPanel.*get*().add(p);
>
> --
> Ianhttp://roughian.com