/** * Creates a {@link CssUrlReferenceHeaderItem} for the given url. * * <strong>Warning</strong>: the conditional comments don't work when injected dynamically * with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing * at the server side: * <code><pre> * public void renderHead(IHeaderResponse response) { * WebClientInfo clientInfo = (WebClientInfo) getSession().getClientInfo(); * ClientProperties properties = clientInfo.getProperties(); * if (properties.isBrowserInternetExplorer() && properties.getBrowserVersionMajor() >= 8) { * response.renderCSSReference(new PackageResourceReference(MyPage.class, "my-conditional.css" )); * } * } * </pre></code> * * @param url * context-relative url of the CSS resource * @param media * the media type for this CSS ("print", "screen", etc.) * @param condition * the condition to use for Internet Explorer conditional comments. E.g. "IE 7". * @return A newly created {@link CssUrlReferenceHeaderItem} for the given url. */ public static CssUrlReferenceHeaderItem forUrl(String url, String media, String condition) { return new CssUrlReferenceHeaderItem(url, media, condition); }
@Override public void render(Response response) { internalRenderCSSReference(response, UrlUtils.rewriteToContextRelative(getUrl(), RequestCycle.get()), getMedia(), getCondition(), getRel()); }
@Override public String toString() { return "CSSUrlReferenceHeaderItem(" + getUrl() + ")"; }
@Override public String toString() { return "CSSUrlReferenceHeaderItem(" + getUrl() + ")"; }
@Override public void render(Response response) { internalRenderCSSReference(response, UrlUtils.rewriteToContextRelative(getUrl(), RequestCycle.get()), getMedia(), getCondition(), getRel()); }
/** * Creates a {@link CssUrlReferenceHeaderItem} for the given url. * * <strong>Warning</strong>: the conditional comments don't work when injected dynamically * with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing * at the server side: * <code><pre> * public void renderHead(IHeaderResponse response) { * WebClientInfo clientInfo = (WebClientInfo) getSession().getClientInfo(); * ClientProperties properties = clientInfo.getProperties(); * if (properties.isBrowserInternetExplorer() && properties.getBrowserVersionMajor() >= 8) { * response.renderCSSReference(new PackageResourceReference(MyPage.class, "my-conditional.css" )); * } * } * </pre></code> * * @param url * context-relative url of the CSS resource * @param media * the media type for this CSS ("print", "screen", etc.) * @param condition * the condition to use for Internet Explorer conditional comments. E.g. "IE 7". * @return A newly created {@link CssUrlReferenceHeaderItem} for the given url. */ public static CssUrlReferenceHeaderItem forUrl(String url, String media, String condition) { return new CssUrlReferenceHeaderItem(url, media, condition); }
@Override public Iterable<?> getRenderTokens() { return Arrays.asList( "css-" + UrlUtils.rewriteToContextRelative(getUrl(), RequestCycle.get()) + "-" + media); }
/** * Creates a {@link CssUrlReferenceHeaderItem} for the given url. * * <strong>Warning</strong>: the conditional comments don't work when injected dynamically with * JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at * the server side: <code><pre> * public void renderHead(IHeaderResponse response) { * WebClientInfo clientInfo = (WebClientInfo) getSession().getClientInfo(); * ClientProperties properties = clientInfo.getProperties(); * if (properties.isBrowserInternetExplorer() && properties.getBrowserVersionMajor() >= 8) { * response.renderCSSReference(new PackageResourceReference(MyPage.class, "my-conditional.css" )); * } * } * </pre></code> * * @param url * context-relative url of the CSS resource * @param media * the media type for this CSS ("print", "screen", etc.) * @param condition * the condition to use for Internet Explorer conditional comments. E.g. "IE 7". * @param rel * the rel attribute content * @return A newly created {@link CssUrlReferenceHeaderItem} for the given url. */ public static CssUrlReferenceHeaderItem forUrl(String url, String media, String condition, String rel) { return new CssUrlReferenceHeaderItem(url, media, condition, rel); }
@Override public Iterable<?> getRenderTokens() { return Arrays.asList( "css-" + UrlUtils.rewriteToContextRelative(getUrl(), RequestCycle.get()) + "-" + media); }
/** * Creates a {@link CssUrlReferenceHeaderItem} for the given url. * * <strong>Warning</strong>: the conditional comments don't work when injected dynamically with * JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at * the server side: <code><pre> * public void renderHead(IHeaderResponse response) { * WebClientInfo clientInfo = (WebClientInfo) getSession().getClientInfo(); * ClientProperties properties = clientInfo.getProperties(); * if (properties.isBrowserInternetExplorer() && properties.getBrowserVersionMajor() >= 8) { * response.renderCSSReference(new PackageResourceReference(MyPage.class, "my-conditional.css" )); * } * } * </pre></code> * * @param url * context-relative url of the CSS resource * @param media * the media type for this CSS ("print", "screen", etc.) * @param condition * the condition to use for Internet Explorer conditional comments. E.g. "IE 7". * @param rel * the rel attribute content * @return A newly created {@link CssUrlReferenceHeaderItem} for the given url. */ public static CssUrlReferenceHeaderItem forUrl(String url, String media, String condition, String rel) { return new CssUrlReferenceHeaderItem(url, media, condition, rel); }
template.process(context, script); header.render( new CssUrlReferenceHeaderItem( ResponseUtils.buildURL(base, "/openlayers3/ol.css", null, URLType.RESOURCE), null,
@Override public void renderHead(Component component, IHeaderResponse response) { HttpServletRequest req = getGeoServerApplication().servletRequest(getRequest()); String baseUrl = baseURL(req); response.render( new CssUrlReferenceHeaderItem( buildURL( baseUrl, "openlayers3/ol.css", null, URLMangler.URLType.RESOURCE), null, null)); response.render( new JavaScriptUrlReferenceHeaderItem( buildURL( baseUrl, "openlayers3/ol.js", null, URLMangler.URLType.RESOURCE), null, false, "UTF-8", null)); } });