How to achieve nested conditional rendering without empty span tags from the top: outputPanel?

I am trying to create a clean XSL-FO from a VisualForce page. But the xml exiting the VisualForce page is invalid due to empty span tags that are generated by the nested vertex: outputPanel tags (external rendered = true, internal rendered = false). Here is a focused page that illustrates the problem:

<apex:page contentType="text/xml" cache="false" showHeader="false" sidebar="false"> <root> There is no reason for a nested apex:outputpanel to generate a span tag like this: <apex:outputPanel layout="none" rendered="true"> <apex:outputPanel layout="none" rendered="false" /> </apex:outputPanel> This breaks strict xml documents like XSL-FO. </root> </apex:page> 

This page gives this xml output:

 <root> There is no reason for a nested apex:outputpanel to generate a span tag like this: <span id="j_id0:j_id3" style="display: none;"></span> This breaks strict xml documents like XSL-FO. </root> 

Actually, I found an obscure reason in the docs :

apex: outputPanel layout attribute - layout style for the panel. Possible values ​​include "block" (which generates the HTML div tag), "inline" (which generates the HTML span tag) and "none" (which does not generate the HTML tag). If not specified, this default value is "none". However, if the layout is set to "none", for each child with the rendered attribute set to "false", the outputPanel generates a span tag , with the identifier of each child and the style attribute set to "display: none". Thus, while the content is not displayed, JavaScript can still access elements through a DOM identifier.

It sounds useful if my content type is html or javascript, but it breaks my strict xml. So the question is: how can I achieve nested conditional rendering while avoiding span tags?

+6
source share
1 answer

Switch both or just the outer to the top: variable as follows:

 <apex:variable rendered="true" value="" var="tempOuter"> <apex:outputPanel layout="none" rendered="false" /> </apex:variable> 
+6
source

Source: https://habr.com/ru/post/915751/


All Articles