So I'm populating an item into the LV, which is gonna have a Remove
button, so when I'm add the AFB in the onsubmit I write to remove the
ListItem which I'm currently populating??
The LV looks like this
final ListView<IMAccount> listview = new ListView<IMAccount>("ims", new
PropertyModel(person, "ImAccounts")) {...}
I tried to remove the markup for the ListView, but didn't found a
working way:
- I tried:
person.getImAccounts().remove(acc); where acc = item.getModelObject();
If I do so, than one item is removing from the LV, but not the correct
one, remember I'm just removed an element from the list, I didn't
removed anything from the markup, but the listview's gonna have one less
line. Why? And why not the removed item is disappearing?
----
- I tried
item.setVisible(false);
but then I did not removed the item from the model, so it would send
incorrect datas. The markup now works as intended.
----
- I tried
item.setVisible(false); person.getImAccounts().remove(acc);
so both of them, than when I pressed the remove button, I successfully
removed from the markup two(!) items. Why?
----
- I tried
final ListView<IMAccount> curr = this; final List<IMAccount> model =
getModelObject();
and in the AFB:
curr.remove(item);
model.remove(acc);
person.setImAccounts(model);
It looks like this is deleting from the markup the last item, and the
correct ListItem's row is setted to defaults...
The only thing I don't get, that when I remove an item from the model,
than why a different row is gonna disappear from the markup...
//In these cases when I'm remove from the model an element in the markup
always the last row is disappearing...
Any help would be appreciated.
Thanks
Regards,
Peter
2009-08-14 18:07 keltezéssel, Igor Vaynberg írta:
if removeall() doesnt do what you want then you have to find the
specific listitem that represents your deleted row and remove just
that one.
-igor
2009/8/14 Major Péter<[email protected]>:
I tried to do this:
ListView obj = (ListView) form.get("rowPanel:ims");
obj.removeAll();
But after that, the input is forgotten.
I tought, that if I enable the ReuseItems, than the list will remember the
contents, but when I call, the removeAll(), it's just forgots the input
values. It's like I just left the reuseItems on false.
How can I achieve, that the new values won't be forgotten when I remove one
item from the list?
Thanks
Peter
2009-08-14 17:18 keltezéssel, Igor Vaynberg írta:
you have ot call removeall() on the listview, not on the button.
-igor
2009/8/14 Major Péter<[email protected]>:
I tried this:
item.add(new AjaxFallbackButton("imRemove", PersonForm.this) {
@Override
public void onSubmit(AjaxRequestTarget target, Form<?>
form) {
person.getIMAccounts().remove(acc);
removeAll();
if (target != null) {
target.addComponent(rowPanel);
}
}
}.setDefaultFormProcessing(false));
but it's still not working, it looks like that on every single
imRemove#onSubmit in the list the last element will disappear. I have no
idea what's causing this behavior...
Regards,
Peter
2009-08-14 04:19 keltezéssel, Cserep Janos írta:
Because of this:
listview.setReuseItems(true);
You should do a
removeAll()
in your onSubmit() method when you change the model (the list in this
case).
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]