JSF2 MyFaces and CDATA makes f:ajax render fail

前端 未结 2 1331
半阙折子戏
半阙折子戏 2021-01-28 20:06

I\'m facing some problems using CDATA blocks inside h:outputscripts with MyFaces 2.0... but I don\'t know exactly if I should avoid using CDATA with JSF2 or if it is because I d

相关标签:
2条回答
  • 2021-01-28 20:23

    I can't answer if you're the only one having problems with it. I can at least answer that having JS code plain in a XML file is a poor practice. JS code is not well formed XML. Fiddling with escaping XML-special characters in JS code or putting JS code in CDATA blocks is plain ugly. That it gives troubles in JSF ajax response is in turn a different story. Technically, that would have been a bug in the JSF implementation used. But from the other side on, you're actually practicing a poor practice.

    Just put JS code in its own .js file which you reference by <h:outputScript>.

    <cc:implementation>
        <h:outputScript library="foo" name="js/your-cc-script.js" target="head" />
        ...
    </cc:implementation>
    
    0 讨论(0)
  • 2021-01-28 20:31

    This is a known issue. See MYFACES-3339 for details. It was already fixed, so you can try the latest code HERE, and it will be included on 2.1.4 and 2.0.10.

    0 讨论(0)
提交回复
热议问题