Introduction to Creating a Calendar Application

15-4 Web User Interface Developers Guide for Oracle Application Development Framework background, as shown in Figure 15–1 . You can customize how the activities are displayed by changing the color ramp. Each activity is associated with a provider, that is, an owner. If you implement your calendar so that it can display activities from more than one provider, you can also style those activities so that each provider’s activity shows in a different color, as shown in Figure 15–4 . Figure 15–4 Month View with Activities from Different Providers

15.2 Creating the Calendar

Before you can add a calendar component to a page, you must implement the logic required by the calendar in Java classes that extend ADF Faces calendar abstract classes. For an ADF Faces application, create the classes as managed beans. After you create the classes, you can add the calendar to a page. Before you implement your logic, it helps to have an understanding of the CalendarModel and CalendarActivity classes, as described in the following section.

15.2.1 Calendar Classes

The calendar component must be bound to an implementation of the CalendarModel class. The CalendarModel class contains the data for the calendar. Note: If your application uses the Fusion technology stack, implement the calendar classes using ADF Business Components. This will allow you to declaratively create and bind your calendar component. For more information, see the Using the ADF Faces Calendar Component section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. Creating a Calendar Application 15-5 This class is responsible for returning a collection of calendar activities, given the following set of parameters: ■ Provider ID: The owner of the activities. For example, you may implement the CalendarModel class such that the calendar can return just the activities associated with the owner currently in session, or it can also return other owners’ activities. ■ Time range: The expanse of time for which all activities that begin within that time should be returned. A date range for a calendar is inclusive for the start time and exclusive for the end time also known as half-open, meaning that it will return all activities that intersect that range, including those that start before the start time, but end after the start time and before the end time. A calendar activity represents an object on the calendar, and usually spans a certain period of time. The CalendarActivity class is an abstract class whose methods you can implement to return information about the specific activities. Activities can be recurring, have associated reminders, and be of a specific time type for example, hour or minute. Activities can also have start and end dates, a location, a title, and a tag. The CalendarProvider class represents the owner of an activity. A provider can be either enabled or disabled for a calendar.

15.2.2 How to Create a Calendar

Create your own implementations of the CalendarModel and CalendarActivity classes and implement the abstract methods to provide the logic. To create the calendar model classes: 1. Create a managed bean that will hold logic for the calendar. This bean must: ■ Extend the oracle.adf.view.rich.model.CalendarModel class. ■ Implement the abstract methods. For more information about the CalendarModel class, see the ADF Faces Javadoc . ■ Implement any other needed functionality for the calendar. For example, you might add logic that sets the time zone, as in the oracle.adfdemo.view.calendar.rich.model.DemoCalendarBean managed bean in the ADF Faces demo application for more information about the demo application, see Section 1.4, ADF Faces Demonstration Application . For more information about creating managed beans, see Section 2.6, Creating and Using Managed Beans. 2. Create a managed bean that will hold logic for the activities. This bean must: ■ Extend the oracle.adf.view.rich.model.CalendarActivity class. ■ Implement the abstract methods. ■ Implement any other required functionality for the calendar. As an example, see the oracle.adfdemo.view.calendar.rich.model. ■ DemoCalendarActivity managed bean in the ADF Faces demo application. 15-6 Web User Interface Developers Guide for Oracle Application Development Framework 3. Create a managed bean that will hold information and logic for providers. ■ Extend the oracle.adf.view.rich.model.CalendarProvider class. ■ Implement the abstract methods. ■ Implement any other required functionality for the provider. To create the calendar component: 1. In the Component Palette, from the Common Components section, drag a Calendar and drop it onto a JSF page. 2. Expand the Calendar Data section of the Property Inspector, and enter an EL expression for Value that resolves to the managed bean that extends the CalendarModel class.

15.3 Configuring the Calendar Component

Configure the many display attributes for the calendar, for example, the day that a week starts, and the time displayed at the beginning of a day.

15.3.1 How to Configure the Calendar Component

You configure the calendar using the Property Inspector. To configure a calendar: 1. With the calendar component selected, expand the Common section of the Property Inspector, and set the following: ■ View : Select the view either day, list, month, or week that should be the default when the calendar is displayed. Users change this value when they click the corresponding button in the calendar’s toolbar. ■ StartDayOfWeek : Enter the day of the week that should be shown as the starting day, at the very left in the monthly or weekly view. When not set, the default is based on the user’s locale. Valid values are: – sun – mon – tue Tip: If you want to style individual instances of an activity for example, if you want each provider’s activities to be displayed in a different color, then the getTags method must return a string that represents the activity instance. For more information, see Section 15.6.1, How to Style Activities. Tip: The calendar component can be stretched by any parent component that can stretch its children. If the calendar is a child component to a component that cannot be stretched, it will use a default width and height, which cannot be stretched by the user at runtime. However, you can override the default width and height using inline style attributes. For more information about the default height and width, see Section 15.3, Configuring the Calendar Component. For more information about stretching components, see Section 8.2.1, Geometry Management and Component Stretching. Creating a Calendar Application 15-7 – wed – thu – fri – sat ■ StartHour : Enter a number that represents the hour in 24 hour format, with 0 being midnight that should be displayed at the top of the day and week view. While the calendar when in day or week view starts the day at 12:01 a.m., the calendar will automatically scroll to the startHour value, so that it is displayed at the top of the view. The user can always scroll above that time to view activities that start before the startHour value. ■ ListType : Select how you want the list view to display activities. Valid values are: – day: Shows activities only for the active day. – dayCount: Shows a number of days including the active day and after, based on the value of the listCount attribute. – month: Shows all the activities for the month to which the active day belongs. – week: Shows all the activities for the week to which the active day belongs ■ ListCount : Enter the number of days’ activities to display used only when the listType attribute is set to dayCount. Figure 15–5 shows a calendar in list view with the listType set to dayCount and the listCount value set to 7. Figure 15–5 LIst View Using dayCount Type

2. Expand the Calendar Data section of the Property Inspector, and set the following:

■ ActiveDay : Set the day used to determine the date range that is displayed in the calendar. By default, the active day is today’s date for the user. Do not change this if you want today’s date to be the default active day when the calendar is first opened. Note that when the user selects another day, this becomes the value for the activeDay attribute. For example, when the user first accesses the calendar, the current date, February 6, 2009 is the active day. The month view will show February. If the user uses the next button to scroll to the next month, the active date will become March 6, 2009. ■ TimeZone : Set the time zone for the calendar. If not set, the value is taken from AdfFacesContext. The valid value is a java.util.TimeZone object.

3. Expand the Other section of the Property Inspector and set AvailableViews. The

value can be one of or a combination of the following: ■ month ■ week