myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik-Berndt Scheper (JIRA)" <>
Subject [jira] Created: (MYFACES-383) x:inputCalendar and conversion/validation errors
Date Wed, 03 Aug 2005 10:59:35 GMT
x:inputCalendar and conversion/validation errors

         Key: MYFACES-383
     Project: MyFaces
        Type: Bug
 Environment: Any
    Reporter: Erik-Berndt Scheper
 Assigned to: sean schofield 
     Fix For: 1.0.9 beta

I'm using the MyFaces tag named x:inputCalendar in order to let the
user select a date from a popup calendar or enter it directly. If the
user enters a valid date, everything goes perfect.

The problem comes when the user enters something wrong, for example
letters. The component tries to convert this value to a valid date
(following the pattern, if there is one), and then throws a
ConvertException exception, so the Apply Request Values phase returns
false, and LifeCycle jumps to the render phase.

When rendering, the component is asked to encode itself, so the
following code is executed:

public void encodeEnd(FacesContext facesContext, UIComponent
component) throws IOException
RendererUtils.checkParamValidity(facesContext, component,

HtmlInputCalendar inputCalendar = (HtmlInputCalendar) component;

Locale currentLocale = facesContext.getViewRoot().getLocale();

Date value = RendererUtils.getDateValue(inputCalendar);


As you can see, the last visible line of this code is:

Date value = RendererUtils.getDateValue(inputCalendar);

so it forces the actual value of the inputCalendar to be a date. And
as obviously we come from a conversion error and that means the value
is not a valid date, the RendererUtils.getDateValue(inputCalendar)

                   throw new IllegalArgumentException(
                           "Expected submitted value of type Date for
component : "+

so this exception results in a ServletException that brings up the
undesirable "full of Java trace annoying text" page to the user.

I was wondering why the encondeEnd of this component forces the value
to be obtained to be a date, when anything can be entered in a input
text box.

I've been looking at the common h:inputText tag and its component
always uses the RenderUtils.getStringValue method from its encodeEnd
method, so if a conversion/validation error has been detected, it is
presented to the user using the friendly mechanism of a FacesMessage
and the well-known messages tags.

So I think this could be a bug as no validation can be done at all!

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message