Page 1 of 2

Calendar min and maxdate

Posted: 06 Jul 2009, 13:12
by bumblebee
Hi everyone,

i have some issues using the calendar component of PrimeFaces. I would like to use it as a 12 month overview of the year. For this i used the page attribute set to "12" and the mode set to "inline". Problem now, the calendar starts with the current date. I thought i can use the attribute mindate to manipulate but i had no success. My first question is, is it possible to use mindate to set the current calendar view to another month and second question how? In the tld mindate and maxdate are bind to java.lang.Object. Why not java.util.Date or java.lang.String?

Thanks in advance!

Re: Calendar min and maxdate

Posted: 06 Jul 2009, 15:14
by cagatay.civici
Hi, underlying widget supports what you need but the calendar component doesn't yet. The key is the pagedate feature which is not given an attribute yet.
For now as a quick workaround you can use the widgetVar extension.

Code: Select all

<p:calendar widgetVar="mycal" .../>

Code: Select all

<script type="text/javascript">
myCalendar.cfg.setProperty("pagedate","01/2009",false); 
</script>
This should start displaying calendar from january.

I've added an issue to add this attribute, it'll be shipped with 0.9.1.

Re: Calendar min and maxdate

Posted: 07 Jul 2009, 08:46
by bumblebee
Hey, thanks for your fast reply. I will try this. Another question is left. I miss the week of the year in the calendar. I think it's not implemented in the underlying widget neither. Do you plan to add the week numbers at the calendar?

Re: Calendar min and maxdate

Posted: 07 Jul 2009, 10:32
by cagatay.civici
Hi, What do you mean by week of the year? Where should it display it? There's a navigator to jump between dates.

Re: Calendar min and maxdate

Posted: 07 Jul 2009, 14:46
by bumblebee
Hey, i mean the numbers of the weeks. The year is divided into 52 weeks. There could be a column infront of the day view. For every row you would see a correspondent week number. Starting in january with the first week. This is, what i'm looking for.

Re: Calendar min and maxdate

Posted: 07 Jul 2009, 15:36
by cagatay.civici
As far as I know, it's possible with the widget. So called show_week_header or so, need to look into it.

Re: Calendar min and maxdate

Posted: 07 Jul 2009, 17:45
by bumblebee
Yes, you're right. There is a property called 'show_week_header'. It works fine. Thanks.

But I paste the whole JavaScript code of the yui calendar to the page, because i did not get the widgetVar attribute to work. I'm not sure where to find the solution now. I used your example like this...

Code: Select all

<p:calendar widgetVar="yahoo_calendar" ... />
...and later on the page i tried...

Code: Select all

<script type="text/javascript">
  yahoo_calendar.cfg.setProperty("pagedate", "01/2009", false);
  yahoo_calendar.cfg.setProperty("show_week_header", true);
</script>
This did not work for me. I use a facelet composition containing the PrimeFaces calendar followed by the JavaScript Tag. I debuged the site and recognized, that the JavaScript which should configure the jui calendar is called before the calendar is initialized from the PrimeFaces Tag. Maybe facelets runs first JavaScripts and after that the JSF tags will be handled. Actually this is exhausting me... Maybe you have a suggestion.

Re: Calendar min and maxdate

Posted: 07 Jul 2009, 18:01
by cagatay.civici
I guess you need to attach your javascript after document is loaded, this will guarantee variable "yahoo_calendar" to exist. Simplest way to do is ;

Code: Select all

<body onload=" yahoo_calendar.cfg.setProperty("pagedate", "01/2009", false);yahoo_calendar.cfg.setProperty("show_week_header", true);">
By the way I'll add this attribute to 0.9.1 release.

Re: Calendar min and maxdate

Posted: 08 Jul 2009, 10:22
by bumblebee
Thats great, thanks. Is there a releasedate yet for the next version? And do you plan an attribute to show the week header too?

Re: Calendar min and maxdate

Posted: 08 Jul 2009, 10:43
by cagatay.civici
Yes, next version is planned to be released in end of july. After the holiday period:) show_week_header and show_week_footer will be added for sure regarding your feedback.