Handling buttons or links in table rows
If you you have a command link or button in a row of a dataTable, there is an easy way to get to row bean from an javax.faces.event.ActionListener.
...
Code Block |
---|
|
public class OrderActionListener implements ActionListener {
public void processAction(ActionEvent anEvent) throws AbortProcessingException {
YourBeanClass tmpBean = null;
UIComponent tmpComponent = anEvent.getComponent();
while (null != tmpComponent && !(tmpComponent instanceof UIData)) {
tmpComponent = tmpComponent.getParent();
}
if (tmpComponent != null && (tmpComponent instanceof UIData)) {
Object tmpRowData = ((UIData) tmpComponent).getRowData();
if (tmpRowData instanceof YourBeanClass) {
tmpBean = (YourBeanClass) tmpRowData;
//TODO Implementation of your method
}
}
//TODO Exception Handling if UIData not found or tmpRowBean of wrong type
}
}
|