2013-11-15 21 views
1

我有一個<h: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 /> 

和此動作方法

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); 
    } 

然而,該命令按鈕不調用操作方法。 我試圖在方法的第一行中打印Hello,但未打印。

這是如何造成的,我該如何解決?

+0

請顯示xhtml代碼。 – Masudul

+0

請顯示您的pesquisaBean的其餘部分 – jltorresm

+0

[h:commandLink/h:commandButton未被調用]的可能重複(http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked) – BalusC

回答

10

我想,你沒有附上<h:commandButton/><h:form/>。試着喜歡叫:

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

無論何時,你會通過書面方式向JSF的工作,總是開放的開發環境下的web.xmlcontext-param

<context-param> 
    <param-name>javax.faces.PROJECT_STAGE</param-name> 
    <param-value>Development</param-value> 
</context-param> 

它會顯示警告,xhtml中缺少什麼。

+0

謝謝,沒錯! – Luciane

相關問題