You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "sean schofield (JIRA)" <my...@incubator.apache.org> on 2005/04/19 15:39:59 UTC

[jira] Updated: (MYFACES-167) x:inputCalendar and conversion/validation errors

     [ http://issues.apache.org/jira/browse/MYFACES-167?page=all ]

sean schofield updated MYFACES-167:
-----------------------------------

    Fix Version: 1.0.9 beta
                     (was: Nightly Build)

> x:inputCalendar and conversion/validation errors
> ------------------------------------------------
>
>          Key: MYFACES-167
>          URL: http://issues.apache.org/jira/browse/MYFACES-167
>      Project: MyFaces
>         Type: Bug
>  Environment: Any
>     Reporter: Enrique Medina Montenegro
>     Assignee: 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.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!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira