|
Project Wonder 5.0 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectcom.webobjects.appserver.WOElement
com.webobjects.appserver.WOComponent
er.ajax.AjaxGrid
public class AjaxGrid
Ajax powered grid based on HTML Table that provides drag and drop column re-ordering, complex sorting, and the ability to embed components in cells. Class names and spans are used extensively to allow the display to be heavily customized with CSS.
The data is taken from a WODisplayGroup. Use er.extensions.ERXBatchingDisplayGroup to provide high performance access to large data sets.
Navigation between batches is not implemented as implementing in it another component bound to the display group will allow for a more flexible UI.
{
tableID = "exampleAjaxGrid"; // Goes on main table tag
updateContainerID = "ajaxGridContainer"; // Goes on div wrapping table, used with AjaxUpdate* components
updateFrequency = 60; // Optional frequency of automatic updates of the grid contents
// This function uses the Ajax.PeriodicalUpdater which does an
// update when it is first created, rather than waiting for the
// frequency time before making the first request
cssClass = "ajaxGrid"; // CSS class attribute on main table tag, optional
cssStyle = "border: thin solid #000000;"; // CSS style attribute on main table tag, optional
evenRowCSSClass = "yellowBackground"; // CSS class attribute on even rows, optional
oddRowCSSClass = "greyBackground"; // CSS class attribute on odd rows, optional
evenRowCSSStyle = "background:lightyellow;" // CSS style attribute on even rows, optional
oddRowCSSStyle = "background:lightgrey;"; // CSS style attribute on odd rows, optional
showRowSelector = true; // Optional, defaults to true, if false no UI is shown to select a row - the cell has only
selectedRowCSSClass = "yellowBackground"; // Secondary CSS class attribute on selected rows, optional
unselectedRowCSSClass = "greyBackground"; // Secondary CSS class attribute on unselected rows, optional
selectedRowCSSStyle = "background:lightyellow;"; // Secondary CSS style attribute on selected rows, optional
unselectedRowCSSStyle = "background:lightgrey;";// Secondary CSS style attribute on unselected rows, optional
canReorder = true; // Optional, defaults to true, Enables (or disables) drag and drop reordering of columns
canResort = true; // Optional, defaults to true, Enables (or disables) sorting by clicking the column titles
dragHeaderOnly = true; // Optional, defaults to false, true if only the title/header cells can
// be dragged to re-order columns
batchSize = 10; // Controls size of batch in display group, use zero for no batching
rowIdentifier = adKey; // Optional, key path into row returning a unique identifier for the row
// rowIdentifier is used to build HTML ID attributes, so a String or Number works best
er.extensions.ERXWORepetition.checkHashCodes = true; // Optional override for global ERXWORepetition setting
columns = ( // List of columns to display, controls the initial display order
{
title = "Name"; // Title for this column in the table header row
keyPath = "fullName"; // Key path into row returning the data to display in this colunmn
}, // keyPath is optional if component is specified
{
title = "Department";
keyPath = "department.name";
sortPath = "department.code"; // sortPath is an optional path to sort this column on, defaults to keyPath
// This is useful if keyPath points to something that can't be sorted or a
// different sort order is need, e.g. here by Department Code rather than name.
// It can also be used when component is used to provide a sorting for the column
},
{
title = "Hire Date";
keyPath = "hireDate";
formatterClass = "com.webobjects.foundation.NSTimestampFormatter"; // Class of formatter to apply to values in this column
formatPattern = "%m/%d/%y"; // Optional pattern if needed by formatter
},
{
title = "Salary";
keyPath = "salary";
formatterClass = "com.webobjects.foundation.NSNumberFormatter";
formatPattern = "$###,##0.00";
cssClass = "alignRight"; // CSS class attribute td tag in this column, optional
},
{
title = "Vacation Days";
keyPath = "daysVacation";
formatterClass = "com.webobjects.foundation.NSNumberFormatter";
cssStyle = "text-align: right;"; // CSS style attribute td tag in this column, useful for text-align and width, optional
},
{
title = "Actions";
keyPath = ""; // Missing or empty keypath results in the current object itself being passed to component
component = "EmployeeActions"; // Name of WOComponent to be displayed in this column. Gets passed two bindings: value (Object),
// and grid (AjaxGrid) so that any other needed data can be accessed
cssClass = "alignCenter";
}
);
sortOrder = (
{
keyPath = "department.code"; // If the related column definition uses sortPath, this keyPath should match it
// This was left as keyPath (rather than sortPath) for backwards compatibility
direction = "ascending";
},
{
keyPath = "salary";
direction = "descending";
},
{
keyPath = "daysVacation";
direction = "ascending";
}
); // This sort is always present so that if the grid is sorted with some ordering where
mandatorySort = { // identical values span multiple batches, batch membership will not be indeterminate.
keyPath = "masterAdKey"; // This will only function if this sorting is quite unique (e.g. like a PK).
direction = "ascending"; // If this sort is also present in sortOrder (above), it will not be duplicated
}; // but will still always be present. If the user has not manually selected it,
// it will not be indicated in the UI.
}
public NSMutableDictionary configData() {
if (configData == null) {
// Get data from user preferences here if available, otherwise load the defaults
configData = mySession().user().preferencesFor("AjaxGridExample");
if (configData == null) {
NSData data = new NSData(application().resourceManager().bytesForResourceNamed("AjaxGridExampleConfiguration.plist", null, NSArray.EmptyArray));
configData = new NSMutableDictionary((NSDictionary) NSPropertyListSerialization.propertyListFromData(data, "UTF-8"));
}
}
return configData;
}
updateContainerID gives the ID
for this. This can be used as the updateContainerID in a
AjaxUpdateLink or
<updateContainerID>Update() can be called directly. This
results in a call to ajaxGrid_init('<tableID>'); to be
re-enable drag and drop on the table.
Here is an example. In this example, updateContainerID is used
to update the grid, and then the NavBar container is updated
manually from onComplete. The reason for this is that the
grid needs to update first so that the correct values are available for
updating the NavBar.
Relevant Configuration:
{
tableID = "exampleAjaxGrid";
updateContainerID = "ajaxGridContainer";
. . .
WOD Bindings:
NavUpdater: AjaxUpdateContainer {
id = "NavBar";
}
NextBatch : AjaxUpdateLink {
action = nextBatch;
updateContainerID = "ajaxGridContainer";
onComplete = "function(request) { NavBarUpdate(); }";
}
| Class Name | Used For |
|---|---|
| ajaxGridRemoveSorting | The th of cell containing link to remove all sorting |
| ajaxGridColumnTitle | The th of cells containing column titles |
| ajaxGridSortAscending | The span that wraps index and direction indicator of columns sorted in ascending order |
| ajaxGridSortDescending | The span that wraps index and direction indicator of columns sorted in descending order |
| ajaxGridSelectRow | The td of cells containing the row selection link |
span tags wrapping default text content. These are there so
that the span wrapping the default content can be set to
display: none and the content of the outer div given in CSS.
For this HTML:
<th class="ajaxGridRemoveSorting"><span>X</span><em> </em></th>The default X can replaced with an image with this CSS:
th.ajaxGridRemoveSorting a span {display: none;}
th.ajaxGridRemoveSorting a em {
background-image: url(http://vancouver.global-village.net/WebObjects/Frameworks/JavaDirectToWeb.framework/WebServerResources/trashcan-btn.gif);
background-repeat:no-repeat;
padding-right: 12px;
padding-bottom: 5px;
}
You can also use content to replace the span content with text
if your browser (not IE) supports it.
| Bindings | |
displayGroup | required, WODisplayGroup acting as source and batching
engine for the data to be displayed |
configurationData | required, NSMutableDictionary used to configure
grid, see documentation for details |
selectedObjects | optional, NSMutableArray list of rows that the user
has selected from the grid |
willUpdate | optional, Ajax action method called when the
AjaxUpdateContainer is being updated, but before it renders its
content |
afterUpdate | optional, JavaScript to execute client-side after the
grid has updated |
updateContainerParameters | optional, passed as parameters binding to
the AjaxUpdateContainer wrapping the grid |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent |
|---|
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event |
| Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
|---|
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility |
| Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding |
|---|
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor |
| Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation |
|---|
com.webobjects.foundation.NSValidation._MethodBinding, com.webobjects.foundation.NSValidation._ValidationBinding, com.webobjects.foundation.NSValidation.DefaultImplementation, com.webobjects.foundation.NSValidation.Utility, com.webobjects.foundation.NSValidation.ValidationException |
| Field Summary | |
|---|---|
static java.lang.String |
AFTER_UPDATE_BINDING
|
static java.lang.String |
BATCH_SIZE
|
static java.lang.String |
CAN_REORDER
|
static java.lang.String |
CAN_RESORT
|
static java.lang.String |
CHECK_HASH_CODES
|
static java.lang.String |
COLUMNS
|
static java.lang.String |
COMPONENT_NAME
|
static java.lang.String |
CONFIGURATION_DATA_BINDING
|
static java.lang.String |
CONFIGURATION_UPDATED
|
static java.lang.String |
DESTINATION_COLUMN_FORM_VALUE
|
static java.lang.String |
DISPLAY_GROUP_BINDING
|
static java.lang.String |
DRAG_HEADER_ONLY
|
static java.lang.String |
EVEN_ROW_CSS_CLASS
|
static java.lang.String |
EVEN_ROW_CSS_STYLE
|
static java.lang.String |
FORMAT_PATTERN
|
static java.lang.String |
FORMATTER_CLASS
|
static java.lang.String |
KEY_PATH
|
static java.lang.String |
MANDATORY_SORT
|
static java.lang.String |
MANDATORY_SORT_ORDER_FLAG
|
static java.lang.String |
ODD_ROW_CSS_CLASS
|
static java.lang.String |
ODD_ROW_CSS_STYLE
|
static java.lang.String |
ROW_IDENTIFIER
|
static java.lang.String |
SELECTED_OBJECTS_BINDING
|
static java.lang.String |
SELECTED_ROW_CSS_CLASS
|
static java.lang.String |
SELECTED_ROW_CSS_STYLE
|
static java.lang.String |
SHOW_ROW_SELECTOR
|
static java.lang.String |
SORT_ASCENDING
|
static java.lang.String |
SORT_DESCENDING
|
static java.lang.String |
SORT_DIRECTION
|
static java.lang.String |
SORT_ORDER
|
static java.lang.String |
SORT_PATH
|
static java.lang.String |
SOURCE_COLUMN_FORM_VALUE
|
static java.lang.String |
TABLE_ID
|
static java.lang.String |
TITLE
|
static java.lang.String |
UNSELECTED_ROW_CSS_CLASS
|
static java.lang.String |
UNSELECTED_ROW_CSS_STYLE
|
static java.lang.String |
UPDATE_CONTAINER_ID
|
static java.lang.String |
UPDATE_FREQUENCY
|
static java.lang.String |
WILL_UPDATE_BINDING
|
| Fields inherited from class com.webobjects.appserver.WOComponent |
|---|
_Extension, _IsEventLoggingEnabled, _keyAssociations |
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling |
|---|
_CLASS |
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
|---|
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator |
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
|---|
NullValue |
| Fields inherited from interface com.webobjects.foundation.NSValidation |
|---|
_CLASS |
| Constructor Summary | |
|---|---|
AjaxGrid(com.webobjects.appserver.WOContext context)
|
|
| Method Summary | |
|---|---|
java.lang.String |
afterUpdate()
Binding value for onRefreshComplete function of AjaxUpdate container. |
void |
appendToResponse(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context)
Adds movecolumns.js to the header. |
protected int |
batchSize()
Returns BATCH_SIZE value from configurationData() |
boolean |
canReorder()
Returns CAN_REORDER value from configurationData(), or true if not
configured. |
boolean |
canResort()
Returns CAN_RESORT value from configurationData(), or true if not
configured. |
boolean |
checkHashCodes()
Allows configuration data to override ERXWORepetition default for checkHashCodes. |
protected void |
clearCachedConfiguration()
Clears local cache of configuration data so that fresh data will be cached. |
java.lang.String |
columnComponentName()
|
java.text.Format |
columnFormatter()
|
void |
columnOrderUpdated()
Ajax action method for when columns are dragged and dropped. |
protected com.webobjects.foundation.NSMutableArray |
columns()
Returns COLUMNS value from configurationData() |
com.webobjects.foundation.NSMutableDictionary |
columnsByKeypath()
|
java.lang.Object |
columnValue()
|
com.webobjects.foundation.NSMutableDictionary |
configurationData()
|
void |
containerUpdated()
This method is called when the AjaxUpdateContainer is about to update. |
com.webobjects.foundation.NSDictionary |
currentColumn()
Cover method for item binding of a WORepetition. |
java.lang.String |
currentColumnID()
|
int |
currentColumnSortIndex()
|
com.webobjects.foundation.NSMutableDictionary |
currentColumnSortOrder()
|
java.lang.String |
currentKeyPath()
|
java.lang.String |
currentSortPath()
|
com.webobjects.appserver.WODisplayGroup |
displayGroup()
|
java.lang.String |
dragHeaderOnly()
|
java.lang.String |
enableDragAndDrop()
Returns Javacript to (re)initialize drag and drop on the grid. |
com.webobjects.foundation.NSMutableDictionary |
formattersByKeypath()
|
boolean |
hasMandatorySort()
|
java.lang.String |
initScript()
Script that goes on this page to initialize drag and drop on the grid when the page loads / re-loads |
boolean |
isCurrentColumnSorted()
|
boolean |
isCurrentColumnSortedAscending()
|
boolean |
isRowSelected()
|
com.webobjects.foundation.NSDictionary |
manadatorySortDictionary()
Returns a copy of the mandatory sort configuration with an additional (dummy) value for the MANDATORY_SORT_ORDER_FLAG. |
java.lang.String |
manadatorySortKeyPath()
|
void |
removeSorting()
Ajax action method for when control clicked to remove all sorting. |
java.lang.String |
removeSortingID()
|
com.webobjects.foundation.NSKeyValueCodingAdditions |
row()
Cover method for item binding of a WORepetition. |
java.lang.String |
rowClass()
Returns EVEN_ROW_CSS_CLASS or ODD_ROW_CSS_CLASS, depending on rowIndex(), value from configurationData() followed by SELECTED_ROW_CSS_CLASS or UNSELECTED_ROW_CSS_CLASS, depending on isRowSelected(), value from configurationData() |
java.lang.String |
rowID()
Returns a value suitable for use as part of an HTML ID attribute that uniquely identifies this row. |
java.lang.String |
rowIdentifier()
Returns an optional key path into row that will return a value that uniquely identifies this row. |
java.lang.String |
rowIdentifierKey()
Returns a key into this row that produces a unique value for this row. |
int |
rowIndex()
Cover method for index binding of a WORepetition. |
java.lang.String |
rowStyle()
Returns EVEN_ROW_CSS_STYLE or ODD_ROW_CSS_STYLE, depending on rowIndex(), value from configurationData() folowed by SELECTED_ROW_CSS_STYLE or UNSELECTED_ROW_CSS_STYLE, depending on isRowSelected(), value from configurationData() |
com.webobjects.foundation.NSMutableArray |
selectedObjects()
This list is implemented by AjaxGrid and is not based on the display group's selected objects. |
void |
setColumnValue(java.lang.Object value)
Method used with automatic synchronizing custom components. |
void |
setCurrentColumn(com.webobjects.foundation.NSDictionary newColumn)
Cover method for item binding of a WORepetition. |
void |
setRow(com.webobjects.foundation.NSKeyValueCodingAdditions newRow)
Cover method for item binding of a WORepetition. |
void |
setRowIndex(int index)
Cover method for index binding of a WORepetition. |
boolean |
showRowSelector()
|
protected com.webobjects.foundation.NSMutableArray |
sortOrders()
Returns SORT_ORDER value from configurationData() |
com.webobjects.foundation.NSMutableDictionary |
sortOrdersByKeypath()
|
void |
sortOrderUpdated()
Ajax action method for when column titles are clicked to change sorting. |
boolean |
synchronizesVariablesWithBindings()
|
java.lang.String |
tableID()
Returns TABLE_ID value from configurationData() |
AjaxGrid |
thisComponent()
|
void |
toggleRowSelection()
Toggles inclusion of row into selectedObjects() (i.e. |
java.lang.String |
toggleRowSelectionID()
|
protected void |
updateBatchSize()
Updates numberOfObjectsPerBatch on the display group |
static void |
updateBatchSize(com.webobjects.appserver.WODisplayGroup dg,
int batchSize)
Updates numberOfObjectsPerBatch on the display group. |
protected void |
updateDisplayGroupSort()
Updates sort orders on the display group. |
static void |
updateDisplayGroupSort(com.webobjects.appserver.WODisplayGroup dg,
com.webobjects.foundation.NSArray sortConfig)
Updates sort orders on the display group. |
| Methods inherited from class com.webobjects.appserver.WOComponent |
|---|
_associationWithName, _awakeInContext, _childTemplate, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, awake, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, invokeAction, isCachingEnabled, isEventLoggingEnabled, isStateless, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, reset, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, sleep, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TITLE
public static final java.lang.String KEY_PATH
public static final java.lang.String SORT_PATH
public static final java.lang.String SORT_DIRECTION
public static final java.lang.String SORT_ASCENDING
public static final java.lang.String SORT_DESCENDING
public static final java.lang.String SORT_ORDER
public static final java.lang.String COLUMNS
public static final java.lang.String BATCH_SIZE
public static final java.lang.String UPDATE_CONTAINER_ID
public static final java.lang.String TABLE_ID
public static final java.lang.String ROW_IDENTIFIER
public static final java.lang.String CAN_REORDER
public static final java.lang.String CAN_RESORT
public static final java.lang.String DRAG_HEADER_ONLY
public static final java.lang.String SOURCE_COLUMN_FORM_VALUE
public static final java.lang.String DESTINATION_COLUMN_FORM_VALUE
public static final java.lang.String FORMATTER_CLASS
public static final java.lang.String FORMAT_PATTERN
public static final java.lang.String EVEN_ROW_CSS_CLASS
public static final java.lang.String ODD_ROW_CSS_CLASS
public static final java.lang.String EVEN_ROW_CSS_STYLE
public static final java.lang.String ODD_ROW_CSS_STYLE
public static final java.lang.String SHOW_ROW_SELECTOR
public static final java.lang.String SELECTED_ROW_CSS_CLASS
public static final java.lang.String UNSELECTED_ROW_CSS_CLASS
public static final java.lang.String SELECTED_ROW_CSS_STYLE
public static final java.lang.String UNSELECTED_ROW_CSS_STYLE
public static final java.lang.String CONFIGURATION_UPDATED
public static final java.lang.String COMPONENT_NAME
public static final java.lang.String UPDATE_FREQUENCY
public static final java.lang.String DISPLAY_GROUP_BINDING
public static final java.lang.String CONFIGURATION_DATA_BINDING
public static final java.lang.String SELECTED_OBJECTS_BINDING
public static final java.lang.String WILL_UPDATE_BINDING
public static final java.lang.String AFTER_UPDATE_BINDING
public static final java.lang.String MANDATORY_SORT_ORDER_FLAG
public static final java.lang.String MANDATORY_SORT
public static final java.lang.String CHECK_HASH_CODES
| Constructor Detail |
|---|
public AjaxGrid(com.webobjects.appserver.WOContext context)
| Method Detail |
|---|
public boolean synchronizesVariablesWithBindings()
synchronizesVariablesWithBindings in class com.webobjects.appserver.WOComponent
public void appendToResponse(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context)
appendToResponse in class com.webobjects.appserver.WOComponentpublic void columnOrderUpdated()
public void sortOrderUpdated()
public void removeSorting()
public java.lang.String removeSortingID()
public boolean hasMandatorySort()
true if the configuration has anything under the MANDATORY_SORT keypublic com.webobjects.foundation.NSDictionary manadatorySortDictionary()
sortOrders()public java.lang.String manadatorySortKeyPath()
public void containerUpdated()
public java.lang.String initScript()
public java.lang.String dragHeaderOnly()
public java.lang.String afterUpdate()
public java.lang.String enableDragAndDrop()
public com.webobjects.foundation.NSMutableDictionary configurationData()
protected void clearCachedConfiguration()
public boolean canReorder()
true if not
configured.
true if column re-ordering is enabledpublic boolean canResort()
true if not
configured.
true if data sorting is enabledpublic java.lang.String tableID()
|
Last updated: Tue, Feb 21, 2017 05:45 PM CET | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||