Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用primefaces动态菜单在iframe上加载内容?_Java_Javascript_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Java 如何使用primefaces动态菜单在iframe上加载内容?

Java 如何使用primefaces动态菜单在iframe上加载内容?,java,javascript,jsf,jsf-2,primefaces,Java,Javascript,Jsf,Jsf 2,Primefaces,我有一个页面,可以加载我的内容: <?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"

我有一个页面,可以加载我的内容:

  <?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:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <meta charset="UTF-8"/>
        <title>Dashboard</title>
        <link rel="stylesheet" type="text/css" href="../css/graficas1_estilos.css" media="all" />           
    </h:head>
    <h:body>
        <div id="page">
            <div id="header">
                <ui:insert name="header" >
                    <ui:include src="Header.xhtml" />
                </ui:insert>
            </div>
            <div id="left">
                <ui:insert name="left" >
                    <ui:include src="Left.xhtml" />
                </ui:insert>
            </div>
            <div id="content">
                <ui:insert name="content" >
                     <iframe scrolling="auto" height="100%" frameborder="0" width="100%" 
                     src="Content.xhtml" name="iFrameMain" id="iFrameMain" pane="center">    
                     </iframe>
                </ui:insert>
            </div>
            <div id="footer">
                <ui:insert name="footer" >
                    <ui:include src="Footer.xhtml" />
                </ui:insert>
            </div>
        </div>
    </h:body>
</html>
因此,当我点击一个链接时,它会重新加载整个页面。 我应该怎么做才能在点击菜单链接后重新加载iframe???
提前感谢。

如果您可以使用javascript

function reloadIframe(e) {
  e.preventDefault();
  document.getElementById('iFrameMain').contentDocument.location.reload(true);
}
在导致问题的链接中

<button onclick="reloadIframe(event)">Click me</button>
点击我

我尝试了你的建议,但不幸的是,我得到了:未捕获类型错误:无法读取null的属性“contentDocument”
iFrameMain
定义了吗?
function reloadIframe(e) {
  e.preventDefault();
  document.getElementById('iFrameMain').contentDocument.location.reload(true);
}
<button onclick="reloadIframe(event)">Click me</button>