Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2010, Red Hat, Inc. and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.richfaces.component;
 
 import java.util.Date;
 import java.util.List;
 
 import  javax.faces.application.FacesMessage;
 import  javax.faces.component.UIComponent;
 import  javax.faces.component.UIInput;
 import  javax.faces.component.UIViewRoot;
 import  javax.faces.component.visit.VisitCallback;
 import  javax.faces.component.visit.VisitContext;
 import  javax.faces.component.visit.VisitResult;
 import  javax.faces.context.FacesContext;
 import  javax.faces.convert.DateTimeConverter;
 import  javax.faces.event.AbortProcessingException;
 import  javax.faces.event.FacesEvent;
 
 import  org.richfaces.context.ExtendedVisitContext;
 import  org.richfaces.context.ExtendedVisitContextMode;
 import  org.richfaces.event.CurrentDateChangeEvent;
 import  org.richfaces.event.CurrentDateChangeListener;
 import  org.richfaces.log.Logger;
 import  org.richfaces.log.RichfacesLogger;
 import  org.richfaces.renderkit.MetaComponentRenderer;

The <rich:calendar> component allows the user to enter a date and time through an in-line or pop-up calendar. The pop-up calendar can navigate through months and years, and its look and feel can be highly customized.

Author(s):
amarkhel
 
 @JsfComponent(type = ., family = ., generate = "org.richfaces.component.UICalendar", renderer = @JsfRenderer(type = "org.richfaces.CalendarRenderer"), attributes = {
         "position-props.xml""popups-props.xml""events-popups-props.xml" }, tag = @Tag(name = "calendar", handler = "org.richfaces.view.facelets.CalendarHandler"))
 public abstract class AbstractCalendar extends UIInput implements MetaComponentResolver, MetaComponentEncoder {
     public static final String DAYSDATA_META_COMPONENT_ID = "daysData";
     public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
     public static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
     public static final String SUB_TIME_PATTERN = "\\s*[hHkKma]+[\\W&&\\S]+[hHkKma]+[\\W&&\\S]*[s]*\\s*";
     public static final String TIME_PATTERN = "HH:mm:ss";
     public static final String DEFAULT_DATE_PATTERN = "MMM d, yyyy";
     Logger log = RichfacesLogger.COMPONENTS.getLogger();
 
     protected enum PropertyKeys {
         locale
     }
 
     public enum Mode {
         client, ajax
     }

    
Used to format the date and time strings, according to ISO 8601 (for example, d/M/yy HH:mm a)
 
     @Attribute
     public abstract String getDatePattern();

    

Used for current date calculations

Default value is "getDefaultTimeZone()"

    @Attribute
    public abstract TimeZone getTimeZone();

    

Determines the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France. Possible values should be integers from 0 to 6, 0 corresponds to Sunday

Default value is "getDefaultFirstWeekDay()"

    @Attribute
    public abstract int getFirstWeekDay();

    

Gets what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, this method returns 1. If the minimal days required must be a full week, this method returns 7.

Default value is "getDefaultMinDaysInFirstWeek()"

    @Attribute
    public abstract int getMinDaysInFirstWeek();

    

This attribute defines the mode for "today" control. Possible values are "scroll", "select", "hidden"

Default value is "select"

    @Attribute
    public abstract String getTodayControlMode();

    

If false this bar should not be shown

Default value is "true"

    @Attribute(defaultValue = "true")
    public abstract boolean isShowWeekDaysBar();

    

If false this bar should not be shown

Default value is "true"

    @Attribute(defaultValue = "true")
    public abstract boolean isShowWeeksBar();

    

If false Calendar's footer should not be shown

Default value is "true"

    @Attribute(defaultValue = "true")
    public abstract boolean isShowFooter();

    

If false Calendar's header should not be shown

Default value is "true"

    @Attribute(defaultValue = "true")
    public abstract boolean isShowHeader();

    

"false" value for this attribute makes text field invisible. It works only if popupMode="true" If showInput is "true" - input field will be shown

Default value is "true"

    @Attribute(defaultValue = "true")
    public abstract boolean isShowInput();

    

If "true", the calendar will be rendered initially as hidden with additional elements for calling as popup

Default value is "true"

    @Attribute(defaultValue = "true")
    public abstract boolean isPopup();

    

If "true", rendered is disabled. In "popup" mode both controls are disabled

Default value is "false"

    @Attribute
    public abstract boolean isDisabled();

    

If "true" calendar input will be editable and it will be possible to change the date manually. If "false" the text field will be "read-only", so the value can be changed only from a handle.

Default value is "false"

    @Attribute
    public abstract boolean isEnableManualInput();

    

If "true". Date and time are not selectable. In "popup" mode input is disabled and button is enabled.

Default value is "false"

    @Attribute(defaultValue = "false")
    public abstract boolean isReadonly();

    

The javascript function that enables or disables a day cell

    @Attribute
    public abstract String getDayDisableFunction();

    

If false ApplyButton should not be shown

Default value is "false"

    @Attribute
    public abstract boolean isShowApplyButton();

    

If value is true then calendar should change time to defaultTime for newly-selected dates

Default value is "false"

    @Attribute
    public abstract boolean isResetTimeOnDateSelect();
    // ---------- position-props.xml
    @Attribute
    public abstract Positioning getJointPoint();
    @Attribute
    public abstract Positioning getDirection();
    @Attribute
    public abstract int getHorizontalOffset();
    @Attribute
    public abstract int getVerticalOffset();

    

This attribute is responsible for behaviour of dates from the previous and next months which are displayed in the current month. Valid values are "inactive" (Default) dates inactive and gray colored, "scroll" boundaries work as month scrolling controls, and "select" boundaries work in the same way as "scroll" but with the date clicked selection

Default value is "inactive"

    @Attribute
    public abstract String getBoundaryDatesMode();
    @Attribute
    public abstract int getZindex();

    

Valid values: ajax or client

Default value is "client"

    @Attribute
    public abstract Mode getMode();

    
The starting label can be set when in the initial view state. If the initial value is already set through the value attribute, this is displayed instead.
    @Attribute
    public abstract String getDefaultLabel();

    
CSS style(s) to be applied when this component is rendered
    @Attribute
    public abstract String getStyle();

    
Space-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup.
    @Attribute
    public abstract String getStyleClass();

    
CSS style(s) to be applied to the popup element
    @Attribute
    public abstract String getPopupStyle();

    
Space-separated list of CSS style class(es) to be applied to the popup element. This value must be passed through as the "class" attribute on generated markup.
    @Attribute
    public abstract String getPopupClass();

    
Attribute that allows to customize names of the months. Should accept list with the month names
    @Attribute
    public abstract Object getMonthLabels();

    
Attribute that allows to customize short names of the months. Should accept list with the month names
    @Attribute
    public abstract Object getMonthLabelsShort();

    
Attribute that allows to customize short names of the weekdays. Should accept list with the weekday's names.
    @Attribute
    public abstract Object getWeekDayLabelsShort();

    
List of the day names displays on the days bar in the following way "Sun, Mon, Tue, Wed,"
    @Attribute
    public abstract Object getWeekDayLabels();

    
The javascript function that determines the CSS style class for each day cell
    @Attribute
    public abstract String getDayClassFunction();

    
Position of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767.
    @Attribute
    public abstract String getTabindex();

    
CSS style(s) to be applied to the input element
    @Attribute
    public abstract String getInputStyle();

    
Space-separated list of CSS style class(es) to be applied to the button element. This value must be passed through as the "class" attribute on generated markup.
    @Attribute
    public abstract String getButtonClass();

    
Space-separated list of CSS style class(es) to be applied to the input element. This value must be passed through as the "class" attribute on generated markup.
    @Attribute
    public abstract String getInputClass();

    
Defines label for the popup button element. If the attribute is set "buttonIcon" and "buttonIconDisabled" are ignored
    @Attribute
    public abstract String getButtonLabel();

    
Defines the size of an input field. Similar to the "size" attribute of <h:inputText/>
    @Attribute
    public abstract String getInputSize();

    
Used to define the month and year which will be displayed
    @Attribute
    public abstract Object getCurrentDate();
    @Attribute
    public abstract void setCurrentDate(Object date);

    
Defines icon for the popup button element. The attribute is ignored if the "buttonLabel" is set
    @Attribute
    public abstract String getButtonIcon();

    
Defines disabled icon for the popup button element. The attribute is ignored if the "buttonLabel" is set
    @Attribute
    public abstract String getButtonDisabledIcon();

    

Defines time that will be used:

  1. to set time when the value is empty
  2. to set time when date changes and flag "resetTimeOnDateSelect" is true

Default value is "getDefaultValueOfDefaultTime()"

    @Attribute
    public abstract Object getDefaultTime();

    

Defines the last range of date which will be loaded to client from dataModel under rendering

Default value is "getDefaultPreloadEnd(getCurrentDateOrDefault())"

    @Attribute
    public abstract Object getPreloadDateRangeBegin();
    public abstract void setPreloadDateRangeBegin(Object date);

    

Define the initial range of date which will be loaded to client from dataModel under rendering

Default value is "getDefaultPreloadBegin(getCurrentDateOrDefault())"

    @Attribute
    public abstract Object getPreloadDateRangeEnd();
    public abstract void setPreloadDateRangeEnd(Object date);

    
Used to provide data for calendar elements. If data is not provided, all Data Model related functions are disabled
    @Attribute
    public abstract CalendarDataModel getDataModel();
    // ---------------- Input events

    
Javascript code executed when a pointer button is clicked over the input element.
    @Attribute(events = @EventName("inputclick"))
    public abstract String getOninputclick();

    
Javascript code executed when a pointer button is double clicked over the input element.
    @Attribute(events = @EventName("inputdblclick"))
    public abstract String getOninputdblclick();

    
Javascript code executed when the input field value is changed manually
    @Attribute(events = @EventName("inputchange"))
    public abstract String getOninputchange();

    
Javascript code executed called when the input field value is selected
    @Attribute(events = @EventName("inputselect"))
    public abstract String getOninputselect();

    
Javascript code executed when a pointer button is pressed down over the input element.
    @Attribute(events = @EventName("inputmousedown"))
    public abstract String getOninputmousedown();

    
Javascript code executed when a pointer button is moved within the input element.
    @Attribute(events = @EventName("inputmousemove"))
    public abstract String getOninputmousemove();

    
Javascript code executed when a pointer button is moved away from the input element.
    @Attribute(events = @EventName("inputmouseout"))
    public abstract String getOninputmouseout();

    
Javascript code executed when a pointer button is moved onto the input element.
    @Attribute(events = @EventName("inputmouseover"))
    public abstract String getOninputmouseover();

    
Javascript code executed when a pointer button is released over the input element.
    @Attribute(events = @EventName("inputmouseup"))
    public abstract String getOninputmouseup();

    
Javascript code executed when a key is pressed down over the input element.
    @Attribute(events = @EventName("inputkeydown"))
    public abstract String getOninputkeydown();

    
Javascript code executed when a key is pressed and released over the input element.
    @Attribute(events = @EventName("inputkeypress"))
    public abstract String getOninputkeypress();

    
Javascript code executed when a key is released over the input element.
    @Attribute(events = @EventName("inputkeyup"))
    public abstract String getOninputkeyup();

    
Javascript code executed when the input element receives focus.
    @Attribute(events = @EventName("inputfocus"))
    public abstract String getOninputfocus();

    
Javascript code executed when the input element loses focus.
    @Attribute(events = @EventName("inputblur"))
    public abstract String getOninputblur();
    // ---------------------

    
Javascript code executed when this element loses focus and its value has been modified since gaining focus.
    @Attribute(events = @EventName(value = "change", defaultEvent = true))
    public abstract String getOnchange();

    
The client-side script method to be called when some date cell is selected
    // -------------- Date select events
    @Attribute(events = @EventName("dateselect"))
    public abstract String getOndateselect();

    
The client-side script method to be called before some date cell is selected
    @Attribute(events = @EventName("beforedateselect"))
    public abstract String getOnbeforedateselect();

    
The client-side script method to be called when the current month or year is changed
    @Attribute(events = @EventName("currentdateselect"))
    public abstract String getOncurrentdateselect();

    
The client-side script method to be called before the current month or year is changed
    @Attribute(events = @EventName("beforecurrentdateselect"))
    public abstract String getOnbeforecurrentdateselect();
    // ----------------

    
The client-side script method to be called after the DOM is updated
    @Attribute(events = @EventName("complete"))
    public abstract String getOncomplete();
    @Attribute(events = @EventName("hide"))
    public abstract String getOnhide();

    
The client-side script method to be called when a pointer is moved away from the date cell
    @Attribute(events = @EventName("datemouseout"))
    public abstract String getOndatemouseout();

    
The client-side script method to be called when a pointer is moved onto the date cell
    @Attribute(events = @EventName("datemouseover"))
    public abstract String getOndatemouseover();
    @Attribute(events = @EventName("show"))
    public abstract String getOnshow();

    
The client-side script method to be called after time is selected
    @Attribute(events = @EventName("timeselect"))
    public abstract String getOntimeselect();

    
The client-side script method to be called before time is selected
    @Attribute(events = @EventName("beforetimeselect"))
    public abstract String getOnbeforetimeselect();

    
The client-side script method to be called before the component is cleaned
    @Attribute(events = @EventName("clean"))
    public abstract String getOnclean();

    

Used for locale definition

Default value is "getDefaultLocale()"

    @Attribute
    public Object getLocale() {
        Object locale = getStateHelper().eval(.);
        if (locale == null) {
            FacesContext facesContext = getFacesContext();
            UIViewRoot viewRoot = facesContext.getViewRoot();
            if (viewRoot != null) {
                locale = viewRoot.getLocale();
            }
        }
        return locale != null ? locale : .;
    }
    public void setLocale(Object locale) {
        getStateHelper().put(.locale);
    }
    @Override
    public void broadcast(FacesEvent eventthrows AbortProcessingException {
        if (event instanceof CurrentDateChangeEvent) {
            FacesContext facesContext = getFacesContext();
            CurrentDateChangeEvent currentDateChangeEvent = (CurrentDateChangeEvent) event;
            String currentDateString = currentDateChangeEvent.getCurrentDateString();
            try {
                // we should use datePattern attribute-based converter only for
                // selectedDate
                // current date string always has predefined format: m/y
                Date currentDate = CalendarHelper.getAsDate(facesContextthisgetCurrentDate());
                Date submittedCurrentDate = CalendarHelper.convertCurrentDate(currentDateStringfacesContextthis);
                currentDateChangeEvent.setCurrentDate(submittedCurrentDate);
                if (!submittedCurrentDate.equals(currentDate)) {
                    updateCurrentDate(facesContextsubmittedCurrentDate);
                }
            } catch (Exception e) {
                if (.isDebugEnabled()) {
                    .debug(" currentDate convertion fails with following exception: " + e.toString(), e);
                }
                setValid(false);
                String messageString = e.toString();
                FacesMessage message = new FacesMessage(messageString);
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                facesContext.addMessage(getClientId(facesContext), message);
                facesContext.renderResponse();
            }
        }
        super.broadcast(event);
    }
    public void updateCurrentDate(FacesContext facesContextObject currentDate) {
        if (facesContext == null) {
            throw new NullPointerException();
        }
        // RF-1073
        try {
            ValueExpression ve = getValueExpression("currentDate");
            if (ve != null) {
                ELContext elContext = facesContext.getELContext();
                if (ve.getType(elContext).equals(String.class)) {
                    DateTimeConverter convert = new DateTimeConverter();
                    convert.setLocale(CalendarHelper.getAsLocale(facesContextthisgetLocale()));
                    convert.setPattern(CalendarHelper.getDatePatternOrDefault(this));
                    ve.setValue(facesContext.getELContext(), convert.getAsString(facesContextthiscurrentDate));
                    return;
                } else if (ve.getType(elContext).equals(Calendar.class)) {
                    Calendar c = CalendarHelper.getCalendar(facesContextthis);
                    c.setTime((DatecurrentDate);
                    ve.setValue(elContextc);
                    return;
                } else {
                    ve.setValue(elContextcurrentDate);
                    return;
                }
            } else {
                setCurrentDate(currentDate);
            }
        } catch (Exception e) {
            setValid(false);
            if (.isDebugEnabled()) {
                .debug(" updateCurrentDate method throws exception: " + e.toString(), e);
            }
            String messageString = e.toString();
            FacesMessage message = new FacesMessage(messageString);
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            facesContext.addMessage(getClientId(facesContext), message);
        }
    }
    public void addCurrentDateChangeListener(CurrentDateChangeListener listener) {
        addFacesListener(listener);
    }
    public void removeCurrentDateChangeListener(CurrentDateChangeListener listener) {
        removeFacesListener(listener);
    }
    public CurrentDateChangeListener[] getCurrentDateChangeListeners() {
        return (CurrentDateChangeListener[]) getFacesListeners(CurrentDateChangeListener.class);
    }
    public static Object getDefaultValueOfDefaultTime(FacesContext facesContextAbstractCalendar calendarComponent) {
        if (calendarComponent == null) {
            return null;
        }
        Calendar calendar = CalendarHelper.getCalendar(facesContextcalendarComponent);
        calendar.set(., 12);
        calendar.set(., 0);
        calendar.set(., 0);
        return calendar.getTime();
    }
    protected Date getDefaultPreloadBegin(Date date) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Calendar calendar = Calendar.getInstance(CalendarHelper.getTimeZoneOrDefault(this),
                CalendarHelper.getAsLocale(facesContextthisgetLocale()));
        calendar.setTime(date);
        calendar.set(.calendar.getActualMinimum(.));
        return calendar.getTime();
    }
    protected Date getDefaultPreloadEnd(Date date) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Calendar calendar = Calendar.getInstance(CalendarHelper.getTimeZoneOrDefault(this),
                CalendarHelper.getAsLocale(facesContextthisgetLocale()));
        calendar.setTime(date);
        calendar.set(.calendar.getActualMaximum(.));
        /*
         * //force recalculation calendar.getTimeInMillis(); calendar.set(Calendar.DAY_OF_WEEK, getLastDayOfWeek(calendar));
         */
        return calendar.getTime();
    }
    public Date getCurrentDateOrDefault() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Date date = CalendarHelper.getAsDate(facesContextthisgetCurrentDate());
        if (date != null) {
            return date;
        } else {
            Date value = CalendarHelper.getAsDate(facesContextthisthis.getValue());
            if (value != null) {
                return value;
            } else {
                return java.util.Calendar.getInstance(CalendarHelper.getTimeZoneOrDefault(this)).getTime();
            }
        }
    }
    public String resolveClientId(FacesContext facesContext, UIComponent contextComponentString metaComponentId) {
        if (.equals(metaComponentId)) {
            return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
        }
        return null;
    }
    public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent contextComponentString metaComponentId) {
        return null;
    }
    @Override
    public boolean visitTree(VisitContext context, VisitCallback callback) {
        if (!isVisitable(context)) {
            return false;
        }
        FacesContext facesContext = context.getFacesContext();
        pushComponentToEL(facesContextnull);
        try {
            VisitResult result = context.invokeVisitCallback(thiscallback);
            if (result == VisitResult.COMPLETE) {
                return true;
            }
            if (result == VisitResult.ACCEPT) {
                if (context instanceof ExtendedVisitContext) {
                    ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) context;
                    if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER) {
                        result = extendedVisitContext.invokeMetaComponentVisitCallback(thiscallback,
                                );
                        if (result == VisitResult.COMPLETE) {
                            return true;
                        }
                    }
                }
            }
            if (result == VisitResult.ACCEPT) {
                Iterator<UIComponent> kids = this.getFacetsAndChildren();
                while (kids.hasNext()) {
                    boolean done = kids.next().visitTree(contextcallback);
                    if (done) {
                        return true;
                    }
                }
            }
        } finally {
            popComponentFromEL(facesContext);
        }
        return false;
    }
    public void encodeMetaComponent(FacesContext contextString metaComponentIdthrows IOException {
        ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(contextthismetaComponentId);
    }
    public Object getPreload() {
        Date[] preloadDateRange = getPreloadDateRange();
        if (preloadDateRange != null && preloadDateRange.length != 0) {
            CalendarDataModel calendarDataModel = (CalendarDataModelgetDataModel();
            if (calendarDataModel != null) {
                CalendarDataModelItem[] calendarDataModelItems = calendarDataModel.getData(preloadDateRange);
                HashMap<StringObjectargs = new HashMap<StringObject>();
                args.put("startDate"formatStartDate(preloadDateRange[0]));
                args.put("days"deleteEmptyPropeties(calendarDataModelItems));
                return args;
            }
        }
        return null;
    }
    public static Object formatStartDate(Date date) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        AbstractCalendar calendarInstance = (AbstractCalendar) AbstractCalendar.getCurrentComponent(facesContext);
        Calendar calendar = CalendarHelper.getCalendar(facesContextcalendarInstance);
        calendar.setTime(date);
        HashMap<StringObjecthashDate = new HashMap<StringObject>();
        hashDate.put("month"calendar.get(.));
        hashDate.put("year"calendar.get(.));
        return hashDate;
    }
    public ArrayList<ObjectdeleteEmptyPropeties(CalendarDataModelItem[] calendarDataModelItems) {
        ArrayList<ObjecthashItems = new ArrayList<Object>();
        for (CalendarDataModelItem item : calendarDataModelItems) {
            HashMap<StringObjectitemPropertiesMap = new HashMap<StringObject>();
            if (null != item) {
                if (!item.isEnabled()) {
                    itemPropertiesMap.put("enabled"item.isEnabled());
                }
                if (null != item.getStyleClass() && !item.getStyleClass().equalsIgnoreCase("")) {
                    itemPropertiesMap.put("styleClass"item.getStyleClass());
                }
            }
            hashItems.add(itemPropertiesMap);
        }
        return hashItems;
    }
    public Date[] getPreloadDateRange() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Date dateRangeBegin = null;
        Date dateRangeEnd = null;
        Mode mode = getMode();
        if (mode == null) {
            mode = .;
        }
        if (..equals(mode)) {
            dateRangeBegin = CalendarHelper.getAsDate(facesContextthis,
                    getDefaultPreloadBegin((DategetCurrentDateOrDefault()));
            dateRangeEnd = CalendarHelper.getAsDate(facesContextthisgetDefaultPreloadEnd((DategetCurrentDateOrDefault()));
        } else {
            Object date = getPreloadDateRangeBegin();
            if (date == null) {
                date = getDefaultPreloadBegin(getCurrentDateOrDefault());
            }
            dateRangeBegin = CalendarHelper.getAsDate(facesContextthisdate);
            date = getPreloadDateRangeEnd();
            if (date == null) {
                date = getDefaultPreloadEnd(getCurrentDateOrDefault());
            }
            dateRangeEnd = CalendarHelper.getAsDate(facesContextthisdate);
        }
        if (dateRangeBegin == null && dateRangeEnd == null) {
            return null;
        } else {
            if (dateRangeBegin.after(dateRangeEnd)) {
                // XXX add message
                FacesMessage message = new FacesMessage("preloadDateRangeBegin is greater than preloadDateRangeEnd");
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                facesContext.addMessage(getClientId(facesContext), message);
                throw new IllegalArgumentException();
            }
            List<Datedates = new ArrayList<Date>();
            Calendar calendar = Calendar.getInstance(CalendarHelper.getTimeZoneOrDefault(this),
                    CalendarHelper.getAsLocale(facesContextthisthis.getLocale()));
            Calendar calendar2 = (Calendarcalendar.clone();
            calendar.setTime(dateRangeBegin);
            calendar2.setTime(dateRangeEnd);
            do {
                dates.add(calendar.getTime());
                calendar.add(., 1);
            } while (!calendar.after(calendar2));
            return (Date[]) dates.toArray(new Date[dates.size()]);
        }
    }
New to GrepCode? Check out our FAQ X