将iframe添加到JSF组件

时间:2011-06-07 08:50:51

标签: jsf iframe widget

是否可以从支持bean向JSF组件(RichFaces,PrimeFaces)添加iframe?

我需要在我的主页上嵌入外部网页。用户需要设置此URL。我不能使用jQuery。

我无法找到任何iframe等效的JSF组件。这有什么特别的原因吗?

3 个答案:

答案 0 :(得分:14)

只需使用纯HTML。

<iframe src="#{bean.iframeUrl}"></iframe>

组件不存在的最可能原因是因为将它包装在JSF组件中时不会有额外的优势。例如<p><br><hr>等也没有JSF等价物。

答案 1 :(得分:2)

是的可能。我们可以在xhtml文件中使用纯HTML。我试过了。它运作良好。下面我给了我的代码。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<f:view locale="#{facesContext.externalContext.requestLocale}">
<h:head>
    <title>
        <h:outputText value="your application title"></h:outputText>
    </title>
    <style type="text/css">
        #imagepgframe { 
            width: 100%;
            height: 100%;
            position: absolute;
        }
        #wrap { 
            width: 100%;
            position: absolute;
            top: 0px; 
            left: 0;
            bottom: 0;
            overflow-y: hidden;
            overflow-x: hidden;
        }
    </style>
</h:head>
<h:body>
    <h:form>
        <div id="wrap"> 
            <iframe id="imagepgframe" name="imagepgframe" frameborder="0" scrolling="auto" src="#{bean.iframeUrl}">
              <p>Your browser does not support iframes.</p>
            </iframe>
        </div>
    </h:form>
</h:body>

感谢。

答案 2 :(得分:1)

您可以使用hsk:panelFrame添加iframe navegation,这是一个简单的示例,当案例navegation正常并且commponent具有target属性时,此案例navegation toViewId显示在iframe(进入panelFrame),直到iframe页面navegation到parentViewId,这个iframe关闭并返回到父页面

来源https://github.com/yracnet/hiska-HskFrame/

自述文件https://github.com/yracnet/hiska-HskFrame/blob/master/README.md

这个带有css的示例可以显示iframe弹出样式的方式。

相关问题