| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 21/01/2007 15:18:05
|
zzzz8
Joined: 07/12/2005 00:00:00
Messages: 249
Offline
|
I'm trying to create a table that allows the user to delete the currently selected row. In this case, there's a "delete" button for each row and if the button is clicked for that row, that row is deleted. Unfortunately, I'm having problems doing this when using Seam's annotations for a JSF datatable. In particular, when I click on the "delete" button on a row in a datatable that has multiple rows, the first row data is always deleted (i.e. the index of the deleted row in the list backing the JSF datatable is always zero) no matter which "delete" button is clicked.
Here's a snippet of my bean code:
Code:
MyList myList = null;
@DataModelSelectionIndex("myList")
int selectedRow = 0;
@DataModel("myList")
public List getMyList() {
return myList;
}
public final void deleteRow(final ActionEvent e) {
myList.remove(selectedRow);
}
I'm wondering if there's an issue using the DataModelSelectionIndex annotation with Seam and ICEfaces where it doesn't pick up the currently selected row... Am I doing something wrong?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 22/01/2007 12:51:42
|
gus315
Joined: 14/11/2006 00:00:00
Messages: 158
Offline
|
I think that you need to binding a UIData in your bean, then try to get rowIndex. After clicking a row button, get the rowIndex, then delete list.remove(index). For example:
[code]
public class BackBean {
private UIData table;
public void deleteRowListener(ActionEvent e) {
int index = allergyTable.getRowIndex();
allergyList.remove(index);
}
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 22/01/2007 12:54:51
|
gus315
Joined: 14/11/2006 00:00:00
Messages: 158
Offline
|
Sorry for misposting the previous thread.
I think that you need to binding a UIData in your bean, then try to get rowIndex. After clicking a row button, get the rowIndex, then delete list.remove(index). For example:
[code]
public class BackBean {
private UIData table;
public void deleteRowListener(ActionEvent e) {
int index = table.getRowIndex();
allergyList.remove(index);
}
...
}
<ice:dataTable var="allergy" binding="#{backBean.table}" ...
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 22/01/2007 13:09:05
|
zzzz8
Joined: 07/12/2005 00:00:00
Messages: 249
Offline
|
Hi san_gu. Thanks for the info. However, one of the benefits of Seam is that you don't have to bind to a UIComponent such as UIData. So I was hoping to avoid using such a component as UIData.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 22/01/2007 13:17:18
|
gus315
Joined: 14/11/2006 00:00:00
Messages: 158
Offline
|
If you don't want to UIData, you may try the @DataModelSelectionIndex of Seam. Then get the row index, but I haven't used the Seam notation.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 29/01/2007 14:57:28
|
philip.breau

Joined: 08/05/2006 00:00:00
Messages: 2675
Offline
|
Theres a thread on the Seam forums about someone else not getting this working (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=99940), so I think it's likely that we need to do something (or stop doing something) to support this. I've put a bug report in for this.
Thanks,
Philip
|
. |
|
|
 |
|
|