UltraLightClient Code Community
[ start | index | login ]
Overview > Date Chooser

Date Chooser

Belongs to following categories: Extension, ULC5.2, ULC6.1,

Project Home
Downloads

ULCDateChooser

Purpose

Simple date picker widget (ULCDateChooser) to browse the calendar and select a date. The date is picked through an event listener. NEW: Available for ULC version 6.1

Features

  • Realized as extension. The main advantage is that there is no server round-trip for each interaction with the widget, such as month navigation, label updates, subpanel refresh, etc. All needed information can be retrieved on the client.
  • Localized. The local default is the client local, but the localization, as well as the cancel button caption, can be customized through the constructor. The localization considers not only the language, but also "cultural" (...) differences (for some people communities the week begins on Monday, for some others on Sunday...).
  • Date selection catch through a listener (IDateSelectedListener). The list of listeners is notified as soon as a new date has been selected from the widget.
  • A state is kept with the last selected date. This means that the widget can be queried at any time to get the last selected date.
  • Preview of the exact selected date on the month navigation panel (this can be switched off).
  • Some customization elements, like element dimensions, colors, and others (see the get/set API methods).
  • Opportunity to specify lower and upper bounds, using the API methods "ULCDateChooser.setFromDate(...)" and "ULCDateChooser.setToDate(...)".
datechooser

How to use it

A sample usage of the ULCDateChooser extension is provided in com.canoo.ulc.community.datechooser.application.ULCDateChooserSample.

A ULCDateChooser is simply a button. When clicked a dialog box is opened and the user can select a date. When a date is selected a list of previously subscribed IDateSelectedListener elements is notified.

...

ULCDateChooser dateChooser = new ULCDateChooser();

dateChooser.addDateSelectedListener(new IDateSelectedListener() {

public void dateChosen(DateSelectedEvent event) { System.out.println("selection performed...." + event.getDate()); } });

...

How it is implemented

ULCDateChooser is implemented as extension, based on the class DateChooser. It is basically a button that opens a modal dialog. Listeners of type IDateSelectedListener can be added to ULCDateChooser. When a new date has been selected the listeners are notified through the call of the method dateChosen(). From the received DateSelectedEvent element, you get access to the selected date.

Graphic parameters are managed within a separate object (GraphicMemento). This object is managed and changed directly by DateChooser, but its internal values are needed by PickDatePanel, the class implementing the dialog.

Compatibility

Functionality and graphic tested on jdk 1.3.3, jdk 1.4.2_03, ULC 5.2, ULC 6.1 (adapted version).

Version for ULC 6.1

In order to continue using the date chooser extension with from ULC 6.1 you need to follow one of the following options:
  • Just recompile the old date chooser code under 6.1. The date chooser will further run as before.
  • Download the new date chooser version adapted for ULC 6.1 taking care that, because of the new extension framework available under 6.1, the name of the event class has been renamed from "DateEvent" to "DateSelectedEvent".

Project Links

Project Home
Downloads

Author

>>sandro

one comment (by stephane) | post comment
labels
Category:Extension
Category:ULC6.1
Category:ULC5.2
attachments
Created by sandro. Last edited by daniel, 318 days ago. Viewed 11,141 times. #53
[diff] [history] [edit] [rdf]

Icon-Comment stephane, one year and 216 days ago. Icon-Permalink

There is a major bug in the code for country (like France) where the first day if the week is Monday: When the 1st day of the month is Sunday, the calendar in incorrect.

In order to correct that look for the line : int nrOfEmptyField = Math.abs(dayOfWeek - firstDayOfWeek);

and change by : if (dayOfWeek < firstDayOfWeek) { nrOfEmptyField = dayOfWeek - firstDayOfWeek + 7; } else { nrOfEmptyField = dayOfWeek - firstDayOfWeek; }

Stephane

Name
Email:
snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt