e-barnett
e-barnett

Reputation: 75

JSF Datatable item removal

There are some questions similar to this, but I haven't found anything that really addresses my issue. Here goes...

There is a working simplified sample available here:

    http://134.154.10.163:8000/yyudatatable/

And the files are visible here:

http://whywhyewej.sci.csueastbay.edu/~yyu/cs6522/facelets/datatable/

What is puzzling me is this: When I check an item that is not the last and hit 'delete', that item is removed. (If multiple items are checked, only the top one disappears. I'm not worried about this behavior right now.)

When I refresh, the item directly below the one that was previously removed is also removed. I can repeat this, refreshing and watching items disappeared, as long as there are items left that were below the original removal target.

I suspect this has something to do with the way the datatable is rendering the information; that the value of the checkbox is carrying up to new targets. But I don't know how to stop it.

Thanks for your help in advance.

Upvotes: 1

Views: 73

Answers (1)

prageeth
prageeth

Reputation: 7395

This happens due to the form re-submission. Your form is submitted again when you refresh the page. This is a common issue in web applications. In orderr to overcome this issue just redirect to the current page after the action is fired . In JSF the easiest way is this.
Add this line at the end of your check() method.

FacesContext.getCurrentInstance().getExternalContext().redirect("your_current_page.jsf");

Upvotes: 1

Related Questions