There's a much easier way to do it, you'll be pleased to here.
<h:commandButton id="buttonID1" image="/images//delete.png" style="width:20px" action="#{bean.deleteMethod}">
<f:setPropertyActionListener value="#{var}" target="#{bean.selectedThing}"/>
<p:ajax/>
</h:commandButton>
so just use setProperty... if the dataTable is var="var" and it's displaying a List<Something> then in the bean you
have private Something selectedThing; You could always use p:commandButton although I don't remember if it has an
image attribute (it has icon=), or a p:commandLink with a nested h:graphicImage and lose the child p:ajax tag.
You didn't show what the dataTable value attribute is but I hope this is valid.
Regards,
Brendan.