Class Sheet
java.lang.Object
javax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UIOutput
javax.faces.component.UIInput
org.primefaces.extensions.component.sheet.Sheet
- All Implemented Interfaces:
EventListener,javax.faces.component.behavior.ClientBehaviorHolder,javax.faces.component.EditableValueHolder,javax.faces.component.PartialStateHolder,javax.faces.component.StateHolder,javax.faces.component.TransientStateHolder,javax.faces.component.ValueHolder,javax.faces.event.ComponentSystemEventListener,javax.faces.event.FacesListener,javax.faces.event.SystemEventListenerHolder,org.primefaces.component.api.Widget
public class Sheet
extends javax.faces.component.UIInput
Spreadsheet component wrappering the Handsontable jQuery UI component.
- Since:
- 6.2
- Author:
- Mark Lassiter / Melloware
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class javax.faces.component.UIInput
ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE, CONVERSION_MESSAGE_ID, EMPTY_STRING_AS_NULL_PARAM_NAME, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID, VALIDATE_EMPTY_FIELDS_PARAM_NAMEFields inherited from class javax.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEYFields inherited from interface org.primefaces.component.api.Widget
ATTR_WIDGET_VAR_PATTERN, CALLBACK_POST_CONSTRUCT, CALLBACK_POST_REFRESH, CALLBACK_PRE_DESTROY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendUpdateEvent(Object rowKey, int colIndex, Object rowData, Object oldValue, Object newValue) Appends an update eventvoidInvoke this method to commit the most recent set of ajax updates and restart the tracking of changes.protected org.primefaces.model.SortOrderConvert to PF SortOrder enum since we are leveraging PF sorting code.The list of child columns.The error message to display when the sheet is in error.Holds the filtered and sorted List of values.The focusId value.The height of the sheet.Generates the bad data var value for this sheet.The list of invalid updatesgetLocalValue(String rowKey, int col) Retrieves the submitted value for the rowKey and col.intgetMappedColumn(int renderCol) Maps the rendered column index to the real column index.The list of rendered child columns.intgetRenderIndexFromRealIdx(int realIdx) Provides the render column index based on the real indexgetRenderValueForCell(javax.faces.context.FacesContext context, String rowKey, int col) Gets the render string for the value the given cell.intThe number of rows in the value list.protected StringgetRowHeaderValueAsString(javax.faces.context.FacesContext context) Gets the row header text value as a string for use in javascriptprotected javax.el.ValueExpressionGets the rowHeader value expression definedprotected ObjectgetRowKeyValue(javax.faces.context.FacesContext context) Gets the rowKey for the current rowprotected StringGets the row key value as a String suitable for use in javascript rendering.protected StringgetRowKeyValueAsString(javax.faces.context.FacesContext context) Gets the row key value as a string for the current row var.The currently selected column.The currently selected column.The currently selected row.The currently selected row.The selection value.Please note: The return type needs to beObject.intGets the rendered col index of the column corresponding to the current sortBy.The sorted list of values.The sort directiongetStyle()The style valuegetSubmittedValue(String rowKey, int col) Retrieves the submitted value for the row and col.A list of updates from the last submission or ajax event.getValue()Return the value of the Sheet.getValueForCell(javax.faces.context.FacesContext context, String rowKey, int col) Gets the object value of the row and col specified.getVar()Return the request-scope attribute under which the data object for the current row will be exposed when iterating.getWidth()booleanbooleanbooleanReturns true if any of the columns contain conditional styling.booleanbooleanbooleanbooleanbooleanbooleanbooleanprotected booleanEvaluates the specified item value against the column filters and if they match, returns true, otherwise false.voidqueueEvent(javax.faces.event.FacesEvent event) protected voidremapFilteredList(List filteredList) Remaps the row keys in a hash map.protected voidRemaps the row keys in a hash map.voidAdds eval scripts to update the bad data array in the sheet to render validation failures produced by the most recent ajax update attempt.voidrenderRowUpdateScript(javax.faces.context.FacesContext context, Set<String> dirtyRows) Adds eval scripts to the ajax response to update the rows dirtied by the most recent successful update request.voidreset()Resets all filters, sorting and submitted values.voidResets invalid updatesvoidResets the sorting to the originally specified values (if any)voidResets the submitted valuesvoidrestoreState(javax.faces.context.FacesContext context, Object state) Restores the state for the submitted, local and bad values.voidsaveSortByColumn(String columnId) Saves the column by which the sheet is currently sorted (when the user clicks on a column).saveState(javax.faces.context.FacesContext context) Saves the state of the submitted and local values and the bad updates.voidsetActiveHeaderStyleClass(String value) voidsetAllowTabOffSheet(boolean value) voidsetCaseSensitiveSort(boolean value) voidsetColumns(List<SheetColumn> columns) Updates the list of child columns.voidsetCommentedCellStyleClass(String value) voidsetCurrentColStyleClass(String value) voidsetCurrentHeaderStyleClass(String value) voidsetCurrentRowStyleClass(String value) voidsetEmptyMessage(String value) voidsetErrorMessage(String value) Updates the errorMessage value.voidsetExtender(String extender) voidsetFilteredValue(List filteredValue) Sets the filtered list.voidsetFixedCols(Integer value) voidsetFixedRows(Integer value) voidsetFixedRowsBottom(Integer value) voidsetFocusId(String focusId) Updates the focusId value.voidUpdates the heightvoidsetInvalidCellStyleClass(String value) voidvoidsetLocalValue(String rowKey, int col, Object value) Updates a local value.voidsetMaxCols(Integer value) voidsetMaxRows(Integer value) voidsetMinCols(Integer value) voidsetMinRows(Integer value) voidsetMovableCols(boolean value) voidsetMovableRows(boolean value) voidsetNoWordWrapStyleClass(String value) voidsetNullSortOrder(Integer value) voidvoidsetReadOnly(boolean value) voidsetReadOnlyCellStyleClass(String value) voidsetResizableCols(boolean value) voidsetResizableRows(boolean value) voidsetRowStyleClass(String styleClass) voidUpdates the row var for iterations over the list.voidsetSelectedColumn(Integer col) Updates the selected column.voidUpdates the selected column.voidUpdates the selected row.voidsetSelectedRow(Integer row) Updates the selected row.voidsetSelection(String selection) Updates the selection value.voidsetSelectionMode(String value) voidsetShowColumnHeaders(boolean value) voidsetShowRowHeaders(boolean value) voidvoidsetSortOrder(String sortOrder) Update the sort directionvoidsetStretchH(String value) voidUpdate the style value for the componentvoidsetStyleClass(String styleClass) voidsetSubmittedValue(Object submittedValue) voidsetSubmittedValue(String rowKey, int col, String value) Updates a submitted value.voidsetTabindex(String tabindex) voidSet the value of theSheet.voidSet the request-scope attribute under which the data object for the current row wil be exposed when iterating.voidSorts and filters the datavoidUpdates the column mappings based on the rendered attributevoidupdateModel(javax.faces.context.FacesContext context) Override to update model with local values.voidvalidate(javax.faces.context.FacesContext context) Converts each submitted value into a local value and stores it back in the hash.Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, clearInitialState, compareValues, decode, getConvertedValue, getConverterMessage, getRequiredMessage, getValidator, getValidatorMessage, getValidators, getValueChangeListener, getValueChangeListeners, isEmpty, isImmediate, isLocalValueSet, isRequired, isValid, markInitialState, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, resetValue, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setValid, setValidator, setValidatorMessage, setValueChangeListener, validateValueMethods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, setConverterMethods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEventMethods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTreeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.faces.component.behavior.ClientBehaviorHolder
addClientBehavior, getClientBehaviorsMethods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, setConverterMethods inherited from interface org.primefaces.component.api.Widget
resolveWidgetVar, resolveWidgetVar
-
Field Details
-
EVENT_CELL_SELECT
- See Also:
-
EVENT_CHANGE
- See Also:
-
EVENT_SORT
- See Also:
-
EVENT_FILTER
- See Also:
-
EVENT_COLUMN_SELECT
- See Also:
-
EVENT_ROW_SELECT
- See Also:
-
COMPONENT_TYPE
- See Also:
-
COMPONENT_FAMILY
- See Also:
-
-
Constructor Details
-
Sheet
public Sheet()
-
-
Method Details
-
getFamily
-
getEventNames
- Specified by:
getEventNamesin interfacejavax.faces.component.behavior.ClientBehaviorHolder- Overrides:
getEventNamesin classjavax.faces.component.UIComponentBase
-
getDefaultEventName
- Specified by:
getDefaultEventNamein interfacejavax.faces.component.behavior.ClientBehaviorHolder- Overrides:
getDefaultEventNamein classjavax.faces.component.UIComponentBase
-
queueEvent
public void queueEvent(javax.faces.event.FacesEvent event) - Overrides:
queueEventin classjavax.faces.component.UIComponentBase
-
getColumns
The list of child columns. -
getRenderedColumns
The list of rendered child columns. -
setColumns
Updates the list of child columns. -
getInvalidUpdates
The list of invalid updates -
resetSubmitted
public void resetSubmitted()Resets the submitted values -
resetSort
public void resetSort()Resets the sorting to the originally specified values (if any) -
resetInvalidUpdates
public void resetInvalidUpdates()Resets invalid updates -
reset
public void reset()Resets all filters, sorting and submitted values. -
setSubmittedValue
Updates a submitted value. -
getSubmittedValue
Retrieves the submitted value for the row and col. -
setLocalValue
Updates a local value. -
getLocalValue
Retrieves the submitted value for the rowKey and col. -
setRowVar
Updates the row var for iterations over the list. The var value will be updated to the value for the specified rowKey.- Parameters:
context- the FacesContext against which to the row var is set. Passed for performancerowKey- the rowKey string
-
getRowMap
-
getValueForCell
Gets the object value of the row and col specified. If a local value exists, that is returned, otherwise the actual value is return. -
getRenderValueForCell
public String getRenderValueForCell(javax.faces.context.FacesContext context, String rowKey, int col) Gets the render string for the value the given cell. Applys the available converters to convert the value. -
getRowHeaderValueAsString
Gets the row header text value as a string for use in javascript -
getSortedValues
The sorted list of values. -
getSortColRenderIndex
public int getSortColRenderIndex()Gets the rendered col index of the column corresponding to the current sortBy. This is used to keep track of the current sort column in the page. -
matchesFilter
protected boolean matchesFilter()Evaluates the specified item value against the column filters and if they match, returns true, otherwise false. If no filterMatchMode is given on a column than the "contains" mode is used. Otherwise the following filterMatchMode values are possible: - startsWith: Checks if column value starts with the filter value. - endsWith: Checks if column value ends with the filter value. - contains: Checks if column value contains the filter value. - exact: Checks if string representations of column value and filter value are same. -
sortAndFilter
Sorts and filters the data -
remapFilteredList
Remaps the row keys in a hash map. -
remapRows
protected void remapRows()Remaps the row keys in a hash map. -
getRowKeyValue
Gets the rowKey for the current row- Parameters:
context- the faces context- Returns:
- a row key value or null if the expression is not set
-
getRowKeyValueAsString
Gets the row key value as a String suitable for use in javascript rendering. -
getRowKeyValueAsString
Gets the row key value as a string for the current row var. -
convertSortOrder
protected org.primefaces.model.SortOrder convertSortOrder()Convert to PF SortOrder enum since we are leveraging PF sorting code. -
validate
public void validate(javax.faces.context.FacesContext context) Converts each submitted value into a local value and stores it back in the hash. If all values convert without error, then the component is valid, and we can proceed to the processUpdates.- Overrides:
validatein classjavax.faces.component.UIInput
-
updateModel
public void updateModel(javax.faces.context.FacesContext context) Override to update model with local values. Note that this is where things can be fragile in that we can successfully update some values and fail on others. There is no clean way to roll back the updates, but we also need to fail processing. Consider keeping old values as we update (need for event anyhow) and if there is a failure attempt to roll back by updating successful model updates with the old value. This may not all be necessary.- Overrides:
updateModelin classjavax.faces.component.UIInput
-
saveState
Saves the state of the submitted and local values and the bad updates.- Specified by:
saveStatein interfacejavax.faces.component.StateHolder- Overrides:
saveStatein classjavax.faces.component.UIInput
-
restoreState
Restores the state for the submitted, local and bad values.- Specified by:
restoreStatein interfacejavax.faces.component.StateHolder- Overrides:
restoreStatein classjavax.faces.component.UIInput
-
getSelection
The selection value.- Returns:
- the selection
-
setSelection
Updates the selection value.- Parameters:
selection- the selection to set
-
getSubmittedValue
- Specified by:
getSubmittedValuein interfacejavax.faces.component.EditableValueHolder- Overrides:
getSubmittedValuein classjavax.faces.component.UIInput
-
setSubmittedValue
- Specified by:
setSubmittedValuein interfacejavax.faces.component.EditableValueHolder- Overrides:
setSubmittedValuein classjavax.faces.component.UIInput
-
getUpdates
A list of updates from the last submission or ajax event.- Returns:
- the editEvent
-
isHasStyledCells
public boolean isHasStyledCells()Returns true if any of the columns contain conditional styling. -
getMappedColumn
public int getMappedColumn(int renderCol) Maps the rendered column index to the real column index.- Parameters:
renderCol- the rendered index- Returns:
- the mapped index
-
getRenderIndexFromRealIdx
public int getRenderIndexFromRealIdx(int realIdx) Provides the render column index based on the real index -
updateColumnMappings
public void updateColumnMappings()Updates the column mappings based on the rendered attribute -
getRowCount
public int getRowCount()The number of rows in the value list. -
getFocusId
The focusId value.- Returns:
- the focusId
-
setFocusId
Updates the focusId value.- Parameters:
focusId- the focusId to set
-
commitUpdates
public void commitUpdates()Invoke this method to commit the most recent set of ajax updates and restart the tracking of changes. Use this when you have processes the updates to the model and are confident that any changes made to this point can be cleared (likely because you have persisted those changes). -
getInvalidDataValue
Generates the bad data var value for this sheet. -
renderRowUpdateScript
Adds eval scripts to the ajax response to update the rows dirtied by the most recent successful update request.- Parameters:
context- the FacesContextdirtyRows- the set of dirty rows
-
renderBadUpdateScript
public void renderBadUpdateScript()Adds eval scripts to update the bad data array in the sheet to render validation failures produced by the most recent ajax update attempt. -
appendUpdateEvent
public void appendUpdateEvent(Object rowKey, int colIndex, Object rowData, Object oldValue, Object newValue) Appends an update event -
setStyleClass
-
getStyleClass
-
setStretchH
-
getStretchH
-
setEmptyMessage
-
getEmptyMessage
-
getSortBy
Please note: The return type needs to beObject. Otherwise, evaluating thesortByattribute as a value expression forces it into a string, and strings are sorted differently than numbers.- Returns:
- The ID of the column to sort by.
-
setSortBy
-
setShowColumnHeaders
public void setShowColumnHeaders(boolean value) -
isShowColumnHeaders
public boolean isShowColumnHeaders() -
setShowRowHeaders
public void setShowRowHeaders(boolean value) -
isShowRowHeaders
public boolean isShowRowHeaders() -
setResizableRows
public void setResizableRows(boolean value) -
isResizableRows
public boolean isResizableRows() -
setResizableCols
public void setResizableCols(boolean value) -
isResizableCols
public boolean isResizableCols() -
setMovableRows
public void setMovableRows(boolean value) -
isMovableRows
public boolean isMovableRows() -
setMovableCols
public void setMovableCols(boolean value) -
isMovableCols
public boolean isMovableCols() -
setRowStyleClass
-
getRowStyleClass
-
getActiveHeaderStyleClass
-
setReadOnly
public void setReadOnly(boolean value) -
isReadOnly
public boolean isReadOnly() -
setActiveHeaderStyleClass
-
getCommentedCellStyleClass
-
setCommentedCellStyleClass
-
getCurrentColStyleClass
-
setCurrentColStyleClass
-
getCurrentHeaderStyleClass
-
setCurrentHeaderStyleClass
-
getCurrentRowStyleClass
-
setCurrentRowStyleClass
-
getInvalidCellStyleClass
-
setInvalidCellStyleClass
-
getNoWordWrapStyleClass
-
setNoWordWrapStyleClass
-
getPlaceholderCellStyleClass
-
setPlaceholderCellStyleClass
-
getReadOnlyCellStyleClass
-
setReadOnlyCellStyleClass
-
setAllowTabOffSheet
public void setAllowTabOffSheet(boolean value) -
isAllowTabOffSheet
public boolean isAllowTabOffSheet() -
getTabindex
-
setTabindex
-
getExtender
-
setExtender
-
setCaseSensitiveSort
public void setCaseSensitiveSort(boolean value) -
isCaseSensitiveSort
public boolean isCaseSensitiveSort() -
getNullSortOrder
-
setNullSortOrder
-
setMaxRows
-
getMaxRows
-
setMinRows
-
getMinRows
-
setMaxCols
-
getMaxCols
-
setMinCols
-
getMinCols
-
setFixedRows
-
getFixedRows
-
setFixedRowsBottom
-
getFixedRowsBottom
-
setFixedCols
-
getFixedCols
-
getLocale
-
setLocale
-
setSelectionMode
-
getSelectionMode
-
getSelectedColumn
The currently selected column.- Returns:
-
setSelectedColumn
Updates the selected column.- Parameters:
col-
-
getSelectedLastColumn
The currently selected column.- Returns:
-
setSelectedLastColumn
Updates the selected column.- Parameters:
col-
-
getSelectedRow
The currently selected row.- Returns:
-
getSelectedLastRow
The currently selected row.- Returns:
-
setSelectedRow
Updates the selected row.- Parameters:
row-
-
setSelectedLastRow
Updates the selected row.- Parameters:
row-
-
getWidth
-
setWidth
-
getHeight
The height of the sheet. Note this is applied to the inner div which is why it is recommend you use this property instead of a style class.- Returns:
-
setHeight
Updates the height- Parameters:
value-
-
getValue
Return the value of the Sheet. This value must be a java.util.List value at this time.- Specified by:
getValuein interfacejavax.faces.component.ValueHolder- Overrides:
getValuein classjavax.faces.component.UIInput
-
getFilteredValue
Holds the filtered and sorted List of values.- Returns:
- a List of sorted and filtered values
-
setFilteredValue
Sets the filtered list.- Parameters:
filteredValue- the List to store
-
setValue
Set the value of theSheet. This value must be a java.util.List at this time.- Specified by:
setValuein interfacejavax.faces.component.ValueHolder- Overrides:
setValuein classjavax.faces.component.UIInput- Parameters:
value- the new value
-
setStyle
Update the style value for the component- Parameters:
value-
-
getStyle
The style value- Returns:
- the style value
-
getRowHeaderValueExpression
protected javax.el.ValueExpression getRowHeaderValueExpression()Gets the rowHeader value expression defined- Returns:
- a value expression for Row Header or null if the expression is not set
-
getVar
Return the request-scope attribute under which the data object for the current row will be exposed when iterating. This property is not enabled for value binding expressions. -
setVar
Set the request-scope attribute under which the data object for the current row wil be exposed when iterating.- Parameters:
var- The new request-scope attribute name
-
saveSortByColumn
Saves the column by which the sheet is currently sorted (when the user clicks on a column).- Parameters:
columnId- ID of the column by which the sheet is currently sorted.
-
getSortOrder
The sort direction- Returns:
-
setSortOrder
Update the sort direction- Parameters:
sortOrder-
-
getErrorMessage
The error message to display when the sheet is in error.- Returns:
-
setErrorMessage
Updates the errorMessage value.- Parameters:
value-
-