开发者

f:verbatim tag stops working when inside a dataTable

开发者 https://www.devze.com 2023-04-06 23:49 出处:网络
I posted this to the PrimeFaces user forum but I think they are too busy to look into it, so I thought I would try here.

I posted this to the PrimeFaces user forum but I think they are too busy to look into it, so I thought I would try here.

I have server-side string that has markup in it, so when I want it rendered I do this:

            <p:panel>                    
                <f:verbatim>
             开发者_如何学JAVA       #{daBean.markedUpString}
                </f:verbatim>
            </p:panel>

This works fine, but not if the same tag is used inside a p:dataTable -- either with or without the p:panel enclosure. What gets rendered is a div class="ui-dt-c" element with nothing in it. To test, if I take out the f:verbatim tag the marked-up text gets escaped and rendered.

I don't know if this should be considered a bug or not, but does anyone know of a work-around for this? This is with PrimeFaces 3.0.M3.


The <f:verbatim> tag is intented to hold plain text/HTML, not JSF components nor EL expressions. The tag is a leftover from JSF 1.0/1.1 ages when it was not possible to inline plain text/HTML between JSF components. The tag is deprecated in JSF2. You do not need it anymore.

Your concrete functional requirement is thus displaying some HTML string from a managed bean unescaped. For that you should use <h:outputText> with escape="false".

<h:outputText value="#{daBean.markedUpString}" escape="false" />

See also:

  • Getters inside f:verbatim called before form submission
  • JSF/Facelets: why is it not a good idea to mix JSF/Facelets with HTML tags?
  • What are the main disadvantages of Java Server Faces 2.0?
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号