|Latest 7 Posts
| Composing With Docker|
Thu, Nov 2nd 2017 9
| Hacktoberfest and More|
Tue, Oct 24th 2017 5
| Go Evergreen|
Tue, Oct 17th 2017 11
| Change is in the Air|
Fri, Sep 1st 2017 6
| Open Source Contribution|
Fri, Jun 16th 2017 8
| Docker Quick Tips|
Fri, Apr 28th 2017 7
| Notes in 9: Dev Tools Grab Bg|
Tue, Apr 4th 2017 4
| Custom JSON Serialization With GSON|
Mon, Jan 23rd 2017 12
| Everything Old is New Again|
Mon, Oct 24th 2016 11
| Go Evergreen|
Tue, Oct 17th 2017 11
| Notes in 9: Docker + SonarQube|
Wed, Feb 24th 2016 10
| Building Java Objects From JSON|
Thu, Jan 22nd 2015 9
| Scripting Server Upgrades|
Fri, Nov 11th 2016 9
| Composing With Docker|
Thu, Nov 2nd 2017 9
| REST is Best|
Wed, Sep 17th 2014 8
| XSLTProc in the Buff|
Thu, Mar 24th 2016 8
| Git Squash|
Thu, Oct 20th 2016 8
||When You Need a Comparator
Many of the XPages Managed Bean demonstrations point to your ability to populate an xp:comboBox with a custom defined List of Select Items. One thing that seems to happen to me is that I wind up having to re-sort such lists to work off of their Label, as opposed to their value; so as to look sorted, at least to human eyes.
A Brief ComboBox Anatomy Lesson
An xp:comboBox lets us build out a list (preferably somewhat short) of values with their labels, which are selected from a “drop down” like interface. More specifically, from MDN,
The HTML select (<select>) element represents a control that presents a menu of options. The options within the menu are represented by <option> elements, which can be grouped by <optgroup> elements. Options can be pre-selected for the user.
But you’re here for the code. Here’s an incredibly simple select tag implemented with three options. If you switch to the HTML pane, you’ll see that the value (which is what can be data bound for value in the xp:comboBox control) is 1, 2, or 3 while the labels are their English equivalent of One, Two, or Three. In classic Notes, we would achieve this by the usual list (line separated) by passing in sets of Label | Value, separated by the pipe character. You can still do this in XPages, but if you’re defining the source for one in a bean, you’ll want to build out your List. My sample class below shows this, but the meat and potatoes here is the Comparator.
Enter java.util.Comparator. It’s a member of the Collections Framework, making it ideal for sorting Collections (which a List is). So, to begin, we’ll define a class (you can nest it in another class, as I have, a stand-alone class, or a member of another, utility class. This class contains a single, public compare method, which returns an int. It returns an int, as that’s what’s returned by the compareToIgnoreCase method of java.lang.String. All the compare method is doing is comparing whether the first string is before or after the second string.
Here’s my super simple sample bean, with the selectOptionsList being read-only (no setter method) as it’s just the selectedOption being what the value to be stored is.
The XPage control implementation is a standard xp:comboBox implemented with the value and select items (options) bound via EL. The value which the user selects is bound to the bean’s property of selectedOption while the list of SelectItems (options list, with both value and labels populated) is the selectOptionsList property.
Here’s the full gist link, with class, XPage, and faces-config (in case anyone is looking for how my bean is registered).
Jan 08, 2015
| Recent Blog Posts
Composing With Docker|
Thu, Nov 2nd 2017 2:00p Eric McCormick
Background About a year ago, I blogged on automating server upgrades with Docker and a BASH script. This met the needs I had at the time, and worked itself out to be pretty stable. But, since I think about such things and always question my preconceptions, I went down a path of creating a Docker compose config file, something I wouldn’t have had to create from scratch by waiting a little while as one appeared as an example from GitLab. As it turns it, it was a great learning experience regardl
Hacktoberfest and More|
Tue, Oct 24th 2017 2:00p Eric McCormick
Hacktoberfest 2017 October brings many good things with it. It’s the beginning of autumnal colors here, along with some yard raking in my case. It also brings with it not just Oktoberfest, but Hacktoberfest! Hacktoberfest 2017 Hacktoberfest is a month long open source support initiative, sponsored by Digital Ocean, partnering with GitHub. It’s meant to promote open source involvement and contribution. As added incentive, if you meet the criteria, you can get a free t-shirt (and stickers).
Tue, Oct 17th 2017 4:00p Eric McCormick
Happy 🎂 Day IE 11! On the 17th of October in 2013, Internet Explorer 11 was released from Microsoft. That means that as of today, this popular* browser is now four years old and, with all respect to it, it really ought to go. Good day sir. I said good day! Evergreen Browsers What makes a browser, or any software for that matter, evergreen? Well, the basic requirements for a browser, or any piece of software for that matter, are specifically the support of automatic updates, that bring in:
Change is in the Air|
Fri, Sep 1st 2017 1:00p Eric McCormick
I’m Back What Can I Say? In Case You Missed It If you find yourself asking “where was Eric?”, this should summarize it all: Instead of trying to do everything all summer, I tend to take a break from blogging and a lot of open source endeavors over the summer. It means I can focus on family time along with yard and house projects. Ah... Summer That’s all paid off and, with fall fast approaching, I’ve found myself wanting to start those things back up; ramping up into winter when
Open Source Contribution|
Fri, Jun 16th 2017 5:00p Eric McCormick
Intro It’s time to clear some of the backlog. I started this post a few months back and it should probably be sent on its way to clear the pile of drafts I haven’t finished yet… 🤔 I have a bit of a passion for open source software. My preferred distribution of Linux has been Ubuntu since 4.10, the Warty Warthog (I was even a minor contributor on a short lived, wildly popular project that aimed at improving the Ubuntu experience early on), I’ve enjoyed most open source projects I’ve
Docker Quick Tips|
Fri, Apr 28th 2017 3:00p Eric McCormick
Docker If you have been living under a rock, Docker is pretty much amazing. If you haven’t been living under a rock, you may be getting used to the idea of Docker, but still have the occasional question. I’ve found myself using Docker in increasing amounts and complexity over the last year or so. I’ve recently decided to start recording some of the tasks I’ve found useful, some of which may be less familiar to a beginner. If you’re so inclined, check out the playlist, embedded here.
Notes in 9: Dev Tools Grab Bg|
Tue, Apr 4th 2017 1:00p Eric McCormick
Intro I’m on Notes in 9 again, with a “grab bag” of a couple of tools I’ve put together recently that may be of a varying degree of useful for other Domino + XPages developers. You don’t need these to do development, but for the right person, they may help with their development workflow. Also of note, with the upgrade to Swiper with the FP8 release of Notes + Domino Designer, the limitations previously mentioned are no longer there! This means that my second tool I talked about, node-
Custom JSON Serialization With GSON|
Mon, Jan 23rd 2017 2:00p Eric McCormick
Mon, Jan 16th 2017 3:00p Eric McCormick
Per usual, I’ve had a little break between things and decided to catch up with a bit of a summary of some recent things that each didn’t necessitate their own post.
2017 IBM Champion
For starters, I’m honored to be named an IBM Champion in Collaboration Solutions (/ Social Business) for the third time. This would be a hat trick in (ice) hockey 🏒. I’m happy to be recognized with a group of people, developers and more, who are passionate about both their work and the plat
Rebirth: An App of Ice and Fire|
Wed, Dec 14th 2016 4:00p Eric McCormick
If you read my blog for any of the Saga of Servlets series, then I hope that you’re excited I’m returning to the application I put together for it. This time, it’s as a conversation piece in regards to some of the build process modernization I engaged in recently, in order to unify the code base in its git repository. In any case, it’s helping pave the way forward before I update some of the back-end elements, when it will again be a talking point for some additional rework and