Class CssHeaderItem

    • Method Detail

      • getId

        public String getId()
        Returns:
        an optional markup id for the <link> HTML element that will be rendered for this header item
      • setId

        public CssHeaderItem setId​(String markupId)
        Parameters:
        markupId - an optional markup id for this header item
        Returns:
        this object, for method chaining
      • forReference

        public static CssReferenceHeaderItem forReference​(ResourceReference reference,
                                                          PageParameters pageParameters,
                                                          String media,
                                                          String rel)
        Creates a CssReferenceHeaderItem for the given reference. Warning: 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:
         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" ));
           }
         }
         
        Parameters:
        reference - a reference to a CSS resource
        pageParameters - the parameters for this CSS resource reference
        media - the media type for this CSS ("print", "screen", etc.)
        rel - the rel attribute content
        Returns:
        A newly created CssReferenceHeaderItem for the given reference.
      • forUrl

        public static CssUrlReferenceHeaderItem forUrl​(String url,
                                                       String media,
                                                       String rel)
        Creates a CssUrlReferenceHeaderItem for the given url. Warning: 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:
         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" ));
           }
         }
         
        Parameters:
        url - context-relative url of the CSS resource
        media - the media type for this CSS ("print", "screen", etc.)
        rel - the rel attribute content
        Returns:
        A newly created CssUrlReferenceHeaderItem for the given url.