Coming Up for Air

New Components in Mojarra Scales: Part IV – sc:combo

Thursday, February 18, 2010 |

Yesterday brought us Part III in our look at some new components in Mojarra Scales. Today, Part IV brings us sc:combo, combination, if you can imagine that, of a h:selectOneMenu and h:inputText.

The h:selectOneMenu is a nice control as it allows the application author to limit what the user can enter, thus helping insure data integrity (and sanity). Sometimes, though, it would be nice to offer a list of options for the user, but allow him to enter any arbitrary alternative. Unfortunately, the HTML spec doesn’t offer this kind of control. Lucky for us, though, this is fairly easy to implement using some of the nice JavaScript widgets provided by YUI. Here’s a sample:

1
2
3
<sc:combo id='combo' style='width: 500px' value='#{comboBean.value}'>
    <f:selectItems value='#{comboBean.selectItems}'/>
</sc:combo>

This should look very familiar to anyone who has used any of the selection components in JSF (h:selectBooleanCheckbox, h:selectManyCheckbox, h:selectManyListbox, h:selectManyMenu, h:selectOneListbox, h:selectOneMenu, or h:selectOneRadio). About the only change is the name of the parent tag. Rendered, you should see something like this:

Mojarra Scales sc:combo screenshot

As the user keys in his choice, should he choose to do so, type-ahead will attempt to complete his entry for him from the available options. If one is not found, though, the user is free to enter what he desires.

In the next installment, we’ll take a look at sc:resize, a component that adds resizing capabilities to another control on the screen.

Search

    Quotes

    Sample quote

    Quote source

    About

    My name is Jason Lee. I am a software developer living in the middle of Oklahoma. I’ve been a professional developer since 1997, using a variety of languages, including Java, Javascript, PHP, Python, Delphi, and even a bit of C#. I currently work for Red Hat on the WildFly/EAP team, where, among other things, I maintain integrations for some MicroProfile specs, OpenTelemetry, Micrometer, Jakarta Faces, and Bean Validation. (Full resume here. LinkedIn profile)

    I am the president of the Oklahoma City JUG, and an occasional speaker at the JUG and a variety of technical conferences.

    On the personal side, I’m active in my church, and enjoy bass guitar, running, fishing, and a variety of martial arts. I’m also married to a beautiful woman, and have two boys, who, thankfully, look like their mother.

    My Links

    Publications