cancel
Showing results for 
Search instead for 
Did you mean: 

How to include a CSS from another project

Former Member
0 Kudos

Hi all,

I'm developing an AbstractPortalComponent which uses some of my own defined stylesheets. I can include the stylesheet defined in my own project by this:

com.sapportals.portal.prt.resource.IResource myStyle = 
request.getResource("css", "css/my_nav.css");    
response.include(request, myStyle);

Now I need to include another CSS but from another project.

I tried also to get the response and write the HTML code but it writes it into the <BODY></BODY> tag and the CSS is not used when rendering the document:


...</head>
<body class="prtlBody urFontBaseFam urScrl">
<LINK REL=stylesheet href="https://answers.sap.com/irj/portalapps/myProject/css/zglobal.css" TYPE="text/css">
...

Does anybody know the solution?

Thanks in advance,

Romano

Accepted Solutions (1)

Accepted Solutions (1)

darrell_merryweather
Active Contributor
0 Kudos

There are document hooks that you can use to insert things into the response of a page being written to the client.

Therefore, if you create a service which implements the IDocumentHookListener, you will then need to implement the

String doDocumentHook(int documentPosition, IPortalComponentRequest request, IPortalComponentResponse response)

and

void doDocumentHook(int documentPosition, IPortalComponentRequest request, IPortalComponentResponse response)

The first method, that returns a String, you can basically check where in the document you would like to write code, something like


switch (documentPosition) {
  case IDocumentHookListener.HEAD_SECTION_BEGIN :
    return "some string";
    break;
  case IDocumentHookListener.HEAD_SECTION_END :
    return "some other string";
    break;
}

The second method, simply writes out the String returned from the first method to the response, i.e.


  response.write(doDocumentHook(documentPosition, request));

I hope this helps

Darrell

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi fella's is it possible to apply the EP style sheet to my HTML page which i am posting using an AppIntegrator iView.

I have declared a session parameter in the HTML page where i need to pass this stylesheet.