function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Harika ZillaHarika Zilla 

Insert HTML code in visualforce page

Hi,

 

I have visualforce page with command link.when i click on the link,internally a webservice call happens,which returns HTML code to the controller in the form of string.can anyone provide solution to include that HTML code in visualforce page.

 

VisualForce Page:

 

<apex:page controller="testsearch">
<apex:form >
<apex:commandLink value="Click Me" action="{!testsearch1}">
<apex:param value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=3" assignTo="{!QueryString}"/>
</apex:commandLink>
</apex:form>
{!htmlcode}
</apex:page>

 

Controller Code:

 

public with sharing class testsearch {
public string QueryString{get;set;}
public String htmlcode{get;set;}
public PageReference testsearch1()
{
        Cqservice.CQOperationsPort cqreq=new Cqservice.CQOperationsPort();
        CqserviceCqop.entity_element[] entity=new CqserviceCqop.entity_element[5];
        CqserviceCqop.entity_element entityelement1=new CqserviceCqop.entity_element();
        entityelement1.entityName='QueryString';
        entityelement1.entityValue=QueryString;
        entity.set(0,entityelement1);
        CqserviceCqop.Objects_element objectele=cqreq.CQQuery('UIPreview',entity);
        CqserviceCqop.Object_element[] obj=objectele.Object_x;
        CqserviceCqop.ObjectInfo_element objinfo=obj[0].ObjectInfo;
        htmlcode=objinfo.ObjectContent;
        return null;
        }

}   

 

In the above code,'htmlcode' is a string  variable contains HTML response from webservice.If i run the visualforce page,output will be as follows:

 

Output:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="icon" type="image/vnd.microsoft.icon" href="/cqweb/_rcm-resources/clearquest.ico"> <link rel="stylesheet" href="/cqweb/_rcm-resources/stylesheet/preview.css" type="text/css"> <title>Issue BETA00000565 - IBM Rational ClearQuest</title> </head> <body> <table class="header"><tr><td> <h2><img alt="Database" src="/cqweb/_rcm-resources/images/db.gif" style="vertical-align: middle; margin-right: 4px;">BETA/BETA</h2> </td><td class="navigation"> <select onchange="window.location.href = this.options[this.selectedIndex].value"> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=0">General</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=1">Description</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=2">Comments</option> <option selected="selected" value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=3">Customer Case</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=4">Environment/Attachments</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=5">Release Notes</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=6">History</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=7">Subscriber List</option> <option value="http://ntcqsrv6.bedford.progress.com/cqweb/oslc/repo/BETA/db/BETA/record/16777434-33554997/preview?rcm.tabIndex=8">Links</option> </table> <table class="properties"> <tr><td class="name" style="width: 25%">SupportCases</td><td class="value" style="width: 25%"> </td> <td class="name" style="width: 25%">Hotfix Releases</td><td class="value" style="width: 25%"></td> </tr> <tr><td class="name" style="width: 25%">Category</td><td class="value" style="width: 25%"></td> <td class="name" style="width: 25%">Status</td><td class="value" style="width: 25%"></td> </tr> <tr><td class="name" style="width: 25%">SubCategory</td><td class="value" style="width: 25%"></td> <td class="name" style="width: 25%">Author</td><td class="value" style="width: 25%"></td> </tr> <tr><td class="name" style="width: 25%">Reviewer</td><td class="value" style="width: 25%"></td> <td class="name" style="width: 25%">Public Description</td><td class="value" style="width: 25%"></td> </tr> </table> </body> </html>

 

Here the problem was HTML tags are not executed.     

Best Answer chosen by Admin (Salesforce Developers) 
Harika ZillaHarika Zilla

Hi Kamlesh,

 

Thanks for your reply. It's working fine.

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

Set the content type=”html “ in the <apex:page controller="testsearch" contentType="html"> 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

kamlesh_chauhankamlesh_chauhan

Use <apex:outputtext value={!htmlcode} escape="false"/>

 

Regards,

Kamlesh

Harika ZillaHarika Zilla

Hi Navatar,

 

Thanks for your reply.

 

It is working fine,but iam getting additional link and two dropdowns.

 

How to hide these information?

Harika ZillaHarika Zilla

Hi Kamlesh,

 

Thanks for your reply. It's working fine.

This was selected as the best answer