# Class: Calendar

## RichFaces.ui. Calendar

#### new Calendar(componentId, locale, options, markups)

Backing object for rich:calendar

##### Parameters:

Name | Type | Description
--- | --- | ---
`componentId` | string | component id
`locale` | string | calendar locale
`options` | string |
`markups` |  |

Source:
  - calendar.js, line 455

### Extends

- RichFaces.BaseComponent

### Members

#### name :string

Component name.

##### Type:

- string

Inherited From:
  - RichFaces.BaseComponent#name
Source:
  - richfaces-base-component.js, line 195

### Methods

#### attachToDom(source) → {DOMElement}

Attach component object to DOM element by component id, DOM element or jQuery object and returns the element Its required for the client side API calls and to clean up after ajax request or document unload by calling destroy method

##### Parameters:

Name | Type | Description
--- | --- | ---
`source` | string | DOMElement | jQuery | component id, DOM element or DOM elements wrapped by jQuery

Inherited From:
  - RichFaces.BaseComponent#attachToDom
Source:
  - richfaces-base-component.js, line 237

##### Returns:

Type
  DOMElement

#### destroy()

Destroy method. Will be called before remove component from the page

Inherited From:
  - RichFaces.BaseComponent#destroy
Source:
  - richfaces-base-component.js, line 313

#### detach(source)

Detach component object from DOM element by component id, DOM element or jQuery object

##### Parameters:

Name | Type | Description
--- | --- | ---
`source` | string | DOMElement | jQuery | component id, DOM element or DOM elements wrapped by jQuery

Inherited From:
  - RichFaces.BaseComponent#detach
Source:
  - richfaces-base-component.js, line 258

#### focus()

Focus the input element

Source:
  - calendar.js, line 1189

#### getCurrentMonth() → {int}

Get the number of the current month

Source:
  - calendar.js, line 1230

##### Returns:

number of current month, 0-based

Type
  int

#### getCurrentYear() → {int}

Get the current year

Source:
  - calendar.js, line 1220

##### Returns:

current year

Type
  int

#### getEventElement() → {string}

Method returns element's id for event handlers binding. Event API calls this method when binding by component object as selector was used.

Inherited From:
  - RichFaces.BaseComponent#getEventElement
Source:
  - richfaces-base-component.js, line 224

##### Returns:

Type
  string

#### getValue() → {date}

Get the current date value

Source:
  - calendar.js, line 2083

##### Returns:

current date value

Type
  date

#### getValueAsString(patternopt) → {string}

Get the current date value as string, formatted by the given pattern

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`pattern` | string | <optional> | date pattern

Source:
  - calendar.js, line 2094

##### Returns:

current value

Type
  string

#### hideDateEditor()

Hide the date editor popup

Source:
  - calendar.js, line 2067

#### hidePopup()

Hide the popup

Source:
  - calendar.js, line 1069

#### hideTimeEditor()

Hide the time editor popup

Source:
  - calendar.js, line 2005

#### invokeEvent(eventType, element, event, data) → {boolean}

Invokes event on on the DOM element

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventType` | string | event type, e.g. "click"
`element` | DOMElement | DOM element object
`event` | Event | jQuery Event
`data` | Object | additional data used for event handler

Inherited From:
  - RichFaces.BaseComponent#invokeEvent
Source:
  - richfaces-base-component.js, line 272

##### Returns:

true if an event is successfully invoked

Type
  boolean

#### resetValue()

Clear the current date value

Source:
  - calendar.js, line 2117

#### showDateEditor()

Show the date editor popup

Source:
  - calendar.js, line 2039

#### showPopup()

Show the popup

Source:
  - calendar.js, line 1096

#### showSelectedDate()

Show the month containing the selected date

Source:
  - calendar.js, line 1917

#### showTimeEditor()

Show the time editor popup

Source:
  - calendar.js, line 1966

#### switchPopup()

Switch the state of the popup

Source:
  - calendar.js, line 1150

#### today()

Select today's date

Source:
  - calendar.js, line 1687

#### toString() → {string}

Method for converting object to string

Inherited From:
  - RichFaces.BaseComponent#toString
Source:
  - richfaces-base-component.js, line 203

##### Returns:

Type
  string