PDA

View Full Version : EL and setStyleAttribute: Problem with value containing semicolon ";"



mrechtien
6 Sep 2010, 6:41 AM
Hi,

I tried to apply a custom background image style. The image itself comes base64 encoded
and therefore the elements style should look like something similar to:

style="background: url("data:image/png;base64,iVBORw0KGgoAAA...***...AABJRU5ErkJggg==") no-repeat scroll 0px 0px transparent;"

Unfortunately in com.extjs.gxt.ui.client.core.El.applyStyles(String) the style value of the component is
separated by a regular expression dividing the string on ";" which unfortunately is also containt within the
background styles value. The resulting html does not contain the correct styles then..

Is there any way to circumvent this problem without doing some handcrafted stuff in onRender or onLoad?

Thank you and best regards,
Markus

sven
6 Sep 2010, 6:44 AM
Instead of calling applyStyles you can use setStyleAttribute for each style manually. There is no otehr workaround at the moment.

To make this work prerender in component, you can only use the Render event at the moment. I iwll change how setStyleAttribute works on the component class.

snekse
14 Jun 2011, 2:48 PM
I'm new to GXT and GWT, so sorry if this is a dumb question, but what do you mean "you can only use the Render event at the moment"?

I have the following code:


LayoutContainer panel = new LayoutContainer(new FlowLayout());
panel.setHeight(105);
String url = images.cms_header_test().getURL();
panel.setStyleAttribute("backgroundImage", "url('"+url+"')");


But all the style comes out as:

style="background-image: url("data:image/jpeg");"

Is there some other way for setting a background image (while still using an ImageResource) that I'm not aware of?