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

Break Statement

Hi All,

Break is not working. 


Power=string.valueof(lstproduct2[i].test__c) + ' ' + 'KW' + '<br />' + string.valueof(lstproduct2[i].Rating__c) + ' ' + 'KVA' + '<br />' + string.valueof(lstproduct2[i].Hp__c) + ' ' + 'Hp';


  <apex:outputLabel value="{!Power}" />

Out put 

Out put coming like this but i want break line.

300 Kv<br />150 KA<br />2000 Hp






1000 KW&lt;br&gt;&lt;/br&gt;500 KVA&lt;br&gt;&lt;/br&gt;2000 Hp</label>

label>1000 KW&lt;br&gt;&lt;/br&gt;500 KVA&lt;br&gt;&lt;/br&gt;2000 Hp</label>




Specify the escape attribute as false, e.g.



 <apex:outputLabel value="{!Power}" escape="false" />




As always when you use escape=false, it is up to you to make sure you don't introduce the possibility of cross-site scripting.  e.g. if any of thse fields being used to compose the label contain user-entered data, you must be sure it contains no scripting tags.


Please, however, be aware of the security consequences of this pattern. By default, we escape values in outputLabels and similar components to keep malicious users from entering data that will execute code. When you use escape="false" without specially encoding what you pass in, you're basically letting the people who enter your data insert arbitrary HTML, JavaScript, etc. directly into your page. You should only use this option if you're aware of, and trust, any users with insert/update data privileges.




What I'd recommend doing is breaking up Power into the parts that you're writing in Apex (such as the <br /> tags, which don't need to be escaped) and the parts that come from data (the field values), which you can surround with HTMLENCODE (see the above link). Then escape="false" should be safe.



Have you tried the escape attribute in <apex:outputlabel escape = false> ?