on 2023 Feb 14 12:31 PM
I had to create a new attribute to be displayed in page as creation time for user orders.
The result in page is something like this: order number/ creation date:
For this i had to make a populator.
this is my populator:
public class MyDefaultTicketAssociationPopulator <SOURCE extends AbstractOrderModel, TARGET extends TicketAssociatedData>
extends DefaultTicketAssociationPopulator<SOURCE, TARGET> {
public void populate(final AbstractOrderModel source, final TicketAssociatedData target) {
super.populate(source, target);
target.setCreationtime(source.getCreationtime());} }
Now i need to sort the orders by creation time from the newest to the oldest.
Does anyone have any idea how can i achieve this?
I tried to modifty the actual populator but is not working:
public void populate(final List<AbstractOrderModel> sourceList, final List<TicketAssociatedData> targetList) {
if(sourceList.size() != targetList.size()) {
throw new IllegalArgumentException("....");
}
sourceList.sort(((o1, o2) -> o2.getCreationtime().compareTo(o1.getCreationtime())));
for (int i = 0; i < sourceList.size(); i++) {
AbstractOrderModel source = sourceList.get(i);
TicketAssociatedData target = targetList.get(i);
super.populate(source, target);
target.setCreationtime(source.getCreationtime());
}
}
}
Request clarification before answering.
User | Count |
---|---|
21 | |
21 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.