ui:include src 属性的 EL 在复合组件中解析为 null

发布于 2024-12-24 22:02:11 字数 866 浏览 3 评论 0原文

我有如下复合组件:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:cc="http://java.sun.com/jsf/composite" 
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <cc:interface>
        <cc:attribute name="path" shortDescription="Page Title" type="String"/>
    </cc:interface>
    <cc:implementation>
            <ui:include src="#{cc.attrs.path}"/>
    </cc:implementation>
</html>

上述代码的问题是 #{cc.attrs.path} 已解析为 null。如果 src 是硬编码的,那么 ui:include 就可以正常工作。

尝试使用 h:outputText 检查 #{cc.attrs.path} 并且路径显示正确,这意味着仅在 ui:include 的情况下EL没有解决。有什么帮助吗?

I have composite component as below:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:cc="http://java.sun.com/jsf/composite" 
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <cc:interface>
        <cc:attribute name="path" shortDescription="Page Title" type="String"/>
    </cc:interface>
    <cc:implementation>
            <ui:include src="#{cc.attrs.path}"/>
    </cc:implementation>
</html>

Problem with above code is #{cc.attrs.path} is resolved to null. If src is hardcoded then ui:include works fine.

Tried checking #{cc.attrs.path} with h:outputText and path is displayed correctly, that means only in case of ui:include EL is not resolved. Any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过潦 2024-12-31 22:02:11

这段代码在我的电脑上运行得很好。无论如何,EL 都已解决,但我认为包含失败,因为您尝试包含的文件格式错误或不存在。

也许您可以告诉我们您尝试包含哪种文件,然后给我们该文件的一部分?

This code works just fine on my computer. The EL is resolved in any case, but I think the include failed because the file you try to include is malformed, or does not exist.

Maybe you could tell us what kind of file you try to include, and then give us a portion of this file ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文