4

I need to get html code from a web service and display it in a VF page. I've tried the following, but it's showing the response as text, not as html.

VF

<apex:page showHeader="false" sidebar="false" standardStylesheets="false" controller="GetBlueDotMenu">
    <apex:outputText value="{!response}" />
</apex:page>

APEX

public with sharing class GetBlueDotMenu {
    public String response {get; set;}
    public GetBlueDotMenu() {
        QbApiController api = new QbApiController ('GET', 'QB API' , null, null, 'https://appcenter.intuit.com/api/v1/Account/AppMenu');
        response = api.execute();
    }
}

api.execute() returns the response body.

I've tried messing with the HttpResponse class, but can't figure out how to send the response to the visualforce page.

7

The apex:outputText tag escapes content by default. If you'd like to display HTML content you'll want to set the escape attribute to false.

<apex:page showHeader="false" sidebar="false" standardStylesheets="false" controller="GetBlueDotMenu">
    <apex:outputText value="{!response}" escape="false"/>
</apex:page>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.