Board index JavaServer Faces General Calendar min and maxdate

Calendar min and maxdate

Components, Ajax Framework, Utilities and More.

Post 06 Jul 2009, 13:12

Posts: 12
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!

Post 06 Jul 2009, 15:14

Posts: 15036
Location: Cybertron

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.

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


<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.
PrimeFaces Lead

Post 07 Jul 2009, 08:46

Posts: 12
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?

Post 07 Jul 2009, 10:32

Posts: 15036
Location: Cybertron

Hi, What do you mean by week of the year? Where should it display it? There's a navigator to jump between dates.
PrimeFaces Lead

Post 07 Jul 2009, 14:46

Posts: 12
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.

Post 07 Jul 2009, 15:36

Posts: 15036
Location: Cybertron

As far as I know, it's possible with the widget. So called show_week_header or so, need to look into it.
PrimeFaces Lead

Post 07 Jul 2009, 17:45

Posts: 12
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...

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


...and later on the page i tried...

<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.

Post 07 Jul 2009, 18:01

Posts: 15036
Location: Cybertron

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 ;

<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.
PrimeFaces Lead

Post 08 Jul 2009, 10:22

Posts: 12
Thats great, thanks. Is there a releasedate yet for the next version? And do you plan an attribute to show the week header too?

Post 08 Jul 2009, 10:43

Posts: 15036
Location: Cybertron

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.
PrimeFaces Lead

Next

Return to General