Listbox auto sorted column after ListModel Update

asked 2017-02-17 07:51:28 +0000

jomir gravatar image jomir

Hi, I have a Listbox with a ListModel. I set the model on doAfterCompose then update the model from a timer component. The Listbox have a sort Comparator for each column. The problem is, when a column is sorted (ascending/descending) then the refresh event add a row of data, the data is appended as the last element of row and not sorted according to the column selected. How do I add a row then sort it automatically?


<?init class="AuthenticationInit"?>
import java.util.Comparator;
import com.akarprima.dao.model.JobStatus;
import com.akarprima.util.JobStatusComparator;
Comparator nameAsc = new JobStatusComparator(true, JobStatusComparator.NAME);
Comparator nameDsc = new JobStatusComparator(false, JobStatusComparator.NAME);
Comparator dateAsc = new JobStatusComparator(true, JobStatusComparator.DATE);
Comparator dateDsc = new JobStatusComparator(false, JobStatusComparator.DATE);
Comparator sessionAsc = new JobStatusComparator(true, JobStatusComparator.SESSION);
Comparator sessionDsc = new JobStatusComparator(false, JobStatusComparator.SESSION);
Comparator sTimeAsc = new JobStatusComparator(true, JobStatusComparator.START_TIME);
Comparator sTimeDsc = new JobStatusComparator(false, JobStatusComparator.START_TIME);
Comparator eTimeAsc = new JobStatusComparator(true, JobStatusComparator.END_TIME);
Comparator eTimeDsc = new JobStatusComparator(false, JobStatusComparator.END_TIME);
Comparator durationTimeAsc = new JobStatusComparator(true, JobStatusComparator.DURATION);
Comparator durationTimeDsc = new JobStatusComparator(false, JobStatusComparator.DURATION);
<window border="none"
    <label id="message" />
    <listbox id="jobLog" height="100%" sizedByContent="true"
            <listheader label="No" />
            <listheader label="Date" sortAscending="${dateAsc}"
                sortDescending="${dateDsc}" />
            <listheader label="Session"
                sortAscending="${sessionAsc}" sortDescending="${sessionDsc}" />
            <listheader label="Job Name" sortAscending="${nameAsc}"
                sortDescending="${nameDsc}" sortDirection="ascending" />
            <listheader label="Start" sortAscending="${sTimeAsc}"
                sortDescending="${sTimeDsc}" />
            <listheader label="Finish" sortAscending="${eTimeAsc}"
                sortDescending="${eTimeDsc}" />
            <listheader label="Running Time"
                sortDescending="${durationTimeDsc}" />
        <template name="model">
                <listcell label="${forEachStatus.index + 1}" />
                <listcell label="${each.value.date}" />
                <listcell label="${each.value.session}" />
                <listcell label="${each.value.jobName}" />
                <listcell label="${each.value.startTime}" />
                <listcell label="${each.value.endTime}" />
                <listcell label="${each.value.duration}" />
    <timer id="timer" delay="5000" repeats="true" />


enter code here
package com.akarprima.idx.controller.daily;

public class JobLogController extends SelectorComposer<Component> {
private static final long serialVersionUID = 4463081939576759090L;
AppJobStatusDAO ajdao = new AppJobStatusDAO();

private Listbox jobLog;

private ListModelMap<String, JobStatus> jd = new ListModelMap<String, JobStatus>();

public void doAfterCompose(Component comp) throws Exception {

@Listen("onTimer = timer")
public void refresh() {
    AppUtils.compareAddMap(jd, ajdao.getJobLogDailyMap());
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-22 06:47:31 +0000

Darksu gravatar image Darksu
1910 1 4

Hello jomir,

Please refer to the following documentation, and specifically to the section "The On Sort Event", and "The Sort Method".


It shows how to accomplish your task.

Best Regards,


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2017-02-17 07:51:28 +0000

Seen: 11 times

Last updated: Feb 22

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More