Some time ago I published an article at jroller in order to show how the rich:calendar performance can be improved by using single component instance for all the date inputs on the form. Today I want to use the same workaround to solve another popular problem.

Looking through the community forum I see that many people are having issues related to extended/scrollable tables and embedded components with absolute positioning. These components can be cutoff by the tables borders. Unfortunately it's too late for markup redesign for tables components in 3.3.x because only stabilization works planned for the branch.

In this entry I want to highlight that for the rich:calendar component you can use the solution described in original article to make it work when embedded in tables. I'll also add small update for the article code sample in order to make it works with the latest RichFaces 3.3.3.

Lets check this simple table definition:

	value="#{dataBean.simpleList}" var="list"
	width="300px" height="400px"
		<f:facet name="header">
			<h:outputText value="row number" />
		<h:outputText value="#{rowKey}" />
		<f:facet name="header">
			<h:outputText value="calendar" />
	<rich:calendar />

It will produce the following problematic result:

Now lets move rich:calendar component outside the table and replace it in column with simple input and icon which activates it using api:

Calendar definition (outside the table)
<a4j:loadScript src="/scripts/calendarUtils.js"></a4j:loadScript>

<rich:calendar id="calendar" 
onchanged="#{rich:component('calendar')};" zindex="1000"/>

definition of date columns
	<f:facet name="header">
		<h:outputText value="calendar" />
	<h:inputText value="#{}" id="input2" readonly="true"
	onclick="#{rich:component('calendar')}.customExpand(event, #{rich:element('input2')}, #{rich:element('button2')});" />
	onclick="#{rich:component('calendar')}.customExpand(event, #{rich:element('input2')}, #{rich:element('button2')});"
	id="button2" />

This definitions and calendarUtils.js code is explained in detail in the jroller post. The only thing we need to correct is the script for our calendar initialization. The following lines should be added just after the customExpand function declaration in calendarUtils.js:

function customExpand(e,input,button) {
	 if (!this.isRendered) {
		 this.isRendered = true;

	 ///the rest part fully the same as in original article

This change needed because lazy initialization implemented in calendar in 3.3.3 and without calling render method on the first time calendar call will produce empty calendar to be shown.

And here is expected result for extendedDataTable:

It should became the same used with scrollableDataTable.

Back to top