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
arishi0arishi0 

HTML text not displaying properly in PanelBarItem

Hello,

 

I have a home page component that displays text from a field in a custom object called FrontPageNews. The idea is to load into the component the latest news we have in our org.

 

What I did was to create a VF page that uses a panelbaritem and a repeat tag to iterate display a list of records that are returned from an extension class. The repeat tag creates a panelbaritem for each record in the list. All this is displayed in an iframe on the home page. So far so good.

 

The code is working ok since it returns the records it should, also the styles in the style class also are ok since the panelbaritem is colored correctly. BUT the issue comes up in the body of the panelbaritem where the content to display should be a rich text field. The issue is that it is not showing  with the HTML as it should, so where I have a <br> tag im getting the actual <br> in between the text, and so on for all the other html tags and attirbutes.

 

I need to know how I can show the rich text with the correct format in the content part of the panelbaritem. Below is the code to show what Im doing.

 

 

 

//VF PAGE

<apex:page sidebar="False" showHeader="false"  standardcontroller="FrontPageNewsItem__c" extensions="FrontPageNewsItemExt" >
    <style>
    .header
    {
      background-color:#1797C0;
      background-image: none;
      color: white
    }
    .body
    {
     background-color:#B0E0E6;
      background-image: none;
      color: black;
      font-size: 12px;
    }
    .headerActive
    {
      background-color: #1797C0;
      background-image: none;
      color: white;
    }
  </style>
    <apex:panelBar >
        <apex:repeat value="{!FrontPageNewsItems}" var="item"  >
           <apex:panelBarItem label="{!item.Name}"  headerClassActive="headerActive" headerClass="header" contentClass="body" expanded="false" >{!item.Body_Text__c}</apex:panelBarItem>
        </apex:repeat>
    </apex:panelBar>
</apex:page>

 The Body_Text__c field is the rich text field I am wanting to display correctly in SF.

 

THANK YOU!!

 

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

You should be able to use <apex:outputText> with escape=false attribute to display the rich text.   

As always when you use escape=false it is up to you to make sure the content is not capable of causing any cross-site scripting security vulnerablility.

All Answers

aballardaballard

You should be able to use <apex:outputText> with escape=false attribute to display the rich text.   

As always when you use escape=false it is up to you to make sure the content is not capable of causing any cross-site scripting security vulnerablility.

This was selected as the best answer
arishi0arishi0

thank you!!!!

 

It worked great, showing as I wanted it to. Many thanks!!