You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Virtudazo, Dennis (Exchange)" <dv...@bear.com> on 2005/11/03 16:35:10 UTC

Skipping date conversion validation

I have an inputText that is not required, that uses the
f:convertDateTime tag. If I blank out the inputText it causes a dateTime
conversion error. How can I skip the conversion when the input is blank?

Below is the code:

<h:inputText id="startTime" value="#{bean.startTime}" required="false">
  <f:convertDateTime type="time" timeStyle="short"/>
</h:inputText>



***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation, 
offer or agreement or any information about any transaction, customer 
account or account activity contained in this communication.
***********************************************************************


Re: Skipping date conversion validation

Posted by Mike Kienenberger <mk...@gmail.com>.
Are you sure you blanked it out?

If you take a look at javax.faces.component.UIInput.validate(), you'll see

        if (submittedValue == null) return;
        Object convertedValue = getConvertedValue(context, submittedValue);

It seems to me that you'd never trigger the converter if the value was
not specified.   I don't think http sends back form data for empty
inputs, but maybe I'm wrong.

You could try setting a breakpoint on the code above and examine the
contents of submittedValue to see what it holds.

On 11/3/05, Virtudazo, Dennis (Exchange) <dv...@bear.com> wrote:
> I have an inputText that is not required, that uses the
> f:convertDateTime tag. If I blank out the inputText it causes a dateTime
> conversion error. How can I skip the conversion when the input is blank?
>
> Below is the code:
>
> <h:inputText id="startTime" value="#{bean.startTime}" required="false">
>   <f:convertDateTime type="time" timeStyle="short"/>
> </h:inputText>
>
>
>
> ***********************************************************************
> Bear Stearns is not responsible for any recommendation, solicitation,
> offer or agreement or any information about any transaction, customer
> account or account activity contained in this communication.
> ***********************************************************************
>
>