You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Martyn Hiemstra <m....@minihouse.com> on 2008/12/23 13:08:38 UTC

Tomahawk inputCalendar bug

Hi All,

I beleive I have discovered a serious bug in the inputCalendar 
component. This is the situation:

I have a form backing bean with a Joda datetime object in it. The value 
expression is #{formBackingBean.dateTime}. I create a htmloutput text 
and set it's value and I set the converter. I use this code:
<f:outputText value='#{formBackingBean.dateTime}" 
converter="DateConverter" />

This works perfectly. When I debug the DateConverter the value of the 
input text is the date time object from the form backing bean. I then 
format the date time object and I see the date in the output text box on 
the screen. By the way the DateConverter is a custom converter that 
converts joda DateTime objects into a String and vice versa.

Now I create a tomahawk inputCalendar and set the value and the 
converter in the same way like this:
<t:inputCalendar value='#{formBackingBean.dateTime}" 
converter="DateConverter" />

When I debug the date converter, the moethod getAsString indicates that 
the value of the input calendar is null. I beleive there is a bug in the 
input calendar object since the joda date time object from the form 
backing bean is not loaded in the input calendar. I use the same value 
expression as the output text and that component works perfectly so it 
isn't some typo.

Any help would be great,
Martyn Hiemstra

Re: Tomahawk inputCalendar bug

Posted by Michiel Weggen <m....@minihouse.eu>.
I managed to fix this by expanding the converter to be able to handle
java.util.Date.
I made it extend from HtmlCalendarRenderer.CalendarDateTimeConverter, and
added a getAsDate method that converts the joda DateTime to a Date object,
like this:

	public Date getAsDate(FacesContext facesContext, UIComponent uiComponent) {
		Object value = RendererUtils.getObjectValue(uiComponent);
		if (value instanceof DateTime) {
			return ((DateTime) value).toDate();
		}
		throw new IllegalArgumentException(
				"Expected submitted value of type DateTime for component : "
						+ RendererUtils.getPathToComponent(uiComponent));
	}

Michiel Weggen




Martyn Hiemstra-3 wrote:
> 
> Hi All,
> 
> I beleive I have discovered a serious bug in the inputCalendar 
> component. This is the situation:
> 
> I have a form backing bean with a Joda datetime object in it. The value 
> expression is #{formBackingBean.dateTime}. I create a htmloutput text 
> and set it's value and I set the converter. I use this code:
> <f:outputText value='#{formBackingBean.dateTime}" 
> converter="DateConverter" />
> 
> This works perfectly. When I debug the DateConverter the value of the 
> input text is the date time object from the form backing bean. I then 
> format the date time object and I see the date in the output text box on 
> the screen. By the way the DateConverter is a custom converter that 
> converts joda DateTime objects into a String and vice versa.
> 
> Now I create a tomahawk inputCalendar and set the value and the 
> converter in the same way like this:
> <t:inputCalendar value='#{formBackingBean.dateTime}" 
> converter="DateConverter" />
> 
> When I debug the date converter, the moethod getAsString indicates that 
> the value of the input calendar is null. I beleive there is a bug in the 
> input calendar object since the joda date time object from the form 
> backing bean is not loaded in the input calendar. I use the same value 
> expression as the output text and that component works perfectly so it 
> isn't some typo.
> 
> Any help would be great,
> Martyn Hiemstra
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomahawk-inputCalendar-bug-tp21143374p23959245.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.