XPages Calendar Control In A Table

In my last blog entry I showed how it was
possible to build a calendar using a couple of repeat controls and some
CSS but in reality a calendar is more suited to be displayed as a table.
By using a table your calendar will also degrade nicely in older web browsers
so I decided to give it a shot and see if it was possible to do in XPages.

The basic concept is still the same.
I need to know how many days there are in the month and I need to know
what day to start the first calendar entry on. Because I’m using a table
I will also need to complete the last row of table columns with blank entries
so this means I will need another repeat control.

In the CSS version of the calendar I
assigned the first day of each week a slightly different style so that
it would ensure that the row would move down. In a table I will need to
close a table row tag and open a new one. At first I tried to just add
a </xp:tr> and a <xp:tr> tag into the main repeat and set their
‘rendered’ value so that they would only render on the first day of each
week but Domino Designer would not allow me to do this because you cannot
add a ‘rendered’ value to a closing tag, only the opening tag.

To get around this I decided to just
fool the xpages rendering engine to output the closing and reopening table
row tags by using a computed field that is set to send it’s results to
the web browser as html.

A picture named M2

This worked perfectly, before the repeat
control outputs the first table column of the week and closing tag for
the previous table row and then an opening tag for the next table row is
sent to the browser.

The last thing I needed to do was add
an extra repeat to fill out the blank table columns at the end of the last
row and then I needed to close the final table row before closing the entire
table. The maximum number of rows that a calendar might take is 6, this
means that your calendar table must have at least 42 table columns split
over the 6 rows. You already know the number of blanks at the start of
the table and the number of days in the month so subtracting these from
42 will give you the number of blanks at the end of the table.

Of course it’s entirely possible for
a calendar month to only need 4 rows, as was the case in February this
year where the first of the month was a Sunday and the 28th of the month
was a Saturday so we need to check the result of our calculation to remove
any blank rows by subtracting either 14 or 7 as necessary.

A picture named M3

Now we just need to apply a little CSS
just for the table and we have a working calendar control in XPages based
on a table.

A picture named M4

Advertisements
Tagged with: ,
Posted in None
4 comments on “XPages Calendar Control In A Table
  1. Thomas Gumz says:

    Hi Declan,to output tables, you might want to consider using the DataTable control, rather than the Repeat Control, since the DataTables main output method ARE table rows and columns.Note: Before you can drag controls into the DT, you first need to add some columns to it (right mouseclick on it…)

    Like

  2. Declan Lynch says:

    For the purpose of a dynamic calendar I can’t seems to see how to use the DataTable for this.The first of the month isn’t always in the first column of the first row.Unless I’m overlooking something very easy I just can;t seem to see a way to do it with a DataTable. If you already have a working solution I’d love to see it.

    Like

  3. Jerry Shelley says:

    Sorry – off-topic alert …I’m just loving your XPages wisdom, Declan, but I’m struggling with your site. Is there anywhere I can search your blog entries please? And/or perhaps you could provide a Tag cloud or a categories list? The “Table of Contents” link only lists the astonishing “learning Xpages” saga, and not your newer stuff such as this Calendar item.Thanks anyway for your totally priceless sharing of knowledge. Jerry.

    Like

  4. Sjaak Ee says:

    Hi Declan,

    I discovered that when xpages are not accessed for ca. 20 minutes on the Domino server it takes 5 to 10 seconds before xpages is started up again. I discovered that more people are suffering with this annoying thing. Is there any advice on this subject. For example recommended settings in config files, etc.

    Like

Comments are closed.

Archives
%d bloggers like this: