Use the JSF converters/formatters
<h:outputLabel value="Date Due" for="dueDate" />
<h:inputText id="dueDate" value="#{MBean.dueDate}" readonly="true" >
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:inputText>
Stefan Maric | IT & Professional Services | BT Global Services
E: [EMAIL PROTECTED] | www.bt.com/globalservices
This electronic message contains information from British Telecommunications
plc, which may be privileged
or confidential. The information is intended for use only by the individual(s)
or entity named above. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution or use of the contents of
this information is strictly prohibited. If you have received this electronic
message in error, please notify
me by telephone or email (to the number or email address above) immediately.
Activity and use of the British Telecommunications plc e-mail system is
monitored to secure its effective
operation and for other lawful business purposes. Communications using this
system will also be monitored
and may be recorded to secure effective operation and for other lawful business
purposes.
British Telecommunications plc. Registered office: 81 Newgate Street London
EC1A 7AJ Registered in
England no: 1800000
-----Original Message-----
From: Mathias Brökelmann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 19, 2005 3:02 PM
To: MyFaces Discussion; Maxence Dewil
Subject: Re: Validation of inter-dependent fields
Please try to send your mails to the mailing list users_at_myfaces.apache.org
too. I´m not sure if know the right answers. So give the other users a chance.
How do you convert the date instance into a string instance to be used for
h:outputText?
It is possible that you have to take care for the timezone. Try using
java.text.DateFormat.getDateInstance(style, locale) which gives you the right
DateFormat instance for a given locale. You can call
DateFormat.setTimeZone(timezone) to provide the timezone before you format the
date into a string. You can also define a timezone for t:inputDate which will
be used for the dates the user enters.
2005/10/19, Maxence Dewil <[EMAIL PROTECTED]>:
> It's a master-detail navigation.
>
> The component rendering the date in the master datatable is a simple
> h:outputText (the date of the previous day is rendered).
>
> The component used to edit the date in the detail page is a
> t:inputDate (the date is rendered correctly)
>
> Regards.
>
> Maxence Dewil.
>
> -----Message d'origine-----
> De: Mathias Brökelmann [mailto:[EMAIL PROTECTED]
> Envoyé: mercredi 19 octobre 2005 15:23
> À: Maxence Dewil; MyFaces Discussion
> Objet: Re: Validation of inter-dependent fields
>
> I foreward this to the mailing list. I currently don´t have an idea
> why this happens. Do you use t:inputDate or a simple h:inputText?
>
> 2005/10/19, Maxence Dewil <[EMAIL PROTECTED]>:
> > Mathias,
> >
> > Ok it works, thx for your help.
> >
> >
> > If you have the time, I have another question:
> >
> > The dates of my application are rendered correctly in the UI components,
> > except in the datatables: the date '19/10/2005 00:00:00' is rendered as
> > '18/10/2005' and '19/10/2005 00:00:01' as '19/19/2005'.
> >
> > I don't understand this behavior.
> >
> > My dates are mapped to sql server datetimes via Hibernate 3 (so the
> > nanosecond part is included in each Date object).
> >
> >
> > -----Message d'origine-----
> > De: Mathias Brökelmann [mailto:[EMAIL PROTECTED]
> > Envoyé: mercredi 19 octobre 2005 10:55
> > À: MyFaces Discussion
> > Objet: Re: Validation of inter-dependent fields
> >
> > define a custom validator for the second date field (must be the second).
> >
> > <h:inputDate id="lowerDate" value="#{yourBackinBean.lowerDate}"/>
> > <h:inputDate value="#{yourBackinBean.upperDate}"
> > validator="#{yourBackingBean.validateDates}"/>
> >
> > public class YourBackingBean
> > {
> > public void validateDates(FacesContext context, UIComponent
> > component, Object value) throws ValidatorException
> > {
> > UIInput lowerComponent = (UIInput)component.findComponent("lowerDate");
> > if(lowerComponent.isValid())
> > {
> > Date lowerDate = lowerComponent.getValue();
> > Date upperDate = (Date)value;
> > // compare the two dates and throw a ValidatorException with
> > message if they are not valid
> > }
> > }
> > }
> >
> >
> > 2005/10/19, Maxence Dewil <[EMAIL PROTECTED]>:
> > >
> > >
> > >
> > > Hello,
> > >
> > >
> > >
> > > My application has to validate a form where a date depends on
> > > another date (the first one must be < the next one), but the JSF
> > > validation is component-oriented. How can I handle that in an elegant way?
> > >
> > >
> > >
> > > A solution is described here but I don't understand how to achieve it :
> > > http://weblogs.java.net/blog/johnreynolds/archive/2004/07/improve_
> > > jsf_by_1.html (#Validation of Inter-Dependent Fields).
> > >
> > >
> > >
> > > Regards,
> > >
> > >
> > >
> > > Maxence Dewil
> >
> >
> > --
> > Mathias
> >
>
>
> --
> Mathias
>
>
--
Mathias