Side Jobs: Log Hound Javascript Logger

November 1st, 2010 No comments
Name: Log Hound
Language: JavaScript

JavaScript.  Logging.  Why is that so hard to understand?   Maybe I should start at the beginning.

In some of the positions I’ve held over the past few years, I’ve had occasion to really dive deep into JavaScript.  Very, very deep.  Eval deep.  Since my primary language is Java, I have grown used to the myriad tools that make my coding life easier, of which logging frameworks provide the largest benefit aside from run-time debuggers.  It’s nice to know exactly what your code is thinking as it displays all your customers’ private information on your public web site due to a misplaced semi-colon.
Read more…

Server Migration Blues

April 5th, 2010 1 comment

Ow ow ow ow ow!!!!

If one of my two readers is wondering why this sporadic blog was down for the last week and a half – you can blame it on my unending need to tinker and insatiable need for more power. Read more…

Categories: MyTechHell Blog Tags:

Your Best (Regex) Buddy

February 20th, 2010 1 comment
Name: RegexBuddy
Version Reviewed: 3.4.1
Operating System: Windows XP, Vista, 7
Price: 39.95 single user license.
Good: Decodes regular expressions.
Contextual assist allows building expressions without knowing any syntax.
Supplies access to help forums directly through a tab.
Allows debugging of expressions.
Provides a library of pre-made expressions for all types of data.
Bad: No free trial.

No More Loosing Your Mind

Regular expressions.  The term should fill you with both a magical wonder of one of the most powerful languages in all of code-dom, and an overpowering frost-fingered fear of one of the most complex languages on Earth.  Next to a Hopi Code Talker, a Wizened Old Unix Guru that can spout regex like it was his first languages is one of the most rare (and probably well-paid) individuals in the world.  For us developers that need to use them once in a while, though, winding our way through the syntax is time-consuming and confusing and sometimes doesn’t end well.

I’ve seen several tools over the years to help with the regex syntax, but about a year ago, a friend of mine turned me on to RegexBuddy.  Three seconds later, I owned a license. Read more…

Recipe: Shepard’s Pie

February 6th, 2010 No comments

I’m hungry!

Wait, what???? This is a techie blog, not a foodie rag, so what in the name of the bleeding edge is a post of the gastronomical persuasion doing here??? Look – even über-geeks can’t live on just pizza and soda (for more than a few weeks).  Seeing as how we usually don’t have much time to spend making food, I’ve got a list of a few quick dishes I can make that last me a few meals, saving me time and keeping me fueled for those long hours toiling over a hot keyboard.  I’ve been asked by a friend to share one, and so I figured I’d bump my post average be a good friend and write it up for her here.  Don’t worry – I’m not going to do this often.  Take a little advise, though, and remember that the most successful geeks do not stay attached to the keyboard and mouse 24/7.  They have other hobbies too. Read more…

Categories: Food, Musings Tags:

Oracle: Paging Results

February 5th, 2010 No comments

Paging Oracle developers…

This will be a quick post, as the problem is small.  I will add, though, that setting up paging with database queries can be a major pain in the ass.  Setting up the consumer – usually jQuery, ExtJS, DWR, or some other AJAX client, is hard enough, but then you have to translate the client’s version of “start-limit” to the persistance-side’s language.  Sometimes it’s a simple start/limit pair, sometimes it’s a start/page pair, and then there’s Oracle, which decided to punt on the whole thing. Read more…

Categories: Grimoire, Oracle Tags: , , , ,

Frozen Explorer

January 21st, 2010 1 comment

A common problem, unfortunately…

This is a simple trick that will save you from having to restart your pc at inopportune times.  The setup – you are working along, minding your own business, writing your [insert invaluable document name] Word document, when out of the blue Windows Explorer freezes up.  You know the symptoms – you can’t click on anything on the desktop… you drag a window around and it leaves “trails”, which everyone will automatically cover the entire desktop in (because it’s fun!).  A few seconds later, you realize that you can’t get to your Word document as well, and you hadn’t saved it.  “That’s [x] hours of work!” you silently scream to yourself as you contemplate the glowing frozen tableau in front of you, dread slowing sinking down into the pit of your stomach.  Now what the hell do you do?

The answer is to try this trick.  It can’t hurt, and it just might recover your computer enough to save your document and restart.  It actually might allow you to keep working normally, but when I’m doing something important, I usually ere on the side of caution – the side where you save anything and restart just to make sure. Read more…

Categories: XP Tricks Tags: , ,

Haiti Relief Fund Through Your Cell Phone

January 15th, 2010 No comments

Update: 6:20 EST, Friday, January 15 2010

So far as I know, if you text donations to any carrier other than AT&T, the service provider will waive the normal text charges. I guess the (twisted, greedy) spirit of Ma Bell still lives within AT&T. Way to go guys! For all other carriers – WAY TO GO GUYS! 🙂

You can help

This is just a quick post from special circumstances. I’m sure you’ve heard of what’s going on with Haiti right now, and the images coming out of there from the news networks would make you cry your eyes out. There’s a technology spin on this, though.

I have Verizon for my cell phone service, and I just donated $10 to the Red Cross using it. It was quick, easy, painless, and the right thing to do. If you’ve got a cell phone, most likely you could donate another $10 in about two minutes to one of eight different charities, and I’m pretty sure it works for just about any service provider.

Look here:

… and pick your charity. As far as using your cell phone goes, it’s a four step process.

  1. Text whatever number corresponds to you choice of donation. For me, it was 90999 and the text was “HAITI”
  2. You get an immediate text back asking to confirm your donation. For me, it asked that I just text “YES” back.
  3. You get another instantaneous response asking if you want to continue getting text updates from your chosen charity. This may only be a Red Cross thing, but you can just text whatever they ask to them to not spam you. In my case, I just texted back “STOP”.
  4. One more text comes back confirming your donation and your preference to not receive any more messages.

That’s all there is to it. Your next service bill gets a small bump, and $10 goes to helping a country that not only helped give us the Louisiana Purchase which doubled the size of our nation 200 years ago, but which most probably just lost a full one percent of it’s entire population. That’s 100,000 people. Think about it. $10 will get you maybe two lattes at Starbucks in the USA. $10 in Haiti might buy enough antibiotics to save a few people’s lives. Take a few minutes out of your day, go to the Huffington Post page, pick your charity, and give, tech-style. It’s good for the soul.

JSF: SelectOneComboBox

January 13th, 2010 5 comments
Post Technology Stack
  • MyFaces 1.1.7 (JSF 1.1 spec)
  • Java 1.5
  • MyFaces Tomahawk 1.1.9
  • ExtJS 3.1 *

Not Again…

JSF, that steaming pile of undocumented, developer-hating obfuscation has yet again soaked up about 16 hours of my time to do something that should have been a three second configuration. Just to reiterate, much like Randall Munroe’s hatred of velociraptors spurs him to evaluate houses based on their ability to repulse dinosauriod attacks, I find myself now evaluating jobs by how close the project requirements are to actually using the JSF framework.

That said, when you’re a contractor, you use the tools selected for you by the almighty architects. In my case, it’s JSF or my paycheck. Being the Alpha Geek that I am, I gratefully welcomed the paycheck an opportunity to learn more about JSF.

What did they do now???

The crux of the problem is right in the title of this post. Combo box. JSF doesn’t have one, and I needed one. Being the Jack of All Tech that I am, I figured it would be relatively simple to grab the ExtJS combobox and front the JSF selectOneMenu control with it. So long as the ExtJS code didn’t monkey with all the javascript and DOM that the JSF selectOneMenu control created, I’d have myself a nice little combobox that worked with JSF. Well, if you’ve been coding for any longer than two minutes, you know just how screwed up things can get right after you utter the words “That was easy!”.

In this case, the problem emerged as an inability to submit the form of which the combobox was a part. Weirder still, submitting was only a problem when I entered in a value that was not in the dropdown list. Armed with Eclipse and 18mg of ritilin, I spent a few hours tracing the problem down to validation which myfaces was perpetrating on the submitted combobox value – validation that was not implemented as an official Validator.

Here I give you a few lines in javax.faces.components.UISelectOne from where the problem stems. Line 69 is perfectly fine, setting off an execution chain that includes getting the list of validators that have been assigned to the component and executing them. That is not where our problem validation happens, and that’s the problem. Line 77, when parsed, creates an iterator for the list of options created for the drop-down. That iterator is then sent to the _SelectItemsUtil.matchValue method which then makes sure that the submitted value for the drop-down component is one of the available options… and there’s the reason I will never get hours of my life back. See, we’ve got code that runs all the validators assigned the UISelect descendant class, then we’ve got what amounts to a hardcoded validation right after that. Isn’t that great!

protected void validateValue(FacesContext context, Object value)
    super.validateValue(context, value);
    if (!isValid() || value == null)
    // selected value must match to one of the available options
    if (!_SelectItemsUtil.matchValue(value, new _SelectItemsIterator(this)))
        _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID,
                        new Object[] {getId()});

Showing the code who’s boss

You’d think that would be the end of the combobox quest. I mean, if checking the submitted value against the options is hardcoded into a core-core API class, you’re basically screwed, right? No getting around that… If you answered yes, please stop reading here, turn in your geek badge, and go read yourself some FARK. If you answered by opening up firefox to the myfaces api and started looking for chinks in the API armour, then read on! …Oh – and if your answer was to break out your Wiha precision screwdriver set and pop the hood off your rig, it’s time to switch to decaf.

* A few important notes first. This solution uses an ExtJS combobox for the UI portion of the hack. ExtJS is, unfortunately, a semi-free library. The “semi” part comes in if you use the library for any public facing user-interfaces which are not open source. Of course, the licensing scheme is waaaay more complicated than that, so I suggest you visit ExtJS’s Licensing Overview page to figure out just what your options are. At the time of this writing, I don’t know of any completely open-source combobox solutions that can interact successfully with the underlying generated JSF DOM structures. If you do, leave a comment!!! Otherwise, the Java/JSF portion of this hack takes care of the application side of things and should be usable (or make usable) any UI combobox solution.

Let’s start with the html/jsp code to make the front end of our combobox work:

<h:form id="carCreatorForm">
    <t:selectOneMenu id="colourSelect"
        <t:selectItems var="colour"

A few assumptions:

  1. colourShelf is an object that holds available colors and is defined as a JSF managed bean, and it has a getColours method that returns a Java List collection of color names.
  2. car is also defined as a JSF managed bean, and has a setColour method.
  3. selectOneComboHelper is defined as a JSF managed bean, and will be discussed shortly.
  4. I dislike JSF immensely.

The above code is standard for creating a selectOneMenu component for MyFaces using the Tomahawk taglibs. The selectOneMenu tag has the value attribute tying the selected value to the “car” managed bean. The selectItems tag creates the option list. In short:

  1. The value attribute says to call the getColours method on the colourShelf managed bean, which in the example’s case returns a Java List collection of colour name strings.
  2. The var attribute states that “colour” will be the variable name in which the string colour names from the list will be stored.
  3. The selectItems tag iterates over the strings in the colour name list, creating new option elements for the select element created by the selectOneMenu tag.

Now that we have our list menu, here’s the code that makes it a combobox:

    <!-- Ext relies on its default css so include it here. -->
    <!-- This must come BEFORE javascript includes! -->
    <link rel="stylesheet" type="text/css" href="js/extjs/resources/css/ext-all.css">
    <!-- Include here your own css files if you have them. -->
    <!-- First of javascript includes must be an adapter... -->
    <script type="text/javascript" src="js/extjs/adapter/ext/ext-base.js"></script>
    <!-- ...then you need the Ext itself, either debug or production version. -->
    <script type="text/javascript" src="js/extjs/ext-all-debug.js"></script>
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="styles.css">
    <script type="text/javascript">
    // Path to the blank image must point to a valid location on your server
    Ext.BLANK_IMAGE_URL = 'js/extjs/resources/images/default/s.gif';
    // Main application entry point
    Ext.onReady(function() {
        var converted = new Ext.form.ComboBox({
            typeAhead: true,
            triggerAction: 'all',

The above is standard ExtJS – you include all the ExtJS scripts in the head element of the page, and then use the Ext.onReady function to initialise your ExtJS UI components. The secret to getting ExtJS to recognise and transform the JSF select box is to remember that the HTML form element IDs JSF generates are the name of the form first, a colon, and then the ID you assigned the element. In the case of the code above, our form name is “carCreatorForm”, and the ID of the select menu is “colourSelect”, hence “carCreatorForm:colourSelect”.

The ExtJS combobox transform attribute tells the component that it isn’t going to create a combobox from scratch, but will instead create one from an existing select element (I’ve gotta tell ya – I love those guys at ExtJS!). That means when the html page’s body’s “onLoad” event fires, ExtJS will seek out a DOM element with the name “carCreatorForm:colourSelect”, suck all the information out of it, remove it, and replace it with pod-person combobox version.

Managing JSF shortcomings

With the user-interface portion of our little hack done, we turn now to the underlying MyFaces code that so offends our idea of “How Things Should Work”. Honestly, I don’t have time to figure out if this same “bug” exists in other JSF implementations, or even later versions of MyFaces. If not, then you are already home free and the rest of this post only serves to show you how clever I am (I am extremely clever!). If you try the above and find that the page refreshes without any form elements getting bound to their backing beans, however, this next part my serve as a guide, if not an outright shortcut to getting a working combobox.

To recap (damn, this is a long post!), the symptoms of the problem is the lack of anything actually happening when you hit the form’s submit button. The screen refreshes, but none of the form values are bound to their associated backing beans. Another symptom is this nebulous entry in your log files:

DEBUG | 2010-01-12 15:19:18,550 | | exiting from lifecycle.execute in PROCESS_VALIDATIONS(3) because getRenderResponse is true from one of the after listeners

According to the code, there should have been another error along the lines of:


…but no amount of fiddling with Log4j would make it appear.

Anyhoo, that debug log message is the clue to what is really happening. When the code decides that you are vainly trying to trick it by providing a value that wasn’t on the approved option list, it stops the bus at the third JSF lifecycle step of “Process Validations”, turns it around and leaves the way it drove in. Just so you know, the fourth lifecycle step is “Update Model Values”, which is where the form values would have been bound to the backing beans. It’s also where the bathroom was, which is why you get that bloated, unfulfilled feeling when you see the page refresh with no joy for the backing beans.

Giving JSF more “options”

I know this post is aging you where you sit, that your coffee is cold, and that you are starting to worry about deep vein thrombosis, but there’s only two parts to this hack and all the background’s been covered, so just stay with me a few more paragraphs!

I’ve seen very few APIs that were bullet proof – meaning that I couldn’t screw with them. The general rule is the more complex or less well-developed the API, the easier it is to screw with. That axiom in mind, JSF is extremely easy to screw with! Let’s start with a “helper” class, and when I say helper, I mean l33t h4x0r c0Dz:

package com.facets.examples;
import java.util.List;
import javax.faces.component.UISelectItems;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.component.html.ext.HtmlSelectOneMenu;
public class SelectOneComboBox {
    private HtmlSelectOneMenu component;
    public HtmlSelectOneMenu getHtmlSelectOneMenu() {
        return this.component;
    public void setHtmlSelectOneMenu(HtmlSelectOneMenu component) {
        this.component = component;
        // Get _ComponentChildrenList, with list of child components of the SelectOneMenu component.
        List children = component.getChildren();
        if(children==null || children.isEmpty()) {
            // If no children, page is probably just being rendered, not submitted, so nothing
            // needs to be (or can be) done.
        // Tell myfaces to marshal the submitted values so we can get to them. 
        // This is the previous value of the component - the last value to be submitted.
        Object value = component.getValue();
        // This is the current value of the component - the value just submitted.
        Object subValue = component.getSubmittedValue();
        if(!(subValue instanceof String)) {
        String valueStr = (String)subValue;
        // Get the only child of the SelectOneMenu - the SelectItems component.
        UISelectItems itemsComp = (UISelectItems)children.get(0);
        // Get the array of values from the SelectOneMenu.
        SelectItem[] items = (SelectItem[])itemsComp.getValue();
        // Is the submitted value one of the listed option values?
        for(SelectItem item : items) {
            if(!StringUtils.isBlank((String)item.getValue()) && item.getValue().equals(valueStr)) {
                return; // Submitted value is a listed option - nothing needs to be done.
        // Create a new value for the written-in value of the combobox.
        SelectItem newValue = new SelectItem(valueStr,valueStr);
        // Create and fill a new array for the existing option values and the one written in value.
        SelectItem[] newItems = new SelectItem[items.length+1];
        for(int i=0;i<items.length; i++) {
            newItems[i] = items[i];
        newItems[items.length] = (new SelectItem(valueStr));
        // Set the new value array on the SelectItems component so the backing list now includes
        // the written-in value.
        // Tell the component that the submitted value is an object from the backing list.

For the most part, everything you need to know about the class exists as inline comments in the code above. Regardless of whether the backing list for the SelectItems component contains strings or objects of your own design, the above should work because it is called between the second and third lifecycle steps (2=Apply Request Values, 3=Process Validations). Since the “Process Validations” step is where everything is converted to the underlying object model from the necessary string values for the front-end HTML UI, strings are all you really have to deal with. I would be careful if you are using Enums as your backing list objects, however, as you can’t just create a new Enum member on the fly from a new value.

To get this to work, you need two pieces of code. The first you saw in the jsp code above, specifically the “binding” attribute of the SelectOneMenu component. That snippet hands the select component object to the SelectOneComboBox.setHtmlSelectOneMenu method above. In order for the SelectOneComboBox object to exist, we need to add it as a managed bean to your faces-config file, like so:


Congratulations! Not only do you now have a working JSF combo box, but more importantly you have made it through my longest post yet!

JSF Tricks: Abstracted Actions

December 17th, 2009 2 comments

JavaServer Faces – Aw, crap…

I hate JavaServer Faces. I think JSF is a bloated abstraction-fest and just about any other framework makes it easier to write MVC applications – even Struts. That being said, I’ve had to recently work with the beast, and in doing so I had to figure out how to do some things that wouldn’t even be an issue in Spring MVC, but required a workaround in JSF. One of those things is abstracting out actions from the JSF tags, and what follows is how to do it.
Read more…

Categories: Grimoire, JSF Tags: , , , , ,

Unlocking Your Problems With Unlocker

December 13th, 2009 No comments
Name: Unlocker
Version Reviewed: 1.8.8
Operating System: Windows XP, Vista, 7
Price: Completely free.
Site: (download)
Good: Helps solve one of the great mysteries of Windows – what the @!&$!!% is locking my file!?!
Easy enough to use for non-geeks (Yes mom – even you…)
Bad: Very simple for a utility, takes a smidgen of knowledge about Windows process to be used for anything more than unlocking files.
Verdict: Get it. Install it. Loose some stress.

Unlocker LogoA Small Utility For A Big Annoyance

You’re working on some files – say some dlls or .class files if you are a geek, or Word and Excel files if you’re mortal, and you need to move them.  No problem since you’ve moved files before – heck, anyone can move a file!  You right-click on the file to get the context menu, left-click on “cut”, right-click in the destination file, left-click on “paste”…

(Play music clip to get full experience of horror and rage)

Read more…