Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Any
Description
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.class);
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)
throws:
throw new IllegalArgumentException(
"Expected submitted value of type Date for
component : "+
getPathToComponent(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!
Attachments
Issue Links
- is a clone of
-
MYFACES-167 x:inputCalendar and conversion/validation errors
-
- Closed
-