This page describes the usage of widgets within the classic UI, which was deprecated in AEM 6.4.
Adobe recommends that you use the modern, touch-enabled UI based on Coral UI and Granite UI.
Adobe Experience Manager’s (AEM) web-based interface uses AJAX and other modern browser technologies to enable WYSIWYG editing and formatting of content by authors right on the web page.
AEM uses the ExtJS widgets library, which provides the highly polished user interface elements that work across all the most important browsers and allow the creation of desktop-grade UI experiences.
These widgets are included within AEM and, in addition to being used by AEM itself, can be used by any website built using AEM.
For a complete reference of all the available widgets in AEM, see the widget API documentation or the list of existing xtypes. In addition, many examples showing how to use the ExtJS framework are available on the Sencha site, the owner of the framework.
This page gives some insights about how to use and extend widgets. It first describes how to include client-sided code in a page. It then describes some sample components that have been created to illustrate some basic use and extension. Those components are available in the Using ExtJS Widgets package on Package Share.
The package includes examples of:
The classic UI of Adobe Experience Manager is built upon ExtJS 3.4.0.
Client sided JavaScript and style sheet code should be placed in a client library.
To create a client library:
Create a node below /apps/<project>
with the following properties:
Note: <category-name> is the name of the custom library (e.g. "cq.extjstraining") and is used to include the library on the page.
Below clientlib
create the css
and js
folders (nt:folder).
Below clientlib
create the css.txt
and js.txt
files (nt:files). Those .txt files list the files that are included in the library.
Edit js.txt
: it must start with ’ #base=js
’ followed by the list of the files that are aggregated by the CQ client library service, for example:
#base=js
components.js
exercises.js
CustomWidget.js
CustomBrowseField.js
InsertTextPlugin.js
Edit css.txt
: it must start with ’ #base=css
’ followed by the list of the files that are aggregated by the CQ client library service, for example:
#base=css
components.css
Below the js
folder, place the JavaScript files that belong to the library.
Below the css
folder, place the .css
files and the resources used by the css files (for example, my_icon.png
).
The handling of style sheets described before is optional.
To include the client library in the page component jsp:
to include both JavaScript code and style sheets:
<ui:includeClientLib categories="<category-name1>, <category-name2>, ..."/>
where <category-nameX>
is the name of the client-sided library.
to only include JavaScript code:
<ui:includeClientLib js="<category-name>"/>
For more details refer to the description of the <ui:includeClientLib> tag.
Sometimes a client library should only be available in author mode and should be excluded in publish mode. It can be achieved as follows:
if (WCMMode.fromRequest(request) != WCMMode.DISABLED) {
%><ui:includeClientLib categories="cq.collab.blog"/><%
}
To follow the tutorials on this page, install the package Using ExtJS Widgets in a local AEM instance and create a sample page in which the components are included. To do so, do the following:
extjstraining
below /apps
in the repository./apps/geometrixx/components/page/headlibs.jsp
and add the cq.extjstraining
category to the existing <ui:includeClientLib>
tag as follows:%><ui:includeClientLib categories="apps.geometrixx-main, cq.extjstraining"/><%
/content/geometrixx/en/products
and call it Using ExtJS Widgets.The examples on this page are based on the Geometrixx sample content, which is no longer shipped with AEM, having been replaced by We.Retail. See the We.Retail Reference Implementation for how to download and install Geometrixx.
Dialogs are typically used to edit content, but can also display information. An easy way to view a complete dialog is to access its representation in json format. To do so, point your browser to:
https://localhost:4502/<path-to-dialog>.-1.json
The first component of the Using ExtJS Widgets group in the Sidekick is called 1. Dialog Basics and includes four basic dialogs that are built with out-of-the-box widgets and without customized JavaScript logic. The dialogs are stored below /apps/extjstraining/components/dialogbasics
. The basic dialogs are:
full
node): it displays a window with three tabs, each tab having two text fields.singlepanel
node): it displays a window with one tab that has two text fields.multipanel
node): its display is the same as the Full dialog but it is built differently.design
node): it displays a window with two tabs. The first tab has a text field, a drop-down menu, and a collapsible text area. The second tab has a field set with four text fields and a collapsible field set with two text fields.Include the 1. Dialog Basics component in the sample page:
The component displays as follows:
The Full dialog displays a window with three tabs, each tab having two text fields. It is the default dialog of the Dialog Basics component. Its characteristics are:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
.cq:Panel
).cq:Widget
, xtype = [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
)./apps/extjstraining/components/dialogbasics/full
https://localhost:4502/apps/extjstraining/components/dialogbasics/full.-1.json
The dialog displays as follows:
The Single Panel dialog displays a window with one tab that has two text fields. Its characteristics are:
cq:Dialog
, xtype = [panel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#panel)
)cq:Widget
, xtype = [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
)/apps/extjstraining/components/dialogbasics/singlepanel
https://localhost:4502/apps/extjstraining/components/dialogbasics/singlepanel.-1.json
To use the Single Panel dialog:
/apps/extjstraining/components/dialogbasics/dialog
/apps/extjstraining/components/dialogbasics/singlepanel
/apps/extjstraining/components/dialogbasics
/apps/extjstraining/components/dialogbasics/Copy of singlepanel
and rename it dialog
.The Multi Panel dialog has the same display as the Full dialog but it is built differently. Its characteristics are:
cq:Dialog
, xtype = [tabpanel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#tabpanel)
).cq:Panel
).cq:Widget
, xtype = [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
)./apps/extjstraining/components/dialogbasics/multipanel
https://localhost:4502/apps/extjstraining/components/dialogbasics/multipanel.-1.json
To use the Multi Panel dialog:
The Rich dialog displays a window with two tabs. The first tab has a text field, a drop-down menu, and a collapsible text area. The second tab has a field set with four text fields and a collapsible field set with two text fields. Its characteristics are:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
).cq:Panel
). [dialogfieldset](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialogfieldset)
widget with a [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
and a [selection](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#selection)
widget with three options, and a collapsible [dialogfieldset](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialogfieldset)
with a [textarea](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textarea)
widget. [dialogfieldset](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialogfieldset)
widget with four [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
widgets, and a collapsible dialogfieldset
with two [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
widgets./apps/extjstraining/components/dialogbasics/rich
https://localhost:4502/apps/extjstraining/components/dialogbasics/rich.-1.json
To use the Rich dialog:
The second component of the Using ExtJS Widgets group in the Sidekick is called 2. Dynamic Dialogs and includes three dynamic dialogs that are built with out-of-the-box widgets and with customized JavaScript logic. The dialogs are stored below /apps/extjstraining/components/dynamicdialogs
. The dynamic dialogs are:
switchtabs
node): it displays a window with two tabs. The first tab has a radio selection with three options: when an option is selected, a tab that relates to the option is displayed. The second tab has two text fields.arbitrary
node): it displays a window with one tab. The tab has a field to drop or upload an asset and a field that displays some information about the containing page and about the asset if one is referenced.togglefield
node): it displays a window with one tab. The tab has a checkbox: when it is checked a field set with two text fields is displayed.To include the 2. Dynamic Dialogs component on the sample page:
The component displays as follows:
The Switch Tabs dialog displays a window with two tabs. The first tab has a radio selection with three options: when an option is selected, a tab that relates to the option is displayed. The second tab has two text fields.
Its main characteristics are:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
).cq:Panel
): one selection tab, the second tab depends on the selection in the first tab (three options).cq:Panel
), each one has two textfields (node type = cq:Widget
, xtype = [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
). Only one optional tab is displayed at a time.switchtabs
node at:/apps/extjstraining/components/dynamicdialogs/switchtabs
https://localhost:4502/apps/extjstraining/components/dynamicdialogs/switchtabs.-1.json
The logic is implemented through event listeners and JavaScript code as follows:
beforeshow
" listener that hides all the optional tabs before the dialog is shown:beforeshow="function(dialog){Ejst.x2.manageTabs(dialog.items.get(0));}"
dialog.items.get(0)
gets the tabpanel
that contains the selection panel and the three optional panels.Ejst.x2
object is defined in the exercises.js
file at:/apps/extjstraining/clientlib/js/exercises.js
Ejst.x2.manageTabs()
method, as the value of index
is -1, all the optional tabs are hidden (i goes from 1 to 3).loadcontent
" event) and one that shows the selected tab when the selection is changed (" selectionchanged
" event):loadcontent="function(field,rec,path){Ejst.x2.showTab(field);}"
selectionchanged="function(field,value){Ejst.x2.showTab(field);}"
Ejst.x2.showTab()
method,field.findParentByType('tabpanel')
gets the tabpanel
that contains all the tabs ( field
represents the selection widget)field.getValue()
gets the value of the selection, for example, tab2Ejst.x2.manageTabs()
displays the selected tab.render
" event:render="function(tab){Ejst.x2.hideTab(tab);}"
Ejst.x2.hideTab()
method,tabPanel
is the tabpanel
that contains all the tabsindex
is the index of the optional tabtabPanel.hideTabStripItem(index)
hides the tabIt displays as follows:
Often a dialog displays content from the underlying component. The dialog described here, called Arbitrary dialog, pulls content from a different component.
The Arbitrary dialog displays a window with one tab. The tab has two fields: one to drop or upload an asset and one that displays some information about the containing page and about the asset if one has been referenced.
Its main characteristics are:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
).tabpanel
widget (node type = cq:Widget
, xtype = [tabpanel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#tabpanel)
) with one panel (node type = cq:Panel
)cq:Widget
, xtype = [smartfile](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#smartfile)
) and an ownerdraw widget (node type = cq:Widget
, xtype = [ownerdraw](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#ownerdraw)
)arbitrary
node at:/apps/extjstraining/components/dynamicdialogs/arbitrary
https://localhost:4502/apps/extjstraining/components/dynamicdialogs/arbitrary.-1.json
The logic is implemented through event listeners and JavaScript code as follows:
ownerdraw
widget has a " loadcontent
" listener that shows information about the page containing the component. That is, the asset referenced by the smartfile widget when the content is loaded:loadcontent="function(field,rec,path){Ejst.x2.showInfo(field,rec,path);}"
field
is set with the ownerdraw
objectpath
is set with the content path of the component (for example, /content/geometrixx/en/products/triangle/ui-tutorial/jcr:content/par/dynamicdialogs
)Ejst.x2
object is defined in the exercises.js
file at:/apps/extjstraining/clientlib/js/exercises.js
Ejst.x2.showInfo()
method,pagePath
is the path of the page containing the component;pageInfo
represents the page properties in json format;reference
is the path of the referenced asset;metadata
represents the metadata of the asset in json format;ownerdraw.getEl().update(html);
displays the created html in the dialogTo use the Arbitrary dialog:
The Toggle Fields dialog displays a window with one tab. The tab has a checkbox: when it is checked a field set with two text fields is displayed.
Its main characteristics are:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
).tabpanel
widget (node type = cq:Widget
, xtype = [tabpanel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textpanel)
) with one panel (node type = cq:Panel
).cq:Widget
, xtype = [selection](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#selection)
, type = [checkbox](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#checkbox)
) and a collapsible dialogfieldset widget (node type = cq:Widget
, xtype = [dialogfieldset](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialogfieldset)
) that is hidden by default, with two textfield widgets (node type = cq:Widget
, xtype = [textfield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#textfield)
).togglefields
node at:/apps/extjstraining/components/dynamicdialogs/togglefields
https://localhost:4502/apps/extjstraining/components/dynamicdialogs/togglefields.-1.json
The logic is implemented through event listeners and JavaScript code as follows:
loadcontent
" event) and one that shows the dialogfieldset when the selection is changed (" selectionchanged
" event):loadcontent="function(field,rec,path){Ejst.x2.toggleFieldSet(field);}"
selectionchanged="function(field,value){Ejst.x2.toggleFieldSet(field);}"
Ejst.x2
object is defined in the exercises.js
file at:/apps/extjstraining/clientlib/js/exercises.js
Ejst.x2.toggleFieldSet()
method,box
is the selection object;panel
is the panel containing the selection and the dialogfieldset widgets;fieldSet
is the dialogfieldset object;show
is the value of the selection (true or false);show
’ the dialogfieldset is displayed or notTo use the Toggle Fields dialog, do the following:
The out-of-the-box widgets shipped with AEM should cover most use cases. However it might be sometimes necessary to create a custom widget to cover a project-specific requirement. Custom widgets can be created by extending existing ones. To help you get started with such customization, the Using ExtJS Widgets
package includes three dialogs that use three different custom widgets:
multifield
node) displays a window with one tab. The tab has a customized multifield widget that has two fields: a drop-down menu with two options and a text field. As it is based on the out-of-the-box multifield
widget (that only has a text field), it has all the features of the multifield
widget.treebrowse
node) displays a window with one tab containing a path browse widget: when you click the arrow, a window opens up in which you can browse a hierarchy and select an item. The path of the item is then added to the path field and is persisted when the dialog is closed.rteplugin
node) that adds a custom button to the Rich Text Editor to insert some custom text to the main text. It consists of a richtext
widget (RTE) and of a custom feature that is added through the RTE plug-in mechanism.The custom widgets and the plugin are included in the component called 3. Custom Widgets of the Using ExtJS Widgets package. To include this component to the sample page:
The Custom Multifield widget-based dialog displays a window with one tab. The tab has a customized multifield widget that, unlike the standard one which has one field, has two fields: a drop-down menu with two options and a text field.
The Custom Multifield widget-based dialog:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
).tabpanel
widget (node type = cq:Widget
, xtype = [tabpanel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#tabpanel)
) containing a panel (node type = cq:Widget
, xtype = [panel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#panel)
).multifield
widget (node type = cq:Widget
, xtype = [multifield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#multifield)
).multifield
widget has a fieldconfig (node type = nt:unstructured
, xtype = ejstcustom
, optionsProvider = Ejst.x3.provideOptions
) that is based on the custom xtype ’ ejstcustom
’:
fieldconfig
’ is a config option of the [CQ.form.MultiField](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.form.MultiField)
object.optionsProvider
’ is a configuration of the ejstcustom
widget. It is set with the Ejst.x3.provideOptions
method which is defined in exercises.js
at:/apps/extjstraining/clientlib/js/exercises.js
multifield
node at:/apps/extjstraining/components/customwidgets/multifield
https://localhost:4502/apps/extjstraining/components/customwidgets/multifield.-1.json
The custom multifield
widget (xtype = ejstcustom
):
Ejst.CustomWidget
CustomWidget.js
JavaScript file at:/apps/extjstraining/clientlib/js/CustomWidget.js
[CQ.form.CompositeField](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.form.CompositeField)
widget.hiddenField
(Textfield), allowField
(ComboBox), and otherField
(Textfield)CQ.Ext.Component#initComponent
to add the three fields:
allowField
is a CQ.form.Selection object of type ‘select’. optionsProvider is a configuration of the Selection object that is instantiated with the optionsProvider configuration of the CustomWidget defined in the dialogotherField
is a CQ.Ext.form.TextField objectsetValue
, getValue
, and getRawValue
of CQ.form.CompositeField to set and retrieve the value of CustomWidget with the format:<allowField value>/<otherField value>, for example: 'Bla1/hello'
.ejstcustom
’ xtype:CQ.Ext.reg('ejstcustom', Ejst.CustomWidget);
The Custom Multifield widget-based dialog displays as follows:
Treebrowse
WidgetThe custom Treebrowse
widget-based dialog displays a window with one tab containing a custom path browse widget. When you select the arrow, a window opens up in which you can browse a hierarchy and select an item. The path of the item is then added to the path field and is persisted when the dialog is closed.
The custom treebrowse
dialog:
cq:Dialog
, xtype = [dialog](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#dialog)
).tabpanel
widget (node type = cq:Widget
, xtype = [tabpanel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#tabpanel)
) containing a panel (node type = cq:Widget
, xtype = [panel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#panel)
).cq:Widget
, xtype = ejstbrowse
)treebrowse
node at:/apps/extjstraining/components/customwidgets/treebrowse
https://localhost:4502/apps/extjstraining/components/customwidgets/treebrowse.-1.json
The custom treebrowse widget (xtype = ejstbrowse
):
Ejst.CustomWidget
CustomBrowseField.js
JavaScript file at:/apps/extjstraining/clientlib/js/CustomBrowseField.js
[CQ.Ext.form.TriggerField](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.form.TriggerField)
.browseWindow
. [CQ.Ext.form.TriggerField](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.form.TriggerField)#onTriggerClick
to show the browse window when the arrow is clicked./bin/wcm/siteadmin/tree.json
.apps/extjstraining
".window
object ( [CQ.Ext.Window](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.Window)
):
show
event.ejstbrowse
’ xtype:CQ.Ext.reg('ejstbrowse', Ejst.CustomBrowseField);
To use the Custom Treebrowse widget-based dialog:
The Rich Text Editor (RTE) Plug-in based dialog is a Rich Text Editor based dialog that has a custom button to insert some custom text within square brackets. The custom text can be parsed by some server-side logic (not implemented in this example), for example to add some text that is defined at the given path:
The RTE plugin based dialog:
/apps/extjstraining/components/customwidgets/rteplugin
https://localhost:4502/apps/extjstraining/components/customwidgets/rteplugin.-1.json
rtePlugins
node has a child node inserttext
(node type = nt:unstructured
) that is named after the plugin. It has a property called features
that defines which of the plugin features are available to the RTE.The RTE plugin:
Ejst.InsertTextPlugin
InsertTextPlugin.js
JavaScript file at:/apps/extjstraining/clientlib/js/InsertTextPlugin.js
[CQ.form.rte.plugins.Plugin](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.form.rte.plugins.Plugin)
object. [CQ.form.rte.plugins.Plugin](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.form.rte.plugins.Plugin)
object and are overridden in the implementing plugin:
getFeatures()
returns an array of all the features that the plugin makes available.initializeUI()
adds the new button to the RTE toolbar.notifyPluginConfig()
displays title and text when the button is hovered.execute()
is called when the button is clicked and performs the plugin action: it displays a window that is used to define the text to be included.insertText()
inserts a text using the corresponding dialog object Ejst.InsertTextPlugin.Dialog
(see afterwards).executeInsertText()
is called by the apply()
method of the dialog, which is triggered when the OK button is clicked.inserttext
’ plugin:CQ.form.rte.plugins.PluginRegistry.register("inserttext", Ejst.InsertTextPlugin);
Ejst.InsertTextPlugin.Dialog
object defines the dialog that is opened when the plugin button is clicked. The dialog consists of a panel, a form, a textfield, and two buttons (OK and Cancel).To use the Rich Text Editor (RTE) Plug-in based dialog:
The Rich Text Editor (RTE) Plug-in based dialog displays as follows:
This example only shows how to implement the client-side part of the logic: the placeholders ([text]) have then to be parsed on the server-side explicitly (for example, in the component JSP).
The out-of-the-box [CQ.Ext.tree.TreePanel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.tree.TreePanel)
object provides tree-structured UI representation of tree-structured data. The Tree Overview component included in the Using ExtJS Widgets package shows how to use the TreePanel
object to display a JCR tree below a given path. The window itself can be docked/undocked. In this example, the window logic is embedded in the component jsp between <script></script> tags.
To include the Tree Overview component to the sample page:
The component displays as follows:
The Tree Overview component:
Is defined at:
/apps/extjstraining/components/treeoverview
The dialog lets you set the size of the window and to dock or undock the window (see details below).
The component jsp:
apps/extjstraining/components/treeoverview/content.jsp
The JavaScript code embedded in the component jsp:
tree
object by trying to retrieve a tree window from the page.treePanel
(CQ.Ext.tree.TreePanel) is created:
treePanel
contains the data that is used to create the window./bin/wcm/siteadmin/tree.json
beforeload
listener makes sure that the selected node is loaded.root
object sets the path apps/extjstraining
as the tree root.tree
( [CQ.Ext.Window](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.Window)
) is set based on the pre-defined treePanel
, and is displayed with:tree.show();
The component dialog:
cq:Dialog
, xtype = [panel](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#panel)
).cq:Widget
, xtype = [sizefield](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#sizefield)
) and a selection widget (node type = cq:Widget
, xtype = [selection](/docs/experience-manager-65/developing/components/classic-ui-components/xtypes.md#selection)
, type = radio
) with two options (true/false)/apps/extjstraining/components/treeoverview/dialog
https://localhost:4502/apps/extjstraining/components/treeoverview/dialog.-1.json
A Grid Panel represents data in a tabular format of rows and columns. It is composed of the following:
The Grid Overview component included in the Using ExtJS Widgets package shows how to display data in a tabular format:
To include the Grid Overview component to the sample page:
The component displays as follows:
In its out-of-the-box version, the Grid Overview component displays a window with static data in a tabular format. In this example, the logic is embedded in the component jsp in two ways:
The Grid Overview component:
/apps/extjstraining/components/gridoverview
The component jsp:
<script type="text/javascript" src="/apps/extjstraining/components/gridoverview/defaultgrid.js"></script>
defaultgrid.js
defines some static data as a base for the GridPanel object.apps/extjstraining/components/gridoverview/content.jsp
The JavaScript code embedded in the component jsp:
grid
object by trying to retrieve the window component from the page:var grid = CQ.Ext.getCmp("<%= node.getName() %>-grid");
grid
does not exist, a CQ.Ext.grid.GridPanel object ( gridPanel
) is defined by calling the getGridPanel()
method (see below). This method is defined in defaultgrid.js
.grid
is a [CQ.Ext.Window](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.Window)
object, based on the pre-defined GridPanel, and is displayed: grid.show();
grid
exists, it is displayed based on the width, height, and docked properties retrieved from the repository.The JavaScript file ( defaultgrid.js
) referenced in the component jsp defines the getGridPanel()
method which is called by the script embedded in the JSP and returns a [CQ.Ext.grid.GridPanel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.GridPanel)
object, based on static data. The logic is as follows:
myData
is an array of static data formatted as a table of five columns and four rows.store
is a CQ.Ext.data.Store
object that consumes myData
.store
is loaded in memory:store.load();
gridPanel
is a [CQ.Ext.grid.GridPanel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.GridPanel)
object that consumes store
:
forceFit: true
singleSelect:true
When you install the package, the content.jsp
of the Grid Overview component displays a grid that is based on static data. It is possible to modify the component to display a grid with the following characteristics:
test
property below the node defined by the path displayed in the first column.As explained in the section before, the window object gets its [CQ.Ext.grid.GridPanel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.GridPanel)
object by calling the getGridPanel()
method defined in the defaultgrid.js
file at /apps/extjstraining/components/gridoverview/defaultgrid.js
. The **Grid Overview **component provides a different implementation for the getGridPanel()
method, defined in the referencesearch.js
file at /apps/extjstraining/components/gridoverview/referencesearch.js
. By switching the .js file that is referenced in the component jsp, the grid is based on data retrieved from the repository.
Switch the .js file that is referenced in the component jsp:
content.jsp
file of the component, comment the line that includes the defaultgrid.js
file, so that it looks as follows:<!-- script type="text/javascript" src="/apps/extjstraining/components/gridoverview/defaultgrid.js"></script-->
referencesearch.js
file, so that it looks as follows:<script type="text/javascript" src="/apps/extjstraining/components/gridoverview/referencesearch.js"></script>
The component displays as follows:
The JavaScript code referenced in the component jsp ( referencesearch.js
) defines the getGridPanel()
method called from the component jsp and returns a [CQ.Ext.grid.GridPanel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.GridPanel)
object, based on data that are dynamically retrieved from the repository. The logic in referencesearch.js
defines some dynamic data as a base for the GridPanel:
reader
is a [CQ.Ext.data.JsonReader](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.data.JsonReader)
object that reads the servlet response in json format for three columns.cm
is a [CQ.Ext.grid.ColumnModel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.ColumnModel)
object for three columns.editor: new [CQ.Ext.form.TextField](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.form.TextField)({})
cm.defaultSortable = true;
store
is a [CQ.Ext.data.GroupingStore](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.data.GroupingStore)
object:
/bin/querybuilder.json
" with a few parameters used to filter the queryreader
, defined beforehandgridPanel
is a [CQ.Ext.grid.EditorGridPanel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.EditorGridPanel)
object that can be edited:
store
and on the column model cm
sm: new [CQ.Ext.grid.RowSelectionModel](https://developer.adobe.com/experience-manager/reference-materials/6-5/widgets-api/index.html?class=CQ.Ext.grid.RowSelectionModel)({singleSelect:true})
afteredit
listener makes sure that after a cell in the “Test” column has been edited:
test
’ of the node at the path defined by the “jcr:path” column is set in the repository with the value of the cellstore
object, otherwise it is rejected