I am having a string field in a wrapper class which might contain several lines. And I am showing that field in an <apex:dataTable>. The code looks like this:

<apex:dataTable value="{!childJobs}" var="Job">
         <apex:facet name="header">
                 time range

The problem with this is the generated html will look like this:


Which means the actual string shown on the screen will be abc def ghi without breaking into different lines. <apex:outputField> will automatically insert <br> in between lines. But outPutField doesn't work for wrapper class fields. And set the value attribute of the <apex:column> doesn't work as well.

One approach I can think of is using Javascript to analyze the string and insert <br> in between. But that doesn't sound very clear option to me. Is there any better way of achieving this?

1 Answer 1


Just use CSS:

<span syle="white-space: pre">{!job.TimePeriod}</span>

This will wrap the line based on HTML-source line breaks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .