myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik-Berndt Scheper (JIRA)" <myfaces-...@incubator.apache.org>
Subject [jira] Commented: (MYFACES-383) x:inputCalendar and conversion/validation errors
Date Wed, 03 Aug 2005 10:59:36 GMT
    [ http://issues.apache.org/jira/browse/MYFACES-383?page=comments#action_12317501 ] 

Erik-Berndt Scheper commented on MYFACES-383:
---------------------------------------------

I've cloned this issue (165) because I disagree with the solution provided.
Now when a user modifies the value after the popup to an invalid date, the message for key="javax.faces.component.UIInput.CONVERSION"
('Conversion error') is reported.

IMHO it would be a lot more user-friendly to show the message for key="org.apache.myfaces.Date.INVALID"
( the user entered an invalid date) .

It would be even better to provide javascript date validation (we're using javascript anyway,
because of the popup)  , but maybe I should post that as a feature request?

> x:inputCalendar and conversion/validation errors
> ------------------------------------------------
>
>          Key: MYFACES-383
>          URL: http://issues.apache.org/jira/browse/MYFACES-383
>      Project: MyFaces
>         Type: Bug
>  Environment: Any
>     Reporter: Erik-Berndt Scheper
>     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


Mime
View raw message