arya-blue
luna-amber
luna-blue
luna-green
luna-pink
nova-dark
nova-light
saga-blue
vela-blue
Sheet
Create columns dynamically and render their style and other attributes from backing beans. Also demonstrate how to customize the Handsontable instance using "updateSettings" and "extender" Javascript.
Dynamic Columns
Source

<pe:sheet id="sheet" value="#{sheetDynamicController.sheetRows}" var="row" height="400" rowKey="#{row.id}"
              showRowHeaders="true" sortBy="#{row.id}" sortOrder="ascending" width="1000"
              widgetVar="sheetWidget" filteredValue="#{sheetDynamicController.filteredSheetRows}"
              extender="sheetExtender">

        <f:facet name="header">
            <h:outputText value="Dynamic Columns"/>
        </f:facet>

        <pe:sheetcolumn headerText="Id (readOnly)" readOnly="true" value="#{row.id}" colWidth="150"/>
        <c:forEach items="#{sheetDynamicController.hoursOfDay}" var="hourOfDay" varStatus="status">
            <pe:sheetcolumn styleClass="htRight #{row.cells[status.index].style}"
                            headerText="#{hourOfDay}"
                            value="#{row.cells[status.index].value}"
                            readonlyCell="#{row.readOnly}"
                            colType="numeric">
                <f:converter converterId="jakarta.faces.Integer"/>
            </pe:sheetcolumn>
        </c:forEach>

        <f:facet name="footer">
            <h:outputText value="#{sheetDynamicController.filteredSheetRows.size()} Records"/>
        </f:facet>
    </pe:sheet>

    <style type="text/css">
        .cell-blue {
            color: blue
        }

        .cell-orange {
            color: darkorange
        }
    </style>
    <script type="text/javascript">
        function sheetExtender() {
            // this = widget
            // this.cfg = JSON configuration
            this.cfg.trimWhitespace = true;
        };

        $(document).ready(function () {
            var $hot = PF('sheetWidget').ht;
            $hot.updateSettings({
                contextMenu: {
                    callback: function (key, options) {
                        if (key === 'about') {
                            setTimeout(function () {
                                // timeout is used to make sure the menu collapsed before alert is shown
                                alert("PrimeFaces Extensions Rocks! This is a context menu with default and custom options mixed");
                            }, 100);
                        }
                    },
                    items: {
                        "row_above": {
                            disabled: function () {
                                // if first row, disable this option
                                return $hot.getSelected()[0] === 0;
                            }
                        },
                        "row_below": {},
                        "hsep1": "---------",
                        "remove_row": {
                            name: 'Remove this row, ok?',
                            disabled: function () {
                                // if first row, disable this option
                                return $hot.getSelected()[0] === 0
                            }
                        },
                        "hsep2": "---------",
                        "about": {name: 'About...'}
                    }
                }
            });
        });
    </script>
            
Components and more
Documentation
Attributes (move mouse over the names to see data types)
Name Description
activeHeaderStyleClassActive header style class.
allowTabOffSheetAllow tab off sheet.Default is false.
bindingAn EL expression referring to a server side UIComponent instance in a backing bean.Default is generated.
caseSensitiveSortCase sensitive sort.Default is false.
commentedCellStyleClassCommented cell style class.
converterEL expression resolves to a converter instance or literal converter ID defining a component converter.
converterMessage
currentColStyleClassCurrent column style class.
currentHeaderStyleClassCurrent header style class.
currentRowStyleClassCurrent row style class.
currentSortByID of column currently used for sorting (internal).
emptyMessageMessage when no records.
errorMessageGlobal error message when sheet is in error.
extenderJavaScript function to extend Handsontable options.
filteredValueFiltered and sorted list of values.
fixedColsNumber of fixed columns when scrolling.
fixedRowsNumber of fixed rows when scrolling.
fixedRowsBottomNumber of fixed rows at bottom.
heightHeight in pixels.
idUnique identifier of the component in a namingContainer.Default is generated.
immediateWhen set true, process validations logic is executed at apply request values phase for this component.Default is false.
invalidCellStyleClassInvalid cell style class.
localeLocale.Default is en-US.
maxColsMaximum number of columns.
maxRowsMaximum number of rows.
minColsMinimum number of columns.Default is 0.
minRowsMinimum number of rows.Default is 0.
movableColsAllow columns to be moved.Default is false.
movableRowsAllow rows to be moved.Default is false.
noWordWrapStyleClassNo word wrap style class.
nullSortOrderNull sort order placement.Default is 1.
origSortOrderOriginal sort order for reset (internal).
placeholderCellStyleClassPlaceholder cell style class.
readOnlySheet read only.Default is false.
readOnlyCellStyleClassRead only cell style class.
renderedBoolean value to specify the rendering of the component, when set to false component will not be rendered.Default is true.
requiredMarks component as required.Default is false.
requiredMessage
resizableColsAllow columns to be resizable.Default is false.
resizableRowsAllow rows to be resizable.Default is false.
rowHeaderAn el expression resolving to a header for each row. Optional.
rowKeyUnique identifier of row data.
rowStyleClassStyle class for each row (EL).
selectedColumnSelected column index.
selectedLastColumnLast selected column index.
selectedLastRowLast selected row index.
selectedRowSelected row index.
selectionModeSelection mode: single, range, multiple.Default is multiple.
showColumnHeadersShow column headers.Default is true.
showRowHeadersShow row headers.Default is true.
sortByColumn/value expression to sort by (Object for correct type).
sortOrderSort direction.Default is ASCENDING.
stretchHHandsontable stretchH.
styleInline style of the component.
styleClassStyle class of the component.
tabindexTab index.Default is 0.
validatorA method expression referring to a method validating the input.
validatorMessage
valueThe value of the sheet (java.util.List).
valueChangeListenerA method binding expression referring to a method for handling a valuchangeevent.
varRequest-scope attribute name for the current row data.
widgetVarName of the client side widget.
widthWidth in pixels.
PrimeFaces Extensions Showcase - © 2011-2025,PrimeFaces: 16.0.0-SNAPSHOT,PrimeFaces Extensions: 16.0.0-SNAPSHOT,JSF: Apache MyFaces Core 4.0 - Impl 4.0.3,Server: Apache Tomcat (TomEE)/10.1.52 (10.1.4),Build time: 2026-03-08 21:04