如何将 Silverlight 控件嵌入 Facelets 页面?

发布于 2025-01-02 14:30:15 字数 2342 浏览 0 评论 0原文

我正在尝试将 Silverlight 控件嵌入到使用 Facelets 的 JSF 2.0 页面中,但是,在页面呈现时我收到一条非常模糊的错误消息。

谁能建议我如何做到这一点?我已准备好 clientaccesspolicy.xml 和 silverlight.js。

当我删除 标记时,JSF 页面显示正确 如果我将 标记放入普通 HTML 页面中,则 silverlight 控件将在 Tomcat 7.0.25 中正确呈现。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:cayman="http://www.fnet.com/cayman/jsf"
template="/WEB-INF/jsf/template.xhtml">

<ui:define name="title">Home Page</ui:define>

<ui:define name="content">

    <h:form>
        <ui:include src="header.xhtml">
            <ui:param name="loginBean" value="#{UserLoginComponent}" />
        </ui:include>
        <div>
            <p:growl />
        </div>
        <center>
            <p:panel header="Home Page">
                <f:verbatim escape="#{true}">
                    <object data="data:application/x-silverlight-2,"
                        type="application/x-silverlight-2" width="100%" height="100%">
                        <param name="source" value="Dashboard.xap" />
                        <a
                            href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0"
                            style="text-decoration: none"> <img
                                src="http://go.microsoft.com/fwlink/?LinkId=161376"
                                alt="Get Microsoft Silverlight" style="border-style: none" />
                        </a>
                    </object>
                </f:verbatim>
                <iframe id="_sl_historyFrame"
                    style="visibility: hidden; height: 0px; width: 0px; border: 0px"></iframe>
                <h:inputHidden id="userid" value="ADMINISTRATOR" />
                <h:inputHidden id="password" value="admin" />
                <h:inputHidden id="adminserviceuurl"
                    value="http://129.196.218.35:8080/cayman/services" />


            </p:panel>
        </center>
    </h:form>
</ui:define>

I am trying to embed a Silverlight control into a JSF 2.0 page, which is using Facelets, however, I am receiving a very ambiguous error message when the page renders.

Can anyone suggest how I can do this? I have my clientaccesspolicy.xml, and silverlight.js in place.

When I remove the <object> tag, the JSF page displays correctly
If I place the <object> tag into a vanilla HTML page, the silverlight control renders correctly in my Tomcat 7.0.25.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:cayman="http://www.fnet.com/cayman/jsf"
template="/WEB-INF/jsf/template.xhtml">

<ui:define name="title">Home Page</ui:define>

<ui:define name="content">

    <h:form>
        <ui:include src="header.xhtml">
            <ui:param name="loginBean" value="#{UserLoginComponent}" />
        </ui:include>
        <div>
            <p:growl />
        </div>
        <center>
            <p:panel header="Home Page">
                <f:verbatim escape="#{true}">
                    <object data="data:application/x-silverlight-2,"
                        type="application/x-silverlight-2" width="100%" height="100%">
                        <param name="source" value="Dashboard.xap" />
                        <a
                            href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0"
                            style="text-decoration: none"> <img
                                src="http://go.microsoft.com/fwlink/?LinkId=161376"
                                alt="Get Microsoft Silverlight" style="border-style: none" />
                        </a>
                    </object>
                </f:verbatim>
                <iframe id="_sl_historyFrame"
                    style="visibility: hidden; height: 0px; width: 0px; border: 0px"></iframe>
                <h:inputHidden id="userid" value="ADMINISTRATOR" />
                <h:inputHidden id="password" value="admin" />
                <h:inputHidden id="adminserviceuurl"
                    value="http://129.196.218.35:8080/cayman/services" />


            </p:panel>
        </center>
    </h:form>
</ui:define>

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

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

发布评论

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

评论(1

白云悠悠 2025-01-09 14:30:15

删除 。它是 JSP 上 JSF 1.x 旧时代的遗留物,在 JSF 2.x 中已弃用。

至于您忘记在问题中包含的不明确的错误消息,请确保您正确转义 XML 特殊字符,如&。 Facelets 是一种基于 XML 的视图技术,在生成 HTML 之前将由 XML 解析器进行解析。当 XML 解析器遇到 & 时,它会被阻塞,该 & 应该表示实体的开始,但没有 ; 来表示实体的结束,或者当实体本身根本不代表任何东西。

所以,替换

href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0"

href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0"

Remove <f:verbatim>. It's a leftover from the old ages of JSF 1.x on JSP and deprecated in JSF 2.x.

As to the ambiguous error message which you forgot to include in your question, make sure that you're properly escaping XML special characters like &. Facelets is a XML based view technology and will be parsed by a XML parser before generating the HTML. The XML parser will choke when it encounters & which is supposed to represent the start of an entity, but there is no ; to denote the end of an entity or when the entity by itself does not represent anything at all.

So, replace

href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0"

by

href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文