[SOLVED] Bug: ArrayIndexOutOfBoundsException Calendar

UI Components for JSF
Post Reply
User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

19 Mar 2010, 12:45

Hi Cagatay,

I think, you have a bug in the CalendarRenderer. Why do you define "pattern" attribute and try to parse regardless with separator "/"?

Code: Select all

			String[] tokens = selectedDate.split("/");
			
			return tokens[0].trim() + "/" + tokens[2].trim();
I have for example 19.03.2010 and get the following exception in the released 2.0.0 version

java.lang.ArrayIndexOutOfBoundsException: 2
at org.primefaces.component.calendar.CalendarRenderer.getPageDate(CalendarRenderer.java:308)
at org.primefaces.component.calendar.CalendarRenderer.encodeScript(CalendarRenderer.java:78)
at org.primefaces.component.calendar.CalendarRenderer.encodeEnd(CalendarRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:295)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:66)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:54)
at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:119)
at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:73)
at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:39)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:295)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:287)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:292)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:292)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
at org.primefaces.application.PrimeFacesPhaseListener$1.invokeContextCallback(PrimeFacesPhaseListener.java:251)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1253)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:672)
at org.primefaces.application.PrimeFacesPhaseListener.writeComponents(PrimeFacesPhaseListener.java:196)
at org.primefaces.application.PrimeFacesPhaseListener.handleAjaxRequest(PrimeFacesPhaseListener.java:94)
at org.primefaces.application.PrimeFacesPhaseListener.beforePhase(PrimeFacesPhaseListener.java:66)
Last edited by Oleg on 19 Mar 2010, 17:13, edited 1 time in total.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

19 Mar 2010, 13:01

Also this line in encodeScript is wrong and doesn't consider user defined pattern

Code: Select all

String valueAsString = getValueAsString(facesContext, calendar, "MM/dd/yyyy");
In encodeInputString it's right

Code: Select all

String valueAsString = getValueAsString(facesContext, calendar, calendar.getPattern());
By the way, to the exception above. For pagedata in the format MM/yyyy the two lines above hence are wrong yet because in german e.g. the month has second place. Depending on pattern I can say

Code: Select all

			String[] tokens = selectedDate.split(".");
			
			return tokens[1].trim() + "/" + tokens[2].trim();
or

Code: Select all

			String[] tokens = selectedDate.split("-");
			
			return tokens[0].trim() + "/" + tokens[2].trim();
and it will be true as well.

Actually you must convert String date to the Date date (attached converter or your embedded) and then format to your pattern "MM/dd/yyyy" and extract "MM/yyyy" ;)
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

19 Mar 2010, 17:13

This bug is not available in the SNAPSHOT! Nice calendar.

PrimeFaces is growing and we are growing together :-)
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 17987
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

22 Mar 2010, 02:16

Yes, Calendar is under maintenance in current snapshot, feel free to shout any new issues :)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider], Google [Bot] and 20 guests