Olá pessoal, não estou conseguindo chamar o método excluir (h:commandLink) que está dentro de um Bean através de um h:form com h:dataTable, segue o código. Agradeço muito a ajuda!
[code]<body>
<h:form>//value = propriedade do backbean que retorna uma lista. var = nome referenciar itens da lista
<h:dataTable value="#{agenda.dados}" var="agenda" border="1">
<h:column>
<f:facet name="header">
<h:outputText value="#{msgs.Cod}"/>
</f:facet>
<h:outputText value="#{agenda.cod}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgs.Titulo}"/>
</f:facet>
<h:outputText value="#{agenda.titulo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{msgs.Link}"/>
</f:facet>
<h:commandLink value="Excluir" action="#{agenda.exclui}" >
<f:setPropertyActionListener target="#{agenda.cod}" value="#{agenda.cod}" />
</h:commandLink>
</h:column>
</h:dataTable>
</h:form>
</body>
</f:view>
[/code] meu Bean:[code]public class AgendaBean {
private Connection conn;
public void abrirConexao()
throws SQLException,
NamingException,
ClassNotFoundException
{
if (conn != null) return;
Class.forName(“org.gjt.mm.mysql.Driver”);
conn = DriverManager.getConnection(“jdbc:mysql://localhost/bdlivros”,“root”,“senha123”);
}
public Result getDados()
throws SQLException,
NamingException,
ClassNotFoundException
{
try{
abrirConexao();
Statement stmt = conn.createStatement();
// stmt.executeUpdate("INSERT INTO livros(Cod, Titulo) VALUES (12333, 'Weeeb') "); esta inserindo ok!
ResultSet result = stmt.executeQuery("SELECT * from livros");
return ResultSupport.toResult(result);
}finally{
fecharConexao();
}
}
// Verificar como remover livros
public void exclui(String cod)
throws SQLException,
NamingException,
ClassNotFoundException{
PreparedStatement pst = null;
{
try{
abrirConexao();
pst = conn.prepareStatement("DELETE FROM livros WHERE cod=?");
pst.setString(1, cod);
pst.executeUpdate();
//return ResultSupport.toResult(result);
}finally{
fecharConexao();
}
}
}
public void fecharConexao() throws SQLException{
if (conn == null) return;
conn.close();
conn = null;
}
}[/code]
Erro:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: #{agenda.exclui}: javax.el.MethodNotFoundException: Method not found: {cod=1, titulo=Algoritmos}.exclui()
root cause
javax.faces.FacesException: #{agenda.exclui}: javax.el.MethodNotFoundException: Method not found: {cod=1, titulo=Algoritmos}.exclui()
root cause
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Method not found: {cod=1, titulo=Algoritmos}.exclui()
root cause
javax.el.MethodNotFoundException: Method not found: {cod=1, titulo=Algoritmos}.exclui()
note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_01 logs.