themaster themaster - 4 months ago 29
HTML Question

Retaining string style on html page

I am fetching a string from database side ,with proper line change and all .My string looks like given below when I see on debug both on java end as well as browser console . But when I print it on UI ,it is shown as a single line string like

Email Request To: FedEx Legal; FedExEmailTeam Subject: Approval request to send email as transactional Attachment: <customer email creative>
.Why and how can I resolve this .

My string -

Email Request
To: FedEx Legal; FedExEmailTeam
Subject: Approval request to send email as transactional
Attachment:customer email creative


My UI code-

<f:facet name="body">

<ice:panelGroup style="margin-top: 2%;">
<div style="border-top: 1px solid #a7a7a7;">
<div
style="border-left: 1px solid #a7a7a7; border-right: 1px solid #a7a7a7;">
<div style="padding: 8px 0px 4px 8px; background-color: #FFF;">
<ice:panelGrid columns="1" border="0">
<ice:outputText
value="#{campaignTrackingCodesBean.emailTransPanel}"></ice:outputText>
</ice:panelGrid>
</div>
</div>
</div>
<div style="border-top: 1px solid #a7a7a7;"></div>
</ice:panelGroup>

</f:facet>

Answer

try using <pre> tag inside the place you wish to conserve the text format

    <pre>
    <ice:outputText value="#{campaignTrackingCodesBean.emailTransPanel}"> </ice:outputText>
    </pre>