<h:commandButton>不调用方法

Luc*_*ane 1 jsf action managed-bean commandbutton

我有一个 <h:commandButton>

   <f:metadata>
        <f:viewParam name="uri" value="#{pesquisaBean.selectedUri}" />
        <f:event listener="#{pesquisaBean.searchElement()}" type="preRenderView"></f:event>
    </f:metadata>
    <h:head>
        <title>Detalhes do Documento</title>
    </h:head>

       <h:body>
       <br />
       Detalhes do Documento

       <br />
       <br />
       <rich:dataTable value="#{pesquisaBean.documentDetailsByTitle}" var="result">

                <c:forEach items="#{pesquisaBean.variableNamesDetails}" var="vname">
                     <rich:column>
                         <f:facet name="header">#{vname}</f:facet>
                          #{result[vname]}
                     </rich:column> 

                </c:forEach> 
       </rich:dataTable>
       <br />
       <h:commandButton value="Excluir" action="#{pesquisaBean.delete()}" />
       <br />
       <br />
Run Code Online (Sandbox Code Playgroud)

和这个行动方法

  public void delete() {
    System.out.println("Hello");
    this.removeDocument(databaseModel, this.selectedDocument);

    System.out.println("");
    System.out.println("After deleting!!!!!!!!!!!!");
    StmtIterator result = databaseModel.listStatements();
    while( result.hasNext() ) {
        Statement stmt = result.next();
        System.out.println(stmt);
    }
Run Code Online (Sandbox Code Playgroud)

但是,命令按钮不会调用操作方法.我正在尝试Hello在方法的第一行打印,但它没有打印.

这是怎么造成的,我该如何解决?

Mas*_*dul 11

我猜,你没有附上<h:commandButton/><h:form/>.尝试打电话:

<h:form>
  <h:commandButton value="Excluir" action="#{pesquisaBean.delete()}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

无论何时,你将与JSF合作,通过写作总是开放的开发环境下context-paramweb.xml.

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

它会显示警告,xhtml中缺少什么.