刷新包括菜单项不起作用

时间:2015-09-02 16:36:39

标签: java web primefaces

当我点击登录时,它不刷新包含有没有人知道是什么问题?

我尝试过其他方法,但仍然会出错 代码

的index.xhtml

<a download="report.csv" id="csvClick" href="#">Download CSV</a>
<table id="myTable">... </table>
<script>
makeCSV("csvClick", "myTable"); 
function makeCSV (link, targetTable) {
    var csvLink=document.getElementById(link);
    var dataurlHeader = "data:text/csv;charset=utf-8,";
    var dataurlContent = "";

    var table = document.getElementById(targetTable);
    for (var i = 0, row; row = table.rows[i]; i++) {
       // row references rows
       if (i > 0){
           dataurlContent += "\n";
       }
       for (var j = 0, column; column = row.cells[j]; j++) {
         // column references columns
         if (j > 0) {
             dataurlContent += ",";
         }
         dataurlContent += column.innerHTML;
       }  
    }
    dataurlContent = encodeURIComponent(dataurlContent);
    csvLink.href = "" + dataurlHeader + dataurlContent;
}
</script>

Controlomenu.java

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Meu Sistema</title>
</h:head>
<h:body>
    <div align="center">
        <p:layout style="min-width:1020px;max-width:1020px;min-height:600px">
            <p:layoutUnit position="center">
                <h:panelGroup id="include">
                    <ui:include src="#{Controlomenu.pagina}" />
                </h:panelGroup>
            </p:layoutUnit>
        </p:layout>
    </div>
<p:dock position="bottom">
    <p:menuitem value="Login" icon="imagens/lock.png" url="#" actionListener="#{Controlomenu.Paginalogin}" update=":include" />
    <p:menuitem value="Registar" icon="imagens/register.png" url="#" actionListener="#{Controlomenu.Paginaregistar}" update=":include"/>
</p:dock>
</h:body>
</html>

谢谢

2 个答案:

答案 0 :(得分:1)

尝试此代码,看看它是否有效

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Meu Sistema</title>
    </h:head>
    <h:body>
<h:form id="outputForm">
        <div align="center">
            <p:layout style="min-width:1020px;max-width:1020px;min-height:600px">
                <p:layoutUnit position="center">
                    <h:panelGroup id="include">
                        <ui:include src="#{Controlomenu.pagina}" />
                    </h:panelGroup>
                </p:layoutUnit>
            </p:layout>
        </div>
</h:form>
<h:form id="dockForm">
    <p:dock position="bottom">
        <p:menuitem value="Login" icon="imagens/lock.png" url="#" actionListener="#{Controlomenu.Paginalogin}" update=":outputForm:include" />
        <p:menuitem value="Registar" icon="imagens/register.png" url="#" actionListener="#{Controlomenu.Paginaregistar}" update=":outputForm:include"/>
    </p:dock>
</h:form:>
    </h:body>
</html>

答案 1 :(得分:0)

确保将<h:body>后的代码包装在<h:form>代码中。

表单允许将数据发送到服务器进行处理。