cancel
Showing results for 
Search instead for 
Did you mean: 

Showing Html-Code in IFrame

Former Member
0 Kudos

Hi!

I am just learning java web dynpro and have the following problem:

I have a variable of type String which is filled with a complete description of a html site. Now I want to show this html-site.

I tried to use an IFrame, but I think it's not possible to use a context-variable as a source which consists of html-conding. I need a url, right?

My question: What is the easiest way to show the content of the variable in an IFrame or something else?

Thanks and regards,

Dominik

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can create an empty HTML file under the mimes folder in the component. Put this file URL as the reference of the IFrame. Once you have got the HTML string, you can open this file and write the string to this file.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

thanks for the idea. How can I reference the file in the mimes-folder?

Regards,

Dominik

Former Member
0 Kudos

Hi

Copy the HTML file into your x:\<project name>\src\mimes\components\<your package name>\<your html>.html

after that in NWDS -- > <b>IFrame</b> --> <b>Reference</b> property just type <your html>.html

Regards

Chaitanya.A

Former Member
0 Kudos

That's an easy way, thanks!

No the last problem: How to fill the file with the information in the string?

Former Member
0 Kudos

Hi

Do you want to display the content of variable on IFrame ? or any other UI Element?

Regards

Chaitanya.A

Former Member
0 Kudos

Hi,

I want to display the html-coding (complete Web-Site) which is stored in a String-variable.

Therefore I thought an IFrame would be the easiest way to show it, or?

Regards,

Dominik

Former Member
0 Kudos

Hi

If you want to display code.

you can use TextEditUIElement with cols and rows accordinglyand bind the VALUE property to your string value attribute

Regards

Chaitanya.A

Former Member
0 Kudos

Hi!

I think there is a missunderstanding.

I want to show a html-page which consists of the html-coding which is stored in the integer-variable.

I tried to write the information from the variable into the file in following way, but it doesn't work, the file is empty:

try{
// Create file 
FileWriter fstream = new FileWriter("MailPreview.html");
BufferedWriter out = new BufferedWriter(fstream);
out.write(wdThis.wdGetHtmlMailController().DummyText());
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
 System.err.println("Error: " + e.getMessage());
}

Regards, Dominik

Former Member
0 Kudos

Hi,

I tried another way, but it doesn't work yet.

The file (Mail.html) is not getting updated.

try {
			wdContext.currentContextElement().setMailPath(WDURLGenerator.getWebResourceURL(wdComponentAPI.getDeployableObjectPart(), "Mail.html"));		
	
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter (new FileOutputStream(wdContext.currentContextElement().getMailPath() ) ) );
		out.write(eMailContent.getHtmlCode());
		//out.newLine();
		out.close();

						
		}catch (Exception e){//Catch exception if any
		  System.err.println("Error: " + e.getMessage());
		}

former_member751941
Active Contributor
0 Kudos

Hi Dominik,

Check this link to refer html page stored in mimes-folder.

Regards,

Mithu

Former Member
0 Kudos

Hi Mithu,

showing the content of the file in an IFrame works perfect.

My problem: I have to edit/clear the html-code in the file during the application is running. Therefore I have to overwrite the exsisting content of the file, but my coding (see above) doesn't work.

Do you have any idea?

Thanks and regards,

Dominik

Former Member
0 Kudos

Hi!

Does anyone else has an idea to solve this problem?

Thanks and regards,

Dominik

Former Member
0 Kudos

Not sure if these classes are already contained in your Web Dynpro version, but something like this should work:

    IWDTransparentContainer root = (IWDTransparentContainer) view.getRootElement();
    IWDIFrame frame = view.createElement(IWDIFrame.class);
    root.addChild(frame);
    
    String html = "...";
    IWDCachedWebResource res = WDWebResource.getPublicCachedWebResource
    (
      html.getBytes(), 
      WDWebResourceType.HTML, 
      WDScopeType.APPLICATION_SCOPE, 
      wdThis.wdGetAPI().getComponent().getDeployableObjectPart(), 
      "page1"
    );
    try
    {
      frame.setSource(res.getURL());
    }
    catch (WDURLException e)
    {
      //TODO handle exception
    }

Armin

Former Member
0 Kudos

Great, it works fine.

Thanks for your help!

Regards,

Dominik

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

you can try with the following link

Regards

Abhijith YS