<p>I am overriding a lot of SAP's Portal functionality in my current project.  I have to create a custom fixed width framework, custom iView trays, custom KM API functionality, and more.</p>

<p>With all of these custom parts, I will not be using a lot of the style functionality implemented by SAP's Theme editor.  What I would like to do is create an external CSS, store it outside of the Portal and reference it.  Storing externally will allow for easier updates rather than storing the CSS within a portal application.  It would also allow for all custom pieces to have their styles in once place.</p>

<p>Unfortunately, I've not found a way to gain access to the HEAD portion of the page that allows me to insert an external stylesheet.  Portal Applications can do so using the IResource object to gain access to internal references, but not items on another server.</p>

<p>I'm looking for any ideas that would allow me to gain this functionality.  I have <a href="https://www.sdn.sap.com/irj/sdn/thread?threadID=1046064&amp;tstart=0" rel="nofollow noreferrer">x-posted on SAP's SDN</a>, but I suspect I'll get a better answer here.</p>

[{'answer_id': 63381, 'author': 'Eric  DeLabar', 'author_id': 7556, 'author_profile': 'https://Stackoverflow.com/users/7556', 'pm_score': 3, 'selected': True, 'text': "<p>I'd consider it  dirty hack, but as a non-Portal developer I'd consider using JavaScript to insert a new link element in the head pointing to your new CSS file.  Of course you'd have a flash of un-styled content because the script probably won't run until after part of the page has been downloaded and rendered, but it may be an adequate solution.</p>\n"}, {'answer_id': 66035, 'author': 'Mike Cornell', 'author_id': 419788, 'author_profile': 'https://Stackoverflow.com/users/419788', 'pm_score': 0, 'selected': False, 'text': '<p>I hate that I\'m answering my own question, but I did find a potential solution that\'s not documented well and in typical SAP fashion uses deprecated methods.  So it might be a slightly less dirty hack than what Eric suggested.  I found it through an unrelated SDN forum post.</p>\n\n<p>Basically, you dive into the request object and gather the PortalNode.  Once you have that, you ask it for a value of a IPortalResponse.  This object can be cast to a PortalHtmlResponse.  That object has a deprecated method called getHtmlDocument.  Using that method, you can use some Html mirror objects to get the head and insert new links.</p>\n\n<p>Sample:</p>\n\n<pre><code>IPortalNode node = request.getNode().getPortalNode();\nIPortalResponse resp = (IPortalResponse) node.getValue(IPortalResponse.class.getName());\nif (resp instanceof PortalHtmlResponse) {\n    PortalHtmlResponse htmlResp = (PortalHtmlResponse) resp;\n    HtmlDocument doc = htmlResp.getHtmlDocument();\n    HtmlHead myHead = doc.getHead();\n    HtmlLink cssLink = new HtmlLink("http://myserver.com/css/mycss.css");\n    cssLink.setType("text/css");\n    cssLink.setRel("stylesheet");\n    myHead.addElement(cssLink);\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/62406', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/419788/']