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
sharrissharris 

Page breaks in an apex:pageblocktable / apex:column value

I need to have page breaks in text that I'm displaying in an apex:pageblocktable.

How can I get the text to not show the literal "<br />" tags? "\n" new line escape doesn't seem to be rendered as a <br/> tag. When I replaceAll "\n" with <br/> that doesn't work. In .NET there's a server function called Server.HtmlDecode that I would use to fix something like this. Does Apex have an equivalent method? Thanks!

 

Class Code:

 

    public List<String> RecListNL 
    {
        get 
        {
	List<String> RecordList = new List<String>();			
	RecordList.add('Record #1\n\nNew Line Test');
	RecordList.add('Record #2\n\nNew Line Test');
	RecordList.add('Record #3\n\nNew Line Test');
	RecordList.add('Record #4\n\nNew Line Test');
	RecordList.add('Record #5\n\nNew Line Test');
         return RecordList;
        }
        set;    
    }  

    public List<String> RecListBR 
    {
        get 
        {
	List<String> RecordList = new List<String>();			
	RecordList.add('Record #1<br /><br />New Line Test');
	RecordList.add('Record #2<br /><br />New Line Test');
	RecordList.add('Record #3<br /><br />New Line Test');
	RecordList.add('Record #4<br /><br />New Line Test');
	RecordList.add('Record #5<br />New Line Test');
         return RecordList;
        }
        set;    
    }  

 Page Code: 

 

    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!RecListNL}" var="nl">
                    <apex:column value="{!nl}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
     
         <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!RecListBR}" var="br">
                    <apex:column value="{!br}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>   
    
    </apex:form>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
James LoghryJames Loghry

Try <apex:column><apex:outputText value="{!br}" escape="false" /></apex:column> in your VF page.

 

Sorry, I should add that would be in conjunction with your RecListBR list.

All Answers

James LoghryJames Loghry

Try <apex:column><apex:outputText value="{!br}" escape="false" /></apex:column> in your VF page.

 

Sorry, I should add that would be in conjunction with your RecListBR list.

This was selected as the best answer
sharrissharris

That did the trick EDLJames.

Thank you very much!