Unified EL – Craziness when handling Strings

Looking at a bug, I noticed some craziness is going on with the unified EL and coercion rules for String. It converts every null object to an empty String.

Take this TLD snippet from the core.tld, for the standard convertDateTime tag:


So, the pattern is String, fine. Now imagine this:

<h:inputText value="#{bean.aRegularDate}">
  <f:convertDateTime pattern="#{boundToSomeNullValue}" />

This does not display the date value. Why ?Simple. The pattern is converted to an empty String (“”) and, when pushing an empty String as the pattern to the SimpleDateFormat class, the format method returns “” as well:

SimpleDateFormat sdf = new SimpleDateFormat("");

System.out.println(sdf.format(new Date()));

For reasons like that, in Trinidad we just do this:

  <deferred-value />

So, a tag like this works <tr:convertDateTime pattern=”#{boundToSomeNullValue}” />.See also this bug, which I noticed, during looking at another bug 🙂



Posted in jsf, jsp, myfaces, trinidad

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: