I had a very similar problem. My question is here
My xhtml page looks like -
<h:outputText itemEscaped="false" escape="false" value="#{singleViewResultDO.associatedCode}" />
associatedCode is getting value from a SQL query where I want to use HTML tag to have conditional styling.
Here is my SQL query looks like:
Select A, REPLACE(Wm_Concat(DISTINCT CASE WHEN sv.rmvd = 0 THEN ' '||sv.CMPNION_CD ELSE '<span style=\"color:red; \">' || ' '||sv.CMPNION_CD|| '</span>' END),' , ','') , "
from Table
Ignore REPLACE and WM_CONCAT as it is for displaying comma separated values. The piece of code relevant is
CASE WHEN sv.rmvd = 0 THEN ' '||sv.CMPNION_CD ELSE '<span style=\"color:red; \">' || ' '||sv.CMPNION_CD|| '</span>' END
I want to have tag based on a condition rmvd = 0.. Since, I have escape="false" in my , I don't need to escape my html tags in query. What I mean is no need to convert < to < > to > and " to "
Also note that since I have double quotes "" in my span, I need to escape it once so it won't be escaped when it reaches .
I am getting my output as desired - 8000778 in red color