First time here? Check out the FAQ!
![]() | 1 | initial version | |
good you found the notifyChange(item)
method, that's the dedicated way to rerender a specific row.
A more granular way to reload just the checked property would have been:
BindUtils.postNotifyChange(item, "modified")
even though it's not an instance variable on your bean, it's still a readonly bean-property just by having a getXXX or isXXX method available.
This is a very useful feature for computed properties for something like fullName
or totalPrice
public String getFullname() {
return this.lastName + ", " + this.firstName;
}
Your second problem is not a problem... clearing a collection and adding items back into it is not ugly. It's perfectly reusing the existing listModelList, in the same way as if you'd just add/remove individual items - can't get simpler than that. And everyone reading your code will instantly know what's your intention.
If you really want to build a new ListModelList you have to notify the viewmodel about the updated property to trigger the load-binding.
@Command
@NotifyChange("list")
public void updateCollection() {
list = new ListModelList<Object>(collection);
}
or via java
@Command
public void updateCollection() {
list = new ListModelList<Object>(collection);
BindUtils.postNotifyChange(this, "list");
}
![]() | 2 | No.2 Revision |
good you found the notifyChange(item)
method, that's the dedicated way to rerender a specific row.
A more granular way to reload just the checked property would have been:
BindUtils.postNotifyChange(item, "modified")
even though it's not an instance variable on your bean, it's still a readonly bean-property just by having a getXXX or isXXX method available.
If you read the docs carefully they only mention methods defining a bean property not the actual instance variable.
This is a very useful feature for computed properties for something like fullName
or totalPrice
public String getFullname() {
return this.lastName + ", " + this.firstName;
}
Your second problem is not a problem... clearing a collection and adding items back into it is not ugly. It's perfectly reusing the existing listModelList, in the same way as if you'd just add/remove individual items - can't get simpler than that. And everyone reading your code will instantly know what's your intention.
If you really want to build a new ListModelList you have to notify the viewmodel about the updated property to trigger the load-binding.
@Command
@NotifyChange("list")
public void updateCollection() {
list = new ListModelList<Object>(collection);
}
or via java
@Command
public void updateCollection() {
list = new ListModelList<Object>(collection);
BindUtils.postNotifyChange(this, "list");
}