Re: How to dynamically load css style in GWT-based application

2015-04-09 Thread Ltearno
Hi !

The tool HexaCss for GWT answers exactly your needs (as i understand them).

With it you can produce several CSS files for the same GWT application (and 
still using them in a type-safe way, like with CssResource) and you can 
then change them dynamically without reloading the application.

Here is the link to the tool (open source on github)
http://www.lteconsulting.fr/hexacss/

I hope this helps you !

Thanks
Arnaud

Le mercredi 12 décembre 2007 10:22:59 UTC+1, yadong a écrit :
>
> I am working on an web application in which the css style varies based 
> on different user, I am curious how to load css file dynamically. 
> Currently we use JSTL tag to access server side parameter to determine 
> which css file needs to be used.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to dynamically load css style in GWT-based application

2014-09-02 Thread Benjamin Cuthbert
Okay interesting. So do you have the css deployed into the war? Or unpacked 
on the server?

On Tuesday, September 2, 2014 4:31:02 PM UTC+1, Yuri C wrote:
>
> In my case the idea was to have a CSS per screen. I call the server the 
> first time the very first time that particular "screen" is revealed.
>
> On Tuesday, September 2, 2014 3:56:56 AM UTC-4, Benjamin Cuthbert wrote:
>>
>> Hi Yuri,
>>
>> How do you make the call to the server? via the onModuleLoad?
>>
>> On Tuesday, January 15, 2013 6:52:57 PM UTC, Yuri C wrote:
>>>
>>> I have 2 CSS loaders.
>>> One relies on  tags. This is the preferred way to load CSS as long 
>>> as you don't need to be notified when the stylesheet is loaded.
>>> Another one updates the page with CSS loaded via a separate HTTP request 
>>> and you can register a callback to be notified when the CSS is loaded.
>>>
>>>
>>> On Wednesday, December 12, 2007 4:22:59 AM UTC-5, yadong wrote:

 I am working on an web application in which the css style varies based 
 on different user, I am curious how to load css file dynamically. 
 Currently we use JSTL tag to access server side parameter to determine 
 which css file needs to be used.
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to dynamically load css style in GWT-based application

2014-09-02 Thread Yuri C
In my case the idea was to have a CSS per screen. I call the server the 
first time the very first time that particular "screen" is revealed.

On Tuesday, September 2, 2014 3:56:56 AM UTC-4, Benjamin Cuthbert wrote:
>
> Hi Yuri,
>
> How do you make the call to the server? via the onModuleLoad?
>
> On Tuesday, January 15, 2013 6:52:57 PM UTC, Yuri C wrote:
>>
>> I have 2 CSS loaders.
>> One relies on  tags. This is the preferred way to load CSS as long 
>> as you don't need to be notified when the stylesheet is loaded.
>> Another one updates the page with CSS loaded via a separate HTTP request 
>> and you can register a callback to be notified when the CSS is loaded.
>>
>>
>> On Wednesday, December 12, 2007 4:22:59 AM UTC-5, yadong wrote:
>>>
>>> I am working on an web application in which the css style varies based 
>>> on different user, I am curious how to load css file dynamically. 
>>> Currently we use JSTL tag to access server side parameter to determine 
>>> which css file needs to be used.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to dynamically load css style in GWT-based application

2014-09-02 Thread Benjamin Cuthbert
Hi Yuri,

How do you make the call to the server? via the onModuleLoad?

On Tuesday, January 15, 2013 6:52:57 PM UTC, Yuri C wrote:
>
> I have 2 CSS loaders.
> One relies on  tags. This is the preferred way to load CSS as long 
> as you don't need to be notified when the stylesheet is loaded.
> Another one updates the page with CSS loaded via a separate HTTP request 
> and you can register a callback to be notified when the CSS is loaded.
>
>
> On Wednesday, December 12, 2007 4:22:59 AM UTC-5, yadong wrote:
>>
>> I am working on an web application in which the css style varies based 
>> on different user, I am curious how to load css file dynamically. 
>> Currently we use JSTL tag to access server side parameter to determine 
>> which css file needs to be used.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to dynamically load css style in GWT-based application

2013-01-15 Thread Yuri C
I have 2 CSS loaders.
One relies on  tags. This is the preferred way to load CSS as long as 
you don't need to be notified when the stylesheet is loaded.
Another one updates the page with CSS loaded via a separate HTTP request 
and you can register a callback to be notified when the CSS is loaded.


On Wednesday, December 12, 2007 4:22:59 AM UTC-5, yadong wrote:
>
> I am working on an web application in which the css style varies based 
> on different user, I am curious how to load css file dynamically. 
> Currently we use JSTL tag to access server side parameter to determine 
> which css file needs to be used.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/6oUGJ0wL408J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

package escort.client.utils;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;

import --;

public class CssLinkLoader {

	private static Logger LOGGER = LoggerFactory.getLogger(CssLinkLoader.class);

	public static interface OnLoad {

		void loaded();

	}

	private static final String SCREEN_CSS_SERVER_FOLDER = "resources/css/screens/";

	/**
	 * All screen related CSS files are kept in one folder on the server. This is a convenience method
	 * which knows in which folder the those CSS files are located. When referencing images and other
	 * resources from the CSS use paths relative to this CSS file.
	 *
	 * @param cssFileName
	 */
	public static void loadScreenCss(String cssFileName) {
		String screenCssFileName = SCREEN_CSS_SERVER_FOLDER + cssFileName;
		if (Document.get().getElementById(screenCssFileName) == null) {
			loadCss(screenCssFileName);
		}
	}

	public static void unloadCss(String cssFileName) {
		Element cssElement = Document.get().getElementById(cssFileName);
		if (cssElement != null) {
			cssElement.removeFromParent();
		}
	}

	private static native Boolean isCssLinkLoaded(String cssFileName) /*-{
var link = $doc.getElementById(cssFileName);
try {
	if (link.sheet && link.sheet.cssRules.length > 0) {
		return true;
	} else if (link.styleSheet && link.styleSheet.cssText.length > 0) {
		return true;
	} else if (link.innerHTML && link.innerHTML.length > 0) {
		return true;
	}
} catch (ex) {
}
return false;
	}-*/;

	private static native void loadCss(String url) /*-{
var l = $doc.createElement("link");
l.setAttribute("id", url);
l.setAttribute("rel", "stylesheet");
l.setAttribute("type", "text/css");
l.setAttribute("href", url + "?v=1"); // Make sure this request is not cached
$doc.getElementsByTagName("head")[0].appendChild(l);
	}-*/;

}
package escort.client.utils;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;

import --

public class CssStyleLoader {

	private static Logger LOGGER = LoggerFactory.getLogger(CssStyleLoader.class);

	public static interface OnLoad {

		void loaded();

	}

	private static final String SCREEN_CSS_SERVER_FOLDER = "resources/css/screens/";

	/**
	 * When referencing images and other resources from the CSS use paths relative to the application.
	 **/
	public static void loadScreenCss(String cssFileName, OnLoad callback) {
		// loadCss(SCREEN_CSS_SERVER_FOLDER + cssFileName, callback);
		loadCss(SCREEN_CSS_SERVER_FOLDER + cssFileName, callback);
	}

	public static void loadCss(final String cssFileName, final OnLoad callback) {
		if (Document.get().getElementById(cssFileName) != null) {
			return;
		}

		RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, cssFileName + "?v=1"); // Do not cache
		requestBuilder.setCallback(new RequestCallback() {
			@Override
			public void onResponseReceived(Request request, Response response) {
if (!createStyleElement(cssFileName, response.getText())) {
	return;
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
	@Override
	public void execute() {
		GWT.log("Loaded stylecheet: " + cssFileName);
		callback.loaded();
	}
});
			}

			@Override
			public void onError(Request request, Throwable exception) {
GWT.log("Failed to load stylecheet: " + cssFileName);
LOGGER.error("Failed to load stylecheet: " + cssFileName);
			}
		});
		try