Duplicate header entries in EPP 5.1 when adding headers using the doHeaders() method of JSR-286

Solution Unverified - Updated -

Issue

We have a requirement to add link, java script and meta tags in the head section of the page. Since this needs to be done dynamically, we are using the doHeaders() method as defined by JSR-286:

    public void doHeaders(RenderRequest request, RenderResponse response)
    {
        Element css = response.createElement("link");
        css.setAttribute("id", "jqueryDemo");
        css.setAttribute("type", "text/css");
        css.setAttribute("rel", "stylesheet");
        css.setAttribute("href", request.getContextPath() + "/css/jqueryDemo.css");
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, css);


        Element jQuery = response.createElement("script"); 
        jQuery.setAttribute("type", "text/javascript"); 
        jQuery.setAttribute("src", request.getContextPath() + "/js/jquery-1.4.2.min.js"); 
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jQuery); 

        Element jQueryUI = response.createElement("script"); 
        jQueryUI.setAttribute("type", "text/javascript"); 
        jQueryUI.setAttribute("src", request.getContextPath() + "/js/jquery-ui-1.8.1.custom.min.js"); 
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jQueryUI);         

    }   

But now we are getting redundant links in the head section of the generated html:

  <link href="/SupportTestPortlet/css/jqueryDemo.css" id="jqueryDemo" rel="stylesheet" type="text/css"/>  

  <link href="/SupportTestPortlet/css/jqueryDemo.css" id="jqueryDemo" rel="stylesheet" type="text/css"/>
  <script src="/SupportTestPortlet/js/jquery-1.4.2.min.js" type="text/javascript"></script>  

  <link href="/SupportTestPortlet/css/jqueryDemo.css" id="jqueryDemo" rel="stylesheet" type="text/css"/>
  <script src="/SupportTestPortlet/js/jquery-1.4.2.min.js" type="text/javascript"></script>
  <script src="/SupportTestPortlet/js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script>  

Environment

  • JBoss Enterprise Portal Platform (EPP)
    • 5.1.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.