I have the problem that my Faces ActionEvent returns a source, but the check on != null returns false. The crazy fact is, that in debug mode I get a filled ActionEvent variable.
I have broken down the code to the important sections
Bean:
public class HibernateUserHandling
{
public void deleteUser(ActionEvent ev)
{
if (ev.getSource() != null && ev.getSource() instanceof HtmlDataTable) {
HtmlDataTable objHtmlDataTable = (HtmlDataTable) ev.getSource();
setRowOfUserToDelete(objHtmlDataTable.getRowIndex());
setPersonsCopy(HibernateDataOutput.persons);
setUserToDelete(getPersonsCopy()[getRowOfUserToDelete()]);
setUserIdToDelete((Integer) getUserToDelete().getUserId());
}
}
View:
<html>
<body>
<ui:composition template="./generalTemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:define name="content">
<h:outputStylesheet library="css" name="cssHibernate.css" />
<h:form id="main">
<h:dataTable value="#{hibernateDataOutput.persons}" var="list"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row">
<h:column>
<f:facet name="header">Delete</f:facet>
<h:commandButton id="delete" actionListener="#{hibernateUserHandling['deleteUser']}" image="delete.jpg"/>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
I don't get an error, it just skips the If block because of the "ev.getSource() != null".
Thanks in advance,
TLS