Quantcast
Channel: Kwintessential Notes
Viewing all articles
Browse latest Browse all 305

I have sorted it out

$
0
0

The comparator I described earlier is now implemented in the Run4Fun application. It did not take too much changes.

First I added a combo-box that allows a user to select by which json property and which order the collection should be sorted:

In the back-end I made it as followed:

So each option is language-supported. For actual sort options (and not the ‘Sort by’ intro option) I add some options:

  • the first value is empty. This allows me to differentiate an actual sort option with the intro option 🙂
  • the second value is the json property to sort on
  • the third option is the order, I have set descending as default, so when I want to have it ascending I have to provide a false value.

At every selection I have to reload the collection and put it in a viewscope that the repeat control uses as data-source.

For the Java MVC architecture I had to create a new method for the sort options:

Since the sortOrder comes in as string have to convert it to a boolean.

The combobox is bounded to a viewscope so the selected option stays in focus when I refresh the page:

Awesome. TV time!


Viewing all articles
Browse latest Browse all 305

Trending Articles