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 String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields 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_NAME
Fields 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_KEY
Fields 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 TypeMethodDescriptionvoid
appendUpdateEvent
(Object rowKey, int colIndex, Object rowData, Object oldValue, Object newValue) Appends an update eventvoid
Invoke this method to commit the most recent set of ajax updates and restart the tracking of changes.protected org.primefaces.model.SortOrder
Convert 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.int
getMappedColumn
(int renderCol) Maps the rendered column index to the real column index.The list of rendered child columns.int
getRenderIndexFromRealIdx
(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.int
The number of rows in the value list.protected String
getRowHeaderValueAsString
(javax.faces.context.FacesContext context) Gets the row header text value as a string for use in javascriptprotected javax.el.ValueExpression
Gets the rowHeader value expression definedprotected Object
getRowKeyValue
(javax.faces.context.FacesContext context) Gets the rowKey for the current rowprotected String
Gets the row key value as a String suitable for use in javascript rendering.protected String
getRowKeyValueAsString
(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
.int
Gets 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()
boolean
boolean
boolean
Returns true if any of the columns contain conditional styling.boolean
boolean
boolean
boolean
boolean
boolean
boolean
protected boolean
Evaluates the specified item value against the column filters and if they match, returns true, otherwise false.void
queueEvent
(javax.faces.event.FacesEvent event) protected void
remapFilteredList
(List filteredList) Remaps the row keys in a hash map.protected void
Remaps the row keys in a hash map.void
Adds eval scripts to update the bad data array in the sheet to render validation failures produced by the most recent ajax update attempt.void
renderRowUpdateScript
(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.void
reset()
Resets all filters, sorting and submitted values.void
Resets invalid updatesvoid
Resets the sorting to the originally specified values (if any)void
Resets the submitted valuesvoid
restoreState
(javax.faces.context.FacesContext context, Object state) Restores the state for the submitted, local and bad values.void
saveSortByColumn
(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.void
setActiveHeaderStyleClass
(String value) void
setAllowTabOffSheet
(boolean value) void
setCaseSensitiveSort
(boolean value) void
setColumns
(List<SheetColumn> columns) Updates the list of child columns.void
setCommentedCellStyleClass
(String value) void
setCurrentColStyleClass
(String value) void
setCurrentHeaderStyleClass
(String value) void
setCurrentRowStyleClass
(String value) void
setEmptyMessage
(String value) void
setErrorMessage
(String value) Updates the errorMessage value.void
setExtender
(String extender) void
setFilteredValue
(List filteredValue) Sets the filtered list.void
setFixedCols
(Integer value) void
setFixedRows
(Integer value) void
setFixedRowsBottom
(Integer value) void
setFocusId
(String focusId) Updates the focusId value.void
Updates the heightvoid
setInvalidCellStyleClass
(String value) void
void
setLocalValue
(String rowKey, int col, Object value) Updates a local value.void
setMaxCols
(Integer value) void
setMaxRows
(Integer value) void
setMinCols
(Integer value) void
setMinRows
(Integer value) void
setMovableCols
(boolean value) void
setMovableRows
(boolean value) void
setNoWordWrapStyleClass
(String value) void
setNullSortOrder
(Integer value) void
void
setReadOnly
(boolean value) void
setReadOnlyCellStyleClass
(String value) void
setResizableCols
(boolean value) void
setResizableRows
(boolean value) void
setRowStyleClass
(String styleClass) void
Updates the row var for iterations over the list.void
setSelectedColumn
(Integer col) Updates the selected column.void
Updates the selected column.void
Updates the selected row.void
setSelectedRow
(Integer row) Updates the selected row.void
setSelection
(String selection) Updates the selection value.void
setSelectionMode
(String value) void
setShowColumnHeaders
(boolean value) void
setShowRowHeaders
(boolean value) void
void
setSortOrder
(String sortOrder) Update the sort directionvoid
setStretchH
(String value) void
Update the style value for the componentvoid
setStyleClass
(String styleClass) void
setSubmittedValue
(Object submittedValue) void
setSubmittedValue
(String rowKey, int col, String value) Updates a submitted value.void
setTabindex
(String tabindex) void
Set the value of theSheet
.void
Set the request-scope attribute under which the data object for the current row wil be exposed when iterating.void
Sorts and filters the datavoid
Updates the column mappings based on the rendered attributevoid
updateModel
(javax.faces.context.FacesContext context) Override to update model with local values.void
validate
(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, validateValue
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, setConverter
Methods 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, unsubscribeFromEvent
Methods 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, visitTree
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.faces.component.behavior.ClientBehaviorHolder
addClientBehavior, getClientBehaviors
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, setConverter
Methods 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:
getEventNames
in interfacejavax.faces.component.behavior.ClientBehaviorHolder
- Overrides:
getEventNames
in classjavax.faces.component.UIComponentBase
-
getDefaultEventName
- Specified by:
getDefaultEventName
in interfacejavax.faces.component.behavior.ClientBehaviorHolder
- Overrides:
getDefaultEventName
in classjavax.faces.component.UIComponentBase
-
queueEvent
public void queueEvent(javax.faces.event.FacesEvent event) - Overrides:
queueEvent
in 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:
validate
in 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:
updateModel
in classjavax.faces.component.UIInput
-
saveState
Saves the state of the submitted and local values and the bad updates.- Specified by:
saveState
in interfacejavax.faces.component.StateHolder
- Overrides:
saveState
in classjavax.faces.component.UIInput
-
restoreState
Restores the state for the submitted, local and bad values.- Specified by:
restoreState
in interfacejavax.faces.component.StateHolder
- Overrides:
restoreState
in 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:
getSubmittedValue
in interfacejavax.faces.component.EditableValueHolder
- Overrides:
getSubmittedValue
in classjavax.faces.component.UIInput
-
setSubmittedValue
- Specified by:
setSubmittedValue
in interfacejavax.faces.component.EditableValueHolder
- Overrides:
setSubmittedValue
in 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 thesortBy
attribute 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:
getValue
in interfacejavax.faces.component.ValueHolder
- Overrides:
getValue
in 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:
setValue
in interfacejavax.faces.component.ValueHolder
- Overrides:
setValue
in 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
-
-