Calendar View

Hello,

I am trying to work with DateField component to display calendar.

I need to view a whole month Calendar and user can be able to view Month only calendar…like in car Reservation example

How can i do this?

thanks for responses

Hi,

You can set the resolution for the DateField using dateField.setResolution(int). DateField.RESOLUTION_MONTH enables selection of month+year only, DateField.RESOLUTION_DAY enables selection of day+month+year.

yourField.setResolution(RESOLUTION_DAY)
yourField.setStyleName(TYPE_INLINE)

For more, seethe DateField API-docs: http://toolkit.itmill.com/demo/doc/api/com/itmill/toolkit/ui/DateField.html

yourField.setResolution(RESOLUTION_DAY)
yourField.setStyleName(TYPE_INLINE)

this creates only a datefield

TYPE_INLINE is not a valid method i tried it

user has to see only a month calendar and then able to browse months only

so i tried
df.setResolution(RESOLUTION_DAY);
df.setStyleName(TYPE_IN);

does not work if i change to df.setStyleName(“TYPE_IN”); nothing still

i just want to be able to see the whole moth view and not DateField view where calendar object is display like a popup window

thnx

[quote=Anonymous]
TYPE_INLINE is not a valid method i tried it
[/quote]You’re right, the above example code isn’t completely correct.

The following will do the thing you want:

DateField calendar = new DateField();
calendar.setResolution(DateField.RESOLUTION_DAY);
calendar.setStyleName(DateField.TYPE_INLINE);

Best regards,
-Jouni

ps.

For everyone posting code snippets here on the forums, please try to paste working code only, i.e. no pseudo-code (unless you specifically say you’re showing pseudo-code, of course). That way no one has to try and guess what has to be added/removed in order to make something work. Thanks in advance.

hey


DateField calendar = new DateField();
 calendar.setResolution(DateField.RESOLUTION_DAY);
 calendar.setStyleName(DateField.TYPE_INLINE);

hey i get an error on

 calendar.setStyleName(DateField.TYPE_INLINE);

i was working with version 5.2.5 it does not work

then i thought may be the version is already outdate…but i tried version 5.2.10 and 5.2.11 it seems to be same problem

but in the documentation it reads this method has been existing

Since:
3.0
Version:
5.2.10
Author:
IT Mill Ltd.

this is the first time i am working with this DateField, may be you can test it to be sure…coz for it is not working

thnx

Hi,

Actually, “inline” is a
type
, not a
style
; do:

DateField df = new InlineDateField();

(TYPE_* are protected, only to be set by subclasses, such as InlineDateField)

Best Regards,
Marc

[quote=Marc Englund]
Actually, “inline” is a
type
, not a
style
; do:

DateField df = new InlineDateField(); (TYPE_* are protected, only to be set by subclasses, such as InlineDateField)
[/quote]Ah, blasted, I did it again! Sorry for the previous inaccurate code example.

[quote=Jouni Koivuviita]
For everyone posting code snippets here on the forums, please try to paste working code only, i.e. no pseudo-code (unless you specifically say you’re showing pseudo-code, of course). That way no one has to try and guess what has to be added/removed in order to make something work. Thanks in advance.
[/quote]Now that makes me sound like a total jackass, I know :slight_smile:

Next time I’ll take my own advice. That’s a promise.

Thakx a lot now working perfectly ready to move on…

hello,

I am trying to parse the date which is from DateField event… i am doing it like following:

DateField dateField = new InlineDateField();
dateField.setResolution( DateField.RESOLUTION_DAY);
dateField.setImmediate(true);
dateField.addListener(this);

then i get the date which has been clicked by using method getProperty and it gives me the date clicked.

i have one problem, which is how to parse the date from dateField the format of the field is like below:
Wed Feb 25 14:23:51 EET 2009

when i try to parse the date i get the error:
Unparseable date: “Thu Feb 26 14:23:51 EET 2009”
Unparseable date: “Thu Feb 26 14:23:51 EET 2009”
null
class java.text.ParseException

to parse the date i am doing it like this:


SimpleDateFormat df=new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy" );
date=df.parse( ""+event.getProperty().toString() );

can someone help me or tell me what i am doing wrong…i think for some reason the error is thrown from SimpleDateFormatter…why??

help
thanks

DateField.getValue() returns a Date, so you don’t have to parse anything. Try something like this instead:

date=(Date)event.getProperty().getValue();

Best Regards,
Marc

hey

can someone please post for a link for the Reservation demo source code…

i can’t seem to find them

sorry :shock:

Hi,

You can find sources to Reservr demo online here: http://toolkit.itmill.com/demo/doc/example-source/com/itmill/toolkit/demo/reservation/

Thanks