Deleting currently selected row in a JSF data table - Seam/ICEfaces issue?
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Deleting currently selected row in a JSF data table - Seam/ICEfaces issue?  XML
Forum Index -> JBoss Seam Integration
Author Message
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?
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);
}
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}" ...
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.
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.
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

.
 
Forum Index -> JBoss Seam Integration
Go to:   
Powered by JForum 2.1.7ice © JForum Team