开发者

In GWT 2.0 CssResource, how to "print" GWT.getModuleBaseURL()

开发者 https://www.devze.com 2023-03-05 11:42 出处:网络
I have a cla开发者_高级运维ss that references a background image (and I don\'t want to upgrade to using imagebundles) so I need to print the \"base module url\" before my image url. How can I achieve

I have a cla开发者_高级运维ss that references a background image (and I don't want to upgrade to using imagebundles) so I need to print the "base module url" before my image url. How can I achieve this?

background: #BDE5F8 url("image/info.png") no-repeat 2px center;


You could always add a static function somewhere:

public static String getBackgroundUrl(){
     return com.google.gwt.core.client.GWT.getModuleName() + "/images/background.png";
}

And in your CSS

@eval BG_URL com.yourclass.getBackgroundUrl();

.myBackground { background-url:BG_URL; }


Including images in your ClientBundle really is the way to go. But then again, you've already mentioned that you're not going to do that.

Instead, consider using a value function to get the value of GWT.getModuleBaseURL():

.something {
    background: #BDE5F8 value('com.google.gwt.core.client.GWT.getModuleBaseURL', '/info.png') no-repeat 2px center;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号