cancel
Showing results for 
Search instead for 
Did you mean: 

WebDynpro View with IFrame displaying html which is using a css

Former Member
0 Kudos

Dear All, I have a WebDynpro View which has an IFrame UI Element. This IFrame is getting the html content from a context attribute. In order to show the html formatting properly, I need to use a css file. I am not sure how to create two different types of web resources, 'css' and 'html' and link them together. Following was my starting code, however it does not use the css. Can anybody help?

Best Regars

Manisha

final String formattedStr = html + wdContext.currentContextElement().getRtf();

IWDWebResource cssResource = WDWebResource.getWebResource( wdComponentAPI.getDeployableObjectPart(), WDWebResourceType.CSS, "win_pic.css");

try {

String url = cssResource.getAbsoluteURL();

final IWDCachedWebResource resource = WDWebResource.getPublicCachedWebResource( formattedStr.getBytes("UTF-8"), WDWebResourceType.HTML, WDScopeType.APPLICATION_SCOPE, wdComponentAPI.getDeployableObjectPart(),"win_pic.css" );

resource.setResourceName("HTML_inline.html");

resource.setAttachement(false);

resource.setReadOnce(false);

wdContext.currentContextElement().setURL(resource.getAbsoluteURL());

} catch (WDURLException e) {

// TODO: handle exception

}

catch (final Exception ex){

wdComponentAPI.getMessageManager().reportException(

new WDNonFatalException(ex),

false);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Manisha,

Are you composing HTML yourself or you get it from somewhere?

In former case, you may append "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + url + "\" />" to HTML source.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi Valery, Thanks a lot for your reply. It did help me to understand how to create 2 Web Resources and integrate the css in the html. However the formatting still does not occur. If I preview the source, I see the following (just a short example)

<html><head><link REL="stylesheet" TYPE="text/css" href="http://iwdf70e4:50000/webdynpro/resources/local/ZSalesSummary/Components/com.sap.test.ZSalesSummaryComponent/win_pic.css"/></head><body><table><tr><td>Firma</td></tr><tr><td>Hitech AG</td></tr></table></body></html>

My css file is following:

body

{

background-color:#fffaf0;

}

table {border-style:outset}

So, I expect to see the proper formatting in the IFrame displaying my html (using my css). However I donot see any changes. The output is same as if not using the css.

Can you perhaps locate my error? Thanks again for your help and for your precious time.

Manisha

Answers (0)