| com.sun.rave.web.ui.component.TableBase
All known Subclasses: com.sun.rave.web.ui.component.Table,
TableBase | abstract public class TableBase extends javax.faces.component.UIComponentBase (Code) | | Use the ui:table
tag to create a table that can be configured to perform actions on
objects in the table, and to manipulate the rows and columns of the
table. The table component features behaviors that let the user sort,
filter, and paginate the table objects, and provides actions that can
be performed on selected objects. The component also allows you to
implement developer-defined custom actions.
Note that the ui:table
tag is not intended to be used to create HTML tables that are used
purely to handle page layout. The
table component renders a
table with
a well-defined structure, including a title, column headings, and
borders. You can use tags
such as ui:propertySheet
and ui:panelGroup
for page
layout if
possible.
The table component
implements Sun's user interface (UI) guidelines for web
applications. The guidelines describe in detail how the table should
appear and behave, including the placement of titles, group headers,
and actions. The table component's default behavior implements the UI
guidelines. The component is also extensible through JavaServer Faces
facets to
allow the component to be used for tables that do not need to adhere
strictly to the UI guidelines.
The ui:table
tag must be used with the ui:tableRowGroup
and ui:tableColumn
tags. The ui:table
tag is
used to define the structure and actions of the table, and is a
container for ui:tableRowGroup
tags. The ui:tableRowGroup tag is used to define
the rows of the table, and is a container for ui:tableColumn
tags. The ui:tableColumn tag is used to define the
columns of the table.
HTML Elements and Layout
The table component renders
an XHTML <table> element. Depending upon the
attributes specified with the ui:table tag, the table
component can also render a title in a <caption>
element, and image hyperlinks for the various buttons for sorting and
pagination. The table component does not render table rows except
for
the rows that contain
the view-changing and pagination controls.
Table Structure
Tables are composed of several
discrete areas. You can use
ui:table tag attributes to cause the table component to
create the default layout for each
area. The default layout strictly adheres to UI guidelines. The
layout for
each area can also be customized by using facets. Some areas
require you to use facets to implement the content you want in those
areas. Descriptions of
the table areas are shown below, followed by a diagram
that shows the placement of the areas.
-
Title - displays a title for the table,
which you can also use to include information about paginated rows and
applied
filters. Use the title attribute to specify the title
content. Use the itemsText attribute to specify the text
displayed for the table title for an unpaginated table. Use
the filterText
attribute to specify text to include in the title about the filter that
is applied. You
can override the default implementation of the
title bar
with a different component by using the title
facet.
-
Action Bar (top) - in the first row of the table, displays
controls that operate on the
table and its data. This area contains the following sub areas:
-
View-Changing
Controls - displays controls for changing the view of the
table data, such as custom filtering and sorting. This area
contains the following sub areas:
-
Filter - displays a drop down menu of filter options,
which allow users to select criteria to be used to determine the items
to display. The component provides a default implementation for adding
options when the Custom filter becomes active, to display the filter
panel, etc. However, you must implement your filters
through custom options. An example
filter is shown in Filter.java.
- Clear Sort - displays a button that is used to remove
all sorting of the table. Use the
clearTableSortButton
attribute to display the clear table sort button.
-
Sort
- displays a
toggle button for the sort panel. Clicking this button
opens and closes an embedded panel with custom sort
options. The panel
opens inside the table below the Action Bar (top). Use the sortPanelToggleButton
attribute
to display the default sort button with a default
layout of the sort panel. You can
provide custom content for the sort panel by using the sortPanel
facet.
-
Preferences
- displays a toggle button for setting the
user's preferences. Clicking this
button opens and closes an embedded
panel with view preferences. The preferences panel opens inside
the table below
the Action Bar (top). You must provide the content of
the preferences panel by using the preferencesPanel
facet. There is no
default implementation of the preferences panel content, and therefore
no attribute to specify that the button should be displayed.
-
Vertical Pagination - The Vertical Pagination area displays a
paginate button, which allows users to switch between viewing the table
as multiple pages, or as a single scrolling page. You can specify
the paginateButton attributes to display the
default paginate button. Note that the Vertical
Pagination area is limited to this button. You cannot use extra
pagination controls in this area, as you can in the bottom Pagination
area.
-
Action Bar (bottom)
-
Actions - displays local actions that apply to
the objects in the table. You must provide the implementation for each
table action, by using the actionsBottom facet . The
same actions can exist for the Table both the "Action
Bar
(top)" and "Action Bar
(bottom)" sections
-
Pagination Controls
- displays controls for pagination, including the
paginate button, which allows users to switch between viewing the table
as multiple pages, or as a single scrolling page. The Pagination area
also includes buttons for turning the pages in sequence, jumping to a
specific page, and jumping to the first or last page. You can specify
the paginateButton and paginateControls
attributes to display the default layout of the Pagination area.
-
Footer - displays a footer across all columns at the
bottom of the table. You can specify the footerText
attribute to display footer content with a default layout, or specify a
component for the footer by using the footer facet.
The
following diagram shows
the relative location of the table areas and facets that can be used
for each area. The areas that are specified with the ui:table
tag attributes are highlighted in blue. The grayed
out area
is controlled with ui:tableRowGroup and ui:tableColumn
tags, but is shown here for context.
Title
Bar title
|
Action
Bar (top)
Actions actionsTop |
View-Changing Controls
Filter
filter |
Sort
|
Clear Sort |
Preferences |
|
Vertical
Pagination
|
Embedded
Panels filterPanel sortPanel preferencesPanel |
|
Column
Header
|
Column
Header
|
Group
Header Bar |
Table
data
|
Table
data
|
Column
Footer |
Column
Footer
|
Group
Footer Bar
|
Table
Column Footer |
Table
Column Footer |
Action
Bar (bottom)
Actions actionsBottom
|
Pagination Controls
|
|
|
Footer
|
Buttons and Controls
The following attributes can
be specified to add buttons and controls to the table:
-
clearSortButton adds a button to the View-Changing
Controls area that clears any sorting of the
table.
-
deselectMultipleButton adds a button for
tables in which multiple rows can be
selected, to allow users to deselect all table rows that are currently
displayed.
-
deselectSingleButton adds a button for tables in
which only a single table row
can be selected at a time, to allow users to deselect a column of radio
buttons
-
paginateButton adds a button
to allow users to switch between
viewing all data on a single page (unpaginated) or to see data in
multiple pages (paginated).
-
paginationControls adds table
pagination controls to allow users to change which page is
displayed.
-
selectMultipleButton adds a button that is used
for selecting multiple rows.
-
sortPanelToggleButton adds a button that is
used to open and close the sort panel.
Cell Spacing and Shading
The following attribute can be
specified to change the spacing and shading weight of the table:
-
cellPadding specifies the amount of
whitespace that
should be placed between the cell contents and the cell borders in all
the cells of the table.
-
cellSpacing specifies the amount of
whitespace
that should be placed between cells, and between the edges of the table
content area and the sides of the table.
-
lite renders the table in a style
that makes the table look lighter weight.
Headers
The table component allows
for multiple headers. The following types of headers are supported:
- Column header - confined to the column for which
it is defined, and displayed by default at the top of the
table,
below the Action Bar and above all row groups. Column headers are
controlled with
attributes in the
ui:tableColumn tag. User interface
guidelines recommend
that column headers are rendered once for each table. In tables with
multiple groups, the column headers should be defined in the ui:tableColumn
tags that are contained in the first ui:tableRowGroup
tag.
See the ui:tableColumn
documentation for more
information.
- Group header - spans across all table columns,
and is displayed above each row group. The first group header is
displayed below the column headers, above the table data. Group
headers for any other groups specified in the table are displayed above
the data rows for the group. Group headers are set in the
ui:tableRowGroup
tag. See the ui:tableRowGroup
documentation for more
information.
Footers
The table component allows
for multiple footers. The following types of footers are supported:
-
Footer - spans the full
width of the table, and displayed at the bottom of the table. Only one
table footer is displayed in each table. The table footer is
defined in the ui:table tag.
-
Column footer - confined to the
column for which it is defined, and displayed by default at the bottom
of the column. In tables with multiple groups of rows, each group can
display its own column footer. The column footer is defined in ui:tableColumn
tags. See the ui:tableColumn
documentation for more
information.
-
Table column footer -
confined to the column for which
it is defined, and displayed by default near the bottom of the table,
below all row groups, and above the Action Bar (bottom). User interface
guidelines recommend
that table column footers are rendered once for each table. In tables
with multiple groups, the table column footers should be defined in the
ui:tableColumn tags that are contained in the first ui:tableRowGroup
tag. See the ui:tableColumn
documentation for more
information.
Facets
The ui:table tag supports the following facets, which
allow you to customize the
layout of the component.
Facet
Name
|
Table Item
Implemented by the Facet
|
actionsBottom |
Actions area of
the Action Bar (bottom).
|
actionsTop |
Actions area of
the Action Bar (top).
|
filter |
Drop down menu for
selecting a filter, in the Filter area of the Action Bar
(top).
|
filterPanel |
Embedded panel for
specifying custom filter options, which is displayed when user selects
the Custom Filter option from the filter drop down menu. The
Custom Filter option is a recommended option that you can provide in
the drop down component that you specify in the filter
facet. The Custom Filter can be used to give users greater
control over filtering. The Filter
example
explains filters in more detail.
|
footer |
Footer that spans
the
width of the table.
|
preferencesPanel |
Panel displayed when
the preferences
toggle button is
clicked, to allow users to specify
preferences for viewing the table.
|
sortPanel |
Panel displayed when
the sort toggle
button is clicked, to
allow users to specify sort
options.
|
title |
Title in the top bar
of
the table.
|
Client-side
JavaScript
Functions
The following JavaScript
functions are available in any page that uses the ui:table
tag. After the table is rendered, the functions you specify in the JSP
page can be invoked directly on the rendered HTML elements. For
example:
var table =
document.getElementById("form1:table1");
var count = table.getAllSelectedRowsCount();
Note:
To use the JavaScript functions, formElements.js file
must be included in the page. The file is automatically included
by
the basic components such as the button and dropDown components.
Function
Name
|
Purpose
|
confirmSelectedRows(message)
|
Confirm the number of
selected rows affected by an action such as edit, archive, etc. |
confirmDeleteSelectedRows() |
Confirm the number of
selected rows affected by a delete action. |
filterMenuChanged() |
Toggle the filter panel when the user selects Custom
Filter in the Filter menu.
|
getAllSelectedRowsCount() |
Get the number of
selected rows in the table, including the rows that are rendered
in the
current page, and rows that are hidden from view on other pages.
|
getAllHiddenSelectedRowsCount() |
Get the number of
selected rows in the table that are on pages that are not currently
displayed.
|
getAllRenderedSelectedRowsCount() |
Get the number of
selected rows
that are currently rendered in the table. This function does not count
the rows that are hidden from view on other pages. Note that rows might
be rendered but not visible, and invisible rows are counted. See
the description of the visible and rendered attributes.
|
initAllRows() |
Initialize all rows displayed
in the table when the state
of selected components change,
such as when checkboxes or radiobuttons are used to select or deselect
all rows.
|
toggleFilterPanel() |
Open and close the custom filter
panel. |
togglePreferencesPanel() |
Open and close the table
preferences panel. |
Notes about ui:table tag
Life Cycle
See the Lifecycle
description in
the documentation for the ui:tableRowGroup component.
Layout
Tables
You should not use the ui:table tag for page layout. The table
component renders elements for a table title, columns headers, and row
headers. These elements should not be used in a layout table, and
create an
accessibility issue. Use a standard HTML <table> element, a ui:propertySheet tag, or the JavaServer Faces h:dataTable tag to perform page layout. If
your application needs to iterate over the same components as in
jato:tiledView, use a custom tag. The JSP Standard Tag Library
(JSTL) forEach tag might also be useful, but there are
interoperability issues with JSTL and JavaServer Faces, so use with
caution.
Nested Tables
Although it is technically
possible to nest tables with the ui:tabl e tag, you should
not use the table component to layout multiple tables for the following
reasons:
-
Nested tables create
accessibility issues, as described in Layout
Tables.
-
UI guidelines do not
support nested tables.
-
Styles used by the
table component might not display properly because they are not
intended to be nested.
-
Table sorting is not
supported in nested tables. The table component does not
support complex components that maintain state not defined by the
JavaServer Faces EditableValueHolder interface. Since a
single
component instance is
used when iterating over DataProvider rows, only the state of an EditableValueHolder
can be maintained.
If you need to display similar
types of data using the same table
layout, you should use a group table. Sorting is supported for group
tables because they are
configured using separate tableRowGroup instances.
Validation
To maintain state, the table
component submits the surrounding form.
For example, when the table is sorted, the form is submitted to update
checkbox values. Likewise, the form might be submitted to update text
field values when the table component must display a new page of a
paginated table. These components cannot be updated if validation
fails for any reason. If a component requires a value to be entered,
and no value is entered, validation fails.
Consider the case where a
required text field and
table
appear on the same page. If the user clicks on a table sort button
while the required text field has no value, the sort action is never
invoked because a value was required and validation failed.
To prevent this validation issue,
you can do either of the following:
- Place the table and the required component in separate forms, to
allow the table data to be submitted separately from the required
field. The table can then be sorted without triggering a validation
failure on a required text field that has no value because the text
field's form is not submitted. However, the values of one form
are lost when the other form is submitted, which is expected HTML
behavior. In this example, if a user places a value in a required text
field and then sorts the table, the value in the text field is
lost.
- Place the table in a virtual
form by setting the
internalVirtualForm
method of the Table component to true. For example:
// Set table component.
public void setTable(Table table) {
this.table = table;
// This binding is used only
for the internal virtual form example.
table.setInternalVirtualForm(true);
}
A virtual form allows the table data to be
submitted separately from the
other components on the page, just as using two separate HTML forms
would allow. Placing
the table in a virtual form allows the table sort action to complete
because validation for the required text field is not processed. This
behavior is similar to that caused by setting the immediate
property of a
button, but allows
table children to be updated so that selected checkbox values may be
sorted, for example. The
advantage to using a virtual form is that the values of the other
components on the page are not lost when table data is submitted.
Value
Bindings
Value
expressions that use DataProviders must use the following syntax:
#{sourceVar['PERSON.NAME']}
#{sourceVar.value['PERSON.NAME']}
Note
that the word value is between the DataProvider and the
FieldKey to bind. The brackets [] are required
only if the FieldKey contains dot syntax.
For example:
- To
bind to a FieldKey named
last , where the sourceVar
property of the table component is names :
#{names.value.last}
- To
bind to a property named
test , where the backing bean is
named TableBean .
#{TableBean.test}
Method
Bindings
A JavaServer Faces issue prevents
method bindings from
working in a DataProvider. To work around the issue, you can bind to a
method in a backing bean, and use that method to retrieve values from
the DataProvider.
For example, the
following
syntax to bind to a DataProvider does not work:
<ui:hyperlink text="#{name.last}" action="#{name.action}"/>
Instead of using a DataProvider to handle the action (which breaks the
MVC paradigm), bind the action to a method in the backing bean. For
example:
<ui:hyperlink text="#{name.last}"
action="#{TableBean.action}"/>
In the TableBean.action method, you may invoke the
following code to
retrieve values from the DataProvider:
public String action() {
FacesContext context =
FacesContext.getCurrentInstance();
ValueBinding vb =
context.getApplication().createValueBinding("#{name.first}");
String first = (String) (vb.getValue(context));
return "whatever";
}
If you have an instance of the DataProvider, you can also invoke the
following code to retrieve values:
public String action() {
FacesContext context =
FacesContext.getCurrentInstance();
ValueBinding vb =
context.getApplication().createValueBinding("#{name.tableRow}");
RowKey row = (RowKey) (vb.getValue(context));
String first = (String)
provider.getFieldKey("first"), row)
}
Logging
To see messages logged by the table component, set the following global
defaults in your JDK's "jre/lib/logging.properties" file.
Alternatively, you can use a different file by specifying a filename
with the java.util.logging.config.file system property (e.g., setenv
CATALINA_OPTS -Djava.util.logging.config.file=myFile).
java.util.logging.ConsoleHandler.level = FINE
com.sun.rave.web.ui.event.TablePaginationActionListener.level = FINE
com.sun.rave.web.ui.event.TableSelectPhaseListener.level = FINE
com.sun.rave.web.ui.event.TableSortActionListener.level = FINE
com.sun.rave.web.ui.component.Table.level = FINE
com.sun.rave.web.ui.component.TableActions.level = FINE
com.sun.rave.web.ui.component.TableColumn.level = FINE
com.sun.rave.web.ui.component.TableFooter.level = FINE
com.sun.rave.web.ui.component.TableHeader.level = FINE
com.sun.rave.web.ui.component.TablePanels.level = FINE
com.sun.rave.web.ui.component.TableRowGroup.level = FINE
com.sun.rave.web.ui.renderer.TableActionsRenderer.level = FINE
com.sun.rave.web.ui.renderer.TableColumnRenderer.level = FINE
com.sun.rave.web.ui.renderer.TableFooterRenderer.level = FINE
com.sun.rave.web.ui.renderer.TableHeaderRenderer.level = FINE
com.sun.rave.web.ui.renderer.TablePanelsRenderer.level = FINE
com.sun.rave.web.ui.renderer.TableRenderer.level = FINE
com.sun.rave.web.ui.renderer.TableRowGroupRenderer.level = FINE
Examples
The following examples use a
backing bean called TableBean
and some
utility classes, which are
included after the examples.
Additional examples are shown in the ui:tableRowGroup
and ui:tableColumn
documents.
Examples in this file:
Supporting files:
Example 1: Basic Table
This example shows how to create a basic
table.
<!-- Basic Table -->
<ui:table id="table1" title="Basic Table">
<ui:tableRowGroup id="rowGroup1"
sourceData="#{TableBean.groupB.names}"
sourceVar="name">
<ui:tableColumn id="col1"
alignKey="last"
headerText="Last Name" rowHeader="true">
<ui:staticText
text="#{name.value.last}"/>
</ui:tableColumn>
<ui:tableColumn id="col2" alignKey="first"
headerText="First Name">
<ui:staticText
text="#{name.value.first}"/>
</ui:tableColumn>
</ui:tableRowGroup>
</ui:table>
Example 2:
Custom Title
This example shows how
to
create a custom title for a table, using the
title
facet. When
you
use the
title
attribute as shown in the BasicTable
example, the
component provides a default title implementation which can include
information regarding paginated rows and applied
filters. This example implements the title with a ui:staticText
tag in
the title facet.
<!-- Custom Title -->
<ui:table id="table1">
<ui:tableRowGroup id="rowGroup1"
sourceData="#{TableBean.groupB.names}"
sourceVar="name">
<ui:tableColumn id="col1"
alignKey="last"
headerText="Last Name" rowHeader="true">
<ui:staticText
text="#{name.value.last}"/>
</ui:tableColumn>
<ui:tableColumn id="col2" alignKey="first"
headerText="First Name">
<ui:staticText
text="#{name.value.first}"/>
</ui:tableColumn>
</ui:tableRowGroup>
<!-- Title -->
<f:facet name="title">
<ui:staticText text="Custom Title"/>
</f:facet>
</ui:table>
Example 3: Paginated Table
This example shows how to create a paginated
table. The default number of rows to be displayed for a paginated table
is 25 per page. You
can override this value with
the
rows attribute in
the ui:tableRowGroup tag.
Note: The rows attribute is used only for paginated tables.
<!-- Paginated Table -->
<ui:table id="table1"
paginateButton="true"
paginationControls="true"
title="Paginated Table">
<ui:tableRowGroup id="rowGroup1"
sourceData="#{TableBean.groupA.names}"
sourceVar="name" rows="5">
<ui:tableColumn id="col1"
alignKey="last"
headerText="Last Name" rowHeader="true">
<ui:staticText
text="#{name.value.last}"/>
</ui:tableColumn>
<ui:tableColumn id="col2" alignKey="first"
headerText="First Name">
<ui:staticText
text="#{name.value.first}"/>
</ui:tableColumn>
</ui:tableRowGroup>
</ui:table>
Example 4: Sort Panel
This example shows how to add
the sort panel. You
can use the
default sort panel by setting the
sortPanelToggleButton
attribute to true. This button opens an embedded panel in the table,
displaying a default implementation. The default
implementation shows
one, two, or three drop down menus that represent the primary,
secondary, and
tertiary sorts. The menus
list the column headers for each sortable column. If a column is not
sortable, it is not shown as a sortable option. If there are
only two sortable columns, only the primary and secondary drop down
menus are shown. If there is only one sort, only the
primary drop down menu is shown. Next to each sort menu is a menu to
select ascending or descending sort order.
<!-- Sort Panel -->
<ui:table id="table"
clearSortButton="true"
sortPanelToggleButton="true"
title="Sort Panel">
<!-- Insert tableRowGroup tag here -->
</ui:table>
To override the default sort panel, use the sortPanel
facet. The sort panel toggle
button is shown when you use the facet, so you do not
need to specify the sortPanelToggleButton
attribute.
Example 5: Table Preferences
This example shows how
to add the preferences toggle button and the table panel. The
preferences panel toggle button is
shown only when you use the preferencesPanel
facet.
The button opens an embedded panel in the table, displaying the
contents that you provide in the preferencesPanel facet.
In this example, the preferences panel is used to set
the number
of paginated rows with the rows attribute of ui:tableRowGroup .
See the Preferences.java example
utility class, which provides functionality for preferences for
this example.
<!-- Preferences -->
<ui:table id="table1" paginationControls="true"
title="Preferences">
<ui:tableRowGroup id="rowGroup1"
rows="#{TableBean.groupA.preferences.rows}"
sourceData="#{TableBean.groupA.names}"
sourceVar="name">
<ui:tableColumn id="col1"
alignKey="last"
headerText="Last Name" rowHeader="true">
<ui:staticText
text="#{name.value.last}"/>
</ui:tableColumn>
<ui:tableColumn id="col2" alignKey="first"
headerText="First Name">
<ui:staticText
text="#{name.value.first}"/>
</ui:tableColumn>
</ui:tableRowGroup>
<!-- Preferences Panel -->
<f:facet name="preferencesPanel">
<f:subview id="preferencesPanel">
<jsp:include
page="preferencesPanel.jsp"/>
</f:subview>
</f:facet>
</ui:table>
preferencesPanel.jsp
This example shows the contents of the preferencesPanel.jsp
file included in the JSP page example above.
<!-- Preferences Panel -->
<ui:textField id="rows"
columns="5"
label="Rows Per Page:"
labelLevel="2"
onKeyPress="if (event.keyCode==13) {var
e=document.getElementById('form1:table1:preferencesPanel:submit'); if
(e != null) e.click(); return false}"
text="#{TableBean.groupA.preferences.preference}"/>
<ui:markup tag="div" styleClass="TblPnlBtnDiv">
<ui:button id="submit"
action="#{TableBean.groupA.preferences.applyPreferences}"
mini="true"
primary="true"
text="OK"/>
<ui:button id="cancel"
mini="true"
onClick="togglePreferencesPanel();
return false"
text="Cancel"/>
</ui:markup>
<!-- Note: If the user presses the enter key while the text field
has focus,
the page will be submitted incorrectly, unless
we capture the onKeyPress
event and invoke the click method of the
submit button. -->
preferences.js
This example shows the contents of the preferences.js file used in the tablePreferencesPanel.jsp
example
above. The togglePreferencesPanel() JavaScript function
is used with
the onClick attribute of a ui:button tag.
// Use this function to toggle the preferences panel open or
closed. This
// functionality requires the filterId of the table component to be set.
function togglePreferencesPanel() {
var table = document.getElementById("form1:table1");
table.togglePreferencesPanel();
}
Example 6: Table Filter
This example shows how to add filters using a filter drop down
menu and the filter panel. In this example, the filter
panel is used to set a custom filter.
The custom filter removes all rows from the view that do not match the
given last name. See the Filter.java
example, which provides the functionality for filters for
this example.
Basic
filters
are filters that
you define for the users of your application. Custom filters enable
users to specify the data to be used by the table component to
determine which table entries to display. You specify the basic
filter names as items in a ui:dropDown
tag in the filter
facet. If you want to allow users to use a custom filter, include a
"Custom Filter" item as one of the ui:dropDown
items.
If you
include a "Custom Filter" item in
the Filter drop down menu, you can allow users to
open a filter panel to filter the table data using a custom
filter. When the Custom
Filter option is selected, an embedded panel in the table is
opened,
displaying the contents that you provide in the filterPanel
facet. The default
custom filter functionality requires you to use the
filterMenuChanged JavaScript function for the onChange
event in the ui:dropDown tag. After the custom
filter is
applied, you should display a non-selectable "Custom
Filter Applied" item in
the
filter drop down menu,
to indicate that a custom filter has been applied. You should also set
the filterText attribute. The table component updates the
table title to
indicate that a basic or custom
filter has been applied by inserting the text <filterText> Filter Applied.
The
default
custom filter
functionality depends on a specific value assigned to the
Custom Filter item in the dropDown component. The table component
provides a method named getFilterOptions() to add the
item text and value for the custom filter option to the drop down list.
You can use getFilterOptions() in your backing
bean to append either the
"Custom Filter" or "Custom Filter Applied" item to the basic filter
items.
In the Filter.java
util example, the
"Custom Filter" and "Custom Filter Applied" items are
assigned
based on the
boolean value
provided
to getFilterOptions( ) . If
this value is true,
the
"Custom Filter Applied" item value is added. If the value is false,
"Custom Filter" item value is added. The filterMenuChanged
JavaScript function, assigned to the dropDown component's onChange
event, behaves differently depending on
which item is added. See the comments in filters.js for
more information.
The
default custom filter functionality
also depends on the id of the
ui:dropDown tag in the filter
facet. Note that if you use the ui:dropDown tag as the
only component
in the filter facet, the filterId is optional. If you use
a custom
component, or use the ui:dropDown as a child component,
you must
specify a filterID.
The table
implements functionality to reset the dropDown menu. If you
use the filterId attribute, the menu can be reset
whenever the sort and preferences toggle buttons are clicked. You can
also use the filterMenuChanged JavaScript function to reset the menu at
some other time. Note:
This functionality requires the selected value of the ui:dropDown
tag to be set in order
to
restore the default selected value when the embedded filter panel is
closed.
The filter
code can be placed in a util class, as shown in the Filter.java example, or in a backing bean.
<!-- Filter -->
<ui:table id="table1"
filterText="#{TableBean.groupA.filter.filterText}"
paginateButton="true"
paginationControls="true"
title="Filter">
<ui:tableRowGroup id="rowGroup1"
binding="#{TableBean.groupA.tableRowGroup}"
rows="5"
sourceData="#{TableBean.groupA.names}"
sourceVar="name">
<ui:tableColumn id="col1"
alignKey="last"
headerText="Last Name" rowHeader="true">
<ui:staticText
text="#{name.value.last}"/>
</ui:tableColumn>
<ui:tableColumn id="col2" alignKey="first"
headerText="First Name">
<ui:staticText
text="#{name.value.first}"/>
</ui:tableColumn>
</ui:tableRowGroup>
<!-- Filter -->
<f:facet name="filter">
<ui:dropDown submitForm="true" id="filter"
action="#{TableBean.groupA.filter.applyBasicFilter}"
items="#{TableBean.groupA.filter.filterOptions}"
onChange="if
(filterMenuChanged() == false) return false"
selected="#{TableBean.groupA.filter.basicFilter}"/>
</f:facet>
<!-- Filter Panel -->
<f:facet name="filterPanel">
<f:subview id="filterPanel">
<jsp:include
page="filterPanel.jsp"/>
</f:subview>
</f:facet>
</ui:table>
filterPanel.jsp
This example shows the contents of the filterPanel.jsp file included in the JSP page in
the example above.
<!-- Filter Panel -->
<ui:textField id="customFilter"
columns="50"
label="Show only rows containing last name:"
labelLevel="2"
onKeyPress="if (event.keyCode==13) {var
e=document.getElementById('form1:table1:filterPanel:submit'); if (e !=
null) e.click(); return false}"
text="#{TableBean.groupA.filter.customFilter}"/>
<ui:markup tag="div" styleClass="TblPnlBtnDiv">
<ui:button id="submit"
action="#{TableBean.groupA.filter.applyCustomFilter}"
mini="true"
primary="true"
text="OK"/>
<ui:button id="cancel"
mini="true"
onClick="toggleFilterPanel(); return
false"
text="Cancel"/>
</ui:markup>
<!-- Note: If the user presses the enter key while the text field
has focus,
the page will be submitted incorrectly, unless
we capture the onKeyPress
event and invoke the click method of the
submit button. -->
filters.js
This example shows the contents of the filters.js file used in the filterPanel.jsp
example above. The toggleFilterPanel()
JavaScript function is used with the onClick attribute of
a ui:button tag to allow the user to close the
filter panel without specifying a filter.
// Toggle the filter panel from the filter menu.
//
// If the "Custom Filter" option has been selected, the filter panel is
// toggled. In this scenario, false is returned indicating the onChange
event,
// generated by the filter menu, should not be allowed to continue.
//
// If the "Custom Filter Applied" option has been selected, no action
is taken.
// Instead, the filter menu is reverted back to the original selection.
In this
// scenario, false is also returned indicating the onChange event,
generated by
// the filter menu, should not be allowed to continue.
//
// For all other selections, true is returned indicating the onChange
event,
// generated by the filter menu, should be allowed to continue.
function filterMenuChanged() {
var table = document.getElementById("form1:table1");
return table.filterMenuChanged();
}
// Use this function to toggle the filter panel open or closed. This
// functionality requires the filterId of the table component to be
set. In
// addition, the selected value must be set as well to restore the
default
// selected value when the embedded filter panel is closed.
function toggleFilterPanel() {
var table = document.getElementById("form1:table1");
table.toggleFilterPanel();
}
Example 7: Table Actions
This example shows how to add
actions to a table by using the actionsTop
and actionsBottom
facets. Four buttons and a drop down menu are added to the Action Bar
(top) and Action Bar (bottom). When the page is initially
displayed, all actions
are disabled. When the user selects at least one checkbox, the actions
are enabled. If the user deselects all checkboxes, the actions are
disabled again.
Note that this example defines a
JavaScript function called disableActions , which is shown in actions.js.
The disableActions function is
defined by the developer, and is not part of the table component.
When the
user clicks on a checkbox, a JavaScript disableActions
function is invoked
with the onClick event. The JavaScript setTimeout
function
is used to ensure checkboxes are selected immediately, instead of
waiting for
the JavaScript function to complete.
See the Actions.java example, which
provides functionality for table actions in this example.
<!-- Actions -->
<ui:table id="table1"
deselectMultipleButton="true"
deselectMultipleButtonOnClick="setTimeout('disableActions()', 0)"
paginateButton="true"
paginationControls="true"
selectMultipleButton="true"
selectMultipleButtonOnClick="setTimeout('disableActions()', 0)"
title="Actions">
<ui:tableRowGroup id="rowGroup1"
binding="#{TableBean.groupA.tableRowGroup}"
rows="5"
selected="#{TableBean.groupA.select.selectedState}"
sourceData="#{TableBean.groupA.names}"
sourceVar="name">
<ui:tableColumn id="col0"
selectId="select"
sort="#{TableBean.groupA.select.selectedState}">
<ui:checkbox id="select"
onClick="setTimeout('initAllRows(); disableActions()', 0)"
selected="#{TableBean.groupA.select.selected}"
selectedValue="#{TableBean.groupA.select.selectedValue}"/>
</ui:tableColumn>
<ui:tableColumn id="col1"
alignKey="last"
headerText="Last Name" rowHeader="true">
<ui:staticText
text="#{name.value.last}"/>
</ui:tableColumn>
<ui:tableColumn id="col2" alignKey="first"
headerText="First Name">
<ui:staticText
text="#{name.value.first}"/>
</ui:tableColumn>
</ui:tableRowGroup>
<!-- Actions (Top) -->
<f:facet name="actionsTop">
<f:subview id="actionsTop">
<jsp:include
page="actionsTop.jsp"/>
</f:subview>
</f:facet>
<!-- Actions (Bottom) -->
<f:facet name="actionsBottom">
<f:subview id="actionsBottom">
<jsp:include
page="actionsBottom.jsp"/>
</f:subview>
</f:facet>
</ui:table>
actionsTop.jsp
This example shows the contents of the actionsTop.jsp file included in the actionsTop
facet in the JSP page in the example above.
<!-- Actions (Top) -->
<ui:button id="action1"
action="#{TableBean.groupA.actions.delete}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmDeleteSelectedRows() == false)
return false"
text="Delete"/>
<ui:button id="action2"
action="#{TableBean.groupA.actions.action}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmSelectedRows() == false) return
false"
text="Action 2"/>
<ui:button id="action3"
action="#{TableBean.groupA.actions.action}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmSelectedRows() == false) return
false"
text="Action 3"/>
<ui:button id="action4"
action="#{TableBean.groupA.actions.action}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmSelectedRows() == false) return
false"
text="Action 4"/>
<ui:dropDown submitForm="true" id="moreActions"
action="#{TableBean.groupA.actions.moreActions}"
disabled="#{TableBean.groupA.actions.disabled}"
items="#{TableBean.groupA.actions.moreActionsOptions}"
selected="#{TableBean.groupA.actions.moreActions}"/>
actionsBottom.jsp
This example shows the contents of the actionsBottom.jsp file included in the actionsBottom
facet in the JSP page in the example above.
<!-- Actions (Bottom) -->
<ui:button id="action1"
action="#{TableBean.groupA.actions.delete}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmDeleteSelectedRows() == false)
return false"
text="Delete"/>
<ui:button id="action2"
action="#{TableBean.groupA.actions.action}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmSelectedRows() == false) return
false"
text="Action 2"/>
<ui:button id="action3"
action="#{TableBean.groupA.actions.action}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmSelectedRows() == false) return
false"
text="Action 3"/>
<ui:button id="action4"
action="#{TableBean.groupA.actions.action}"
disabled="#{TableBean.groupA.actions.disabled}"
onClick="if (confirmSelectedRows() == false) return
false"
text="Action 4"/>
<ui:dropDown submitForm="true" id="moreActions"
action="#{TableBean.groupA.actions.moreActions}"
disabled="#{TableBean.groupA.actions.disabled}"
items="#{TableBean.groupA.actions.moreActionsOptions}"
selected="#{TableBean.groupA.actions.moreActions}"/>
select.js
This example shows the contents of the select.js file used in the example above.
// Use this function to initialize all rows displayed in the
table when the
// state of selected components change (i.e., checkboxes or
radiobuttons used to
// de/select rows of the table). This functionality requires the
selectId
// property of the tableColumn component to be set.
//
// Note: Use setTimeout when invoking this function. This will ensure
that
// checkboxes and radiobutton are selected immediately, instead of
waiting for
// the onClick event to complete. For example:
//
// onClick="setTimeout('initAllRows(); disableActions()', 0)"
function initAllRows() {
// Disable table actions by default.
var table = document.getElementById("form1:table1");
table.initAllRows();
}
actions.js
This example shows the contents of the actions.js file used in the example above.
// Set disabled state of table actions. If a selection has been
made, actions
// are enabled. If no selection has been made, actions are disabled.
//
// Note: Use setTimeout when invoking this function. This will ensure
that
// checkboxes and radiobutton are selected immediately, instead of
waiting for
// the onClick event to complete. For example:
//
// onClick="setTimeout('initAllRows(); disableActions()', 0)"
function disableActions() {
// Disable table actions by default.
var table = document.getElementById("form1:table1");
var selections = table.getAllSelectedRowsCount(); //
Hidden & visible selections.
var disabled = (selections > 0) ? false : true;
// Set disabled state for top actions.
document.getElementById("form1:table1:actionsTop:action1").setDisabled(disabled);
document.getElementById("form1:table1:actionsTop:action2").setDisabled(disabled);
document.getElementById("form1:table1:actionsTop:action3").setDisabled(disabled);
document.getElementById("form1:table1:actionsTop:action4").setDisabled(disabled);
dropDown_setDisabled("form1:table1:actionsTop:moreActions", disabled);
// Set disabled state for bottom actions.
document.getElementById("form1:table1:actionsBottom:action1").setDisabled(disabled);
document.getElementById("form1:table1:actionsBottom:action2").setDisabled(disabled);
document.getElementById("form1:table1:actionsBottom:action3").setDisabled(disabled);
document.getElementById("form1:table1:actionsBottom:action4").setDisabled(disabled);
dropDown_setDisabled("form1:table1:actionsBottom:moreActions",
disabled);
}
//
// Use this function to confirm the number of selected components
(i.e.,
// checkboxes or radiobuttons used to de/select rows of the table),
affected by
// a delete action. This functionality requires the selectId property
of the
// tableColumn component and hiddenSelectedRows property of the
tableRowGroup
// component to be set.
//
// If selections are hidden from view, the confirmation message
indicates the
// number of selections not displayed in addition to the total number of
// selections. If selections are not hidden, the confirmation message
indicates
// only the total selections.
function confirmDeleteSelectedRows() {
var table = document.getElementById("form1:table1");
return table.confirmDeleteSelectedRows();
}
// Use this function to confirm the number of selected components
(i.e.,
// checkboxes or radiobuttons used to de/select rows of the table),
affected by
// an action such as edit, archive, etc. This functionality requires
the
// selectId property of the tableColumn component and hiddenSelectedRows
// property of the tableRowGroup component to be set.
//
// If selections are hidden from view, the confirmation message
indicates the
// number of selections not displayed in addition to the total number of
// selections. If selections are not hidden, the confirmation message
indicates
// only the total selections.
function confirmSelectedRows() {
var table = document.getElementById("form1:table1");
return table.confirmSelectedRows("\n\nArchive all
selections?");
}
faces_config.xml Entry for Managed Bean
The previous examples are based on managed beans, such as the example
below, added to the
faces_config.xml file.
<!DOCTYPE faces-config PUBLIC
'-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.0//EN'
'http://java.sun.com/dtd/web-facesconfig_1_1.dtd'>
<faces-config>
<managed-bean>
<description>The
backing bean for the table example</description>
<managed-bean-name>TableBean</managed-bean-name>
<managed-bean-class>table.TableBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
TableBean
package table;
import com.sun.rave.web.ui.component.Alarm;
import java.util.ArrayList;
import table.util.Group;
import table.util.Name;
// Backing bean for table examples.
public class TableBean {
// Group util for table examples.
private Group groupA = null; // List (rows 0-19).
private Group groupB = null; // Array (rows 0-9).
private Group groupC = null; // Array (rows 10-19).
// Alarms.
private static final Alarm down = new
Alarm(Alarm.SEVERITY_DOWN);
private static final Alarm critical = new
Alarm(Alarm.SEVERITY_CRITICAL);
private static final Alarm major = new
Alarm(Alarm.SEVERITY_MAJOR);
private static final Alarm minor = new
Alarm(Alarm.SEVERITY_MINOR);
private static final Alarm ok = new
Alarm(Alarm.SEVERITY_OK);
// Data for table examples.
protected static final Name[] names = {
new Name("William",
"Dupont", down),
new Name("Anna", "Keeney",
critical),
new Name("Mariko", "Randor",
major),
new Name("John", "Wilson",
minor),
new Name("Lynn",
"Seckinger", ok),
new Name("Richard",
"Tattersall", down),
new Name("Gabriella",
"Sarintia", critical),
new Name("Lisa", "Hartwig",
major),
new Name("Shirley", "Jones",
minor),
new Name("Bill", "Sprague",
ok),
new Name("Greg", "Doench",
down),
new Name("Solange",
"Nadeau", critical),
new Name("Heather",
"McGann", major),
new Name("Roy", "Martin",
minor),
new Name("Claude",
"Loubier", ok),
new Name("Dan", "Woodard",
down),
new Name("Ron", "Dunlap",
critical),
new Name("Keith",
"Frankart", major),
new Name("Andre", "Nadeau",
minor),
new Name("Horace",
"Celestin", ok),
};
// Default constructor.
public TableBean() {
}
// Get Group util created with a List containing all
names.
public Group getGroupA() {
if (groupA != null) {
return groupA;
}
// Create List with all
names.
ArrayList newNames = new
ArrayList();
for (int i = names.length -
1; i >= 0; i--) {
newNames.add(names[i]);
}
return (groupA = new
Group(newNames));
}
// Get Group util created with an array containing a
subset of names.
public Group getGroupB() {
if (groupB != null) {
return groupB;
}
// Create an array with
subset of names (i.e., 0-9).
Name[] newNames = new
Name[10];
System.arraycopy(names, 0,
newNames, 0, 10);
return (groupB = new
Group(newNames));
}
// Get Group util created with an array containing a
subset of names.
public Group getGroupC() {
if (groupC != null) {
return groupC;
}
// Create an array with
subset of names (i.e., 10-19).
Name[] newNames = new
Name[10];
System.arraycopy(names, 10,
newNames, 0, 10);
return (groupC = new
Group(newNames));
}
}
Utility Classes used in the examples
The following utility classes are used in the examples for the table
tags: ui:table , ui:tableRowGroup , and ui:tableColumn.
Group.java
Actions.java
Filter.java
Name.java
Select.java
Preferences.java
Group.java Utility Class
package table.util;
import com.sun.data.provider.TableDataProvider;
import com.sun.data.provider.impl.ObjectArrayDataProvider;
import com.sun.data.provider.impl.ObjectListDataProvider;
import com.sun.rave.web.ui.component.Checkbox;
import com.sun.rave.web.ui.component.TableRowGroup;
import java.util.List;
// This class contains data provider and util classes. Note that not
all util
// classes are used for each example.
public class Group {
private TableRowGroup tableRowGroup = null; //
TableRowGroup component.
private TableDataProvider provider = null; // Data
provider.
private Checkbox checkbox = null; // Checkbox
component.
private Preferences prefs = null; // Preferences
util.
private Messages messages = null; // Messages util.
private Actions actions = null; // Actions util.
private Filter filter = null; // Filter util.
private Select select = null; // Select util.
private Clean clean = null; // Clean util.
// Default constructor.
public Group() {
actions = new Actions(this);
filter = new Filter(this);
select = new Select(this);
clean = new Clean(this);
prefs = new Preferences();
messages = new Messages();
}
// Construct an instance using given Object array.
public Group(Object[] array) {
this();
provider = new
ObjectArrayDataProvider(array);
}
// Construct an instance using given List.
public Group(List list) {
this();
provider = new
ObjectListDataProvider(list);
}
// Get data provider.
public TableDataProvider getNames() {
return provider;
}
// Get Actions util.
public Actions getActions() {
return actions;
}
// Get Filter util.
public Filter getFilter() {
return filter;
}
// Get Messages util.
public Messages getMessages() {
return messages;
}
// Get Preferences util.
public Preferences getPreferences() {
return prefs;
}
// Get Select util.
public Select getSelect() {
return select;
}
// Get tableRowGroup component.
public TableRowGroup getTableRowGroup() {
return tableRowGroup;
}
// Set tableRowGroup component.
public void setTableRowGroup(TableRowGroup
tableRowGroup) {
this.tableRowGroup =
tableRowGroup;
}
// Get checkbox component.
public Checkbox getCheckbox() {
return checkbox;
}
// Set checkbox component.
public void setCheckbox(Checkbox checkbox) {
this.checkbox = checkbox;
}
}
Actions.java Utility Class
package table.util;
import com.sun.data.provider.FieldKey;
import com.sun.data.provider.RowKey;
import com.sun.data.provider.TableDataProvider;
import com.sun.data.provider.impl.ObjectListDataProvider;
import com.sun.rave.web.ui.model.Option;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
// This class provides functionality for table actions.
public class Actions {
private Group group = null; // Group util.
// Action menu items.
protected static final Option[] moreActionsOptions =
{
new Option("ACTION0",
"— More Actions —"),
new Option("ACTION1",
"Action 1"),
new Option("ACTION2",
"Action 2"),
new Option("ACTION3",
"Action 3"),
new Option("ACTION4",
"Action 4"),
};
// Default constructor.
public Actions(Group group) {
this.group = group;
}
// Action button event.
public void action() {
String message = null;
// Get hyperlink parameter
used for embedded actions example.
Map map =
FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap();
String param = (String)
map.get("param");
if (param != null) {
message = "Embedded Action Selected: Parameter = " + param;
} else {
message = "Table Action Selected";
}
group.getMessages().setMessage(message);
}
// Action to remove rows from ObjectListDataProvider.
public void delete() {
// Since mutiple examples
are using the same beans, the binding
// simply tells us that
checkbox state is maintained arcoss pages.
if
(group.getSelect().isKeepSelected()) {
//
If we got here, then we're maintaining state across pages.
delete(group.getTableRowGroup().getSelectedRowKeys());
} else {
//
If we got here, then we're using the phase listener and must
//
take filtering, sorting, and pagination into account.
delete(group.getTableRowGroup().getRenderedSelectedRowKeys());
}
}
// Set disabled value for table actions.
public boolean getDisabled() {
// If there is at least one
row selection, actions are enabled.
boolean result = true;
if (group.getTableRowGroup()
== null) {
return result;
}
// Since mutiple examples
are using the same beans, the binding
// simply tells us that
checkbox state is maintained arcoss pages.
if
(group.getSelect().isKeepSelected()) {
//
If we got here, then we're maintaining state across pages.
result = group.getTableRowGroup().getSelectedRowsCount() < 1;
} else {
//
If we got here, then we're using the phase listener and must
//
take filtering, sorting, and pagination into account.
result = group.getTableRowGroup().getRenderedSelectedRowsCount() < 1;
}
return result;
}
// Get action.
public String getMoreActions() {
// Per the UI guidelines,
always snap back to "More Actions...".
return "ACTION0";
}
// Get action menu options.
public Option[] getMoreActionsOptions() {
return moreActionsOptions;
}
// Action menu event.
public void moreActions() {
group.getMessages().setMessage("More Actions Menu Selected");
}
// Set action.
public void setMoreActions(String action) {
// Do nothing.
}
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Private methods
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Action to remove rows from ObjectListDataProvider.
private void delete(RowKey[] rowKeys) {
if (rowKeys == null) {
return;
}
TableDataProvider provider =
group.getNames();
for (int i = 0; i <
rowKeys.length; i++) {
RowKey rowKey = rowKeys[i];
if
(provider.canRemoveRow(rowKey)) {
provider.removeRow(rowKey);
}
}
((ObjectListDataProvider)
provider).commitChanges(); // Commit.
group.getSelect().clear();
// Clear phase listener.
}
}
Filter.java Utility Class
package table.util;
import com.sun.data.provider.FilterCriteria;
import com.sun.data.provider.impl.CompareFilterCriteria;
import com.sun.rave.web.ui.component.Table;
import com.sun.rave.web.ui.model.Option;
// This class provides functionality for table filters.
//
// This util class sets filters directly on the TableRowGroup component
using
// FilterCriteria; however, there is also a FilteredTableDataProvider
class that
// can used for filtering outside of the table. The table will pick up
what ever
// filter has been applied automatically, for example:
//
// // Some choice of TableDataProvider.
// TableDataProvider provider = new ...
//
// // This wraps and filters an existing TableDataProvider.
// FilteredTableDataProvider filteredProvider = new
FilteredTableDataProvider();
// filteredProvider.setTableDataProvider(provider);
//
// // Set FilteredTableDataProvider in the TableRowGroup component.
// tableRowGroup.setSourceData(filteredProvider);
//
// The table component itself has no idea that there is any filtering
going on,
// but the filtering functionality has been encapsulated in the data
provider.
// The developer can then use different FilterCriteria types to apply
filters,
// for example:
//
// CompareFilterCriteria cfc = new ...
// RegexFilterCriteria rxfc = new ...
// filteredProvider.setFilterCriteria(new FilterCriteria[] { cfc, fxfc
});
public class Filter {
private String customFilter = null; // Custom filter.
private String basicFilter = null; // Basic filter
menu option.
private String filterText = null; // Filter text.
private Group group = null; // Group util.
// Filter menu items.
protected static final Option[] filterOptions = {
new Option("FILTER0", "All
Items"),
new Option("FILTER1",
"Filter 1"),
new Option("FILTER2",
"Filter 2"),
};
// Default constructor.
public Filter(Group group) {
this.group = group;
}
// UI guidelines state that a "Custom Filter" option
should be added to the
// filter menu, used to open the table filter panel.
Thus, if the
// CUSTOM_FILTER option is selected, Javascript
invoked via the onChange
// event will open the table filter panel.
//
// UI guidelines also state that a "Custom Filter
Applied" option should be
// added to the filter menu, indicating that a
custom filter has been
// applied. In this scenario, set the selected
property of the filter menu
// as CUSTOM_FILTER_APPLIED. This selection should
persist until another
// menu option has been selected.
//
// Further, UI guidelines state that the table title
should indicate that a
// custom filter has been applied. To add this text
to the table title, set
// the filter property.
// Basic filter event.
public void applyBasicFilter() {
if
(basicFilter.equals("FILTER1")) {
filterText = "Filter 1";
} else if
(basicFilter.equals("FILTER2")) {
filterText = "Filter 2";
} else {
filterText = null;
}
// Clear all filters since
we don't have an example here.
//
// Note: TableRowGroup
ensures pagination is reset per UI guidelines.
group.getTableRowGroup().setFilterCriteria(null);
}
// Custom filter event.
public void applyCustomFilter() {
basicFilter =
Table.CUSTOM_FILTER_APPLIED; // Set filter menu option.
filterText = "Custom";
// Filter rows that do not
match custom filter.
CompareFilterCriteria
criteria = new CompareFilterCriteria(
group.getNames().getFieldKey("last"), customFilter);
// Note: TableRowGroup
ensures pagination is reset per UI guidelines.
group.getTableRowGroup().setFilterCriteria(
new
FilterCriteria[] {criteria});
}
// Get basic filter.
public String getBasicFilter() {
// Note: the selected value
must be set to restore the default selected
// value when the embedded
filter panel is closed. Further, the selected
// value should never be set
as "Custom Filter...".
return (basicFilter != null
&& !basicFilter.equals(Table.CUSTOM_FILTER))
?
basicFilter : "FILTER0";
}
// Set basic filter.
public void setBasicFilter(String value) {
basicFilter = value;
}
// Get custom filter.
public String getCustomFilter() {
return customFilter;
}
// Set custom filter.
public void setCustomFilter(String value) {
customFilter = value;
}
// Get filter menu options.
public Option[] getFilterOptions() {
// Get filter options based
on the selected filter menu option.
return
Table.getFilterOptions(filterOptions,
basicFilter == Table.CUSTOM_FILTER_APPLIED);
}
// Get filter text.
public String getFilterText() {
return filterText;
}
}
Name.java Utility Class
package table.util;
import com.sun.rave.web.ui.component.Alarm;
import com.sun.rave.web.ui.theme.ThemeImages;
public class Name {
private String last = null; // Last name.
private String first = null; // First name.
private Alarm alarm = null; // Alarm.
// Default constructor.
public Name(String first, String last) {
this.last = last;
this.first = first;
}
// Construct an instance with given alarm severity.
public Name(String first, String last, Alarm alarm) {
this(first, last);
this.alarm = alarm;
}
// Get first name.
public String getFirst() {
return (alarm != null) ? " "
+ first : first;
}
// Set first name.
public void setFirst(String first) {
this.first = first;
}
// Get last name.
public String getLast() {
return last;
}
// Set last name.
public void setLast(String last) {
this.last = last;
}
// Get alarm.
public Alarm getAlarm() {
return alarm;
}
// Get alarm.
public void setAlarm(Alarm alarm) {
this.alarm = alarm;
}
// Get alarm severity.
public String getSeverity() {
return alarm.getSeverity();
}
// Get alarm severity.
public void setSeverity(String severity) {
alarm.setSeverity(severity);
}
}
Select.java Utility Class
package table.util;
import com.sun.data.provider.FieldKey;
import com.sun.data.provider.RowKey;
import com.sun.data.provider.TableDataProvider;
import com.sun.rave.web.ui.event.TableSelectPhaseListener;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
// This class provides functionality for select tables.
//
// Note: UI guidelines recomend that rows should be unselected when no
longer in
// view. For example, when a user selects rows of the table and
navigates to
// another page. Or, when a user applies a filter or sort that may hide
// previously selected rows from view. If a user invokes an action to
delete
// the currently selected rows, they may inadvertently remove rows not
// displayed on the current page. Using TableSelectPhaseListener ensures
// that invalid row selections are not rendered by clearing selected
state
// after the render response phase.
public class Select {
private TableSelectPhaseListener tspl = null; //
Phase listener.
private Group group = null; // Group util.
// Default constructor.
public Select(Group group) {
this.group = group;
tspl = new
TableSelectPhaseListener();
}
// Clear selected state from phase listener (e.g.,
when deleting rows).
public void clear() {
tspl.clear();
}
// Test flag indicating that selected objects should
not be cleared.
public boolean isKeepSelected() {
return tspl.isKeepSelected();
}
// Set flag indicating that selected objects should
not be cleared.
public void keepSelected(boolean keepSelected) {
tspl.keepSelected(keepSelected);
}
// Get selected property.
public Object getSelected() {
return tspl.getSelected(getTableRow());
}
// Set selected property.
public void setSelected(Object object) {
RowKey rowKey =
getTableRow();
if (rowKey != null) {
tspl.setSelected(rowKey, object);
}
}
// Get selected value property.
public Object getSelectedValue() {
RowKey rowKey =
getTableRow();
return (rowKey != null) ?
rowKey.getRowId() : null;
}
// Get the selected state -- Sort on checked state
only.
public boolean getSelectedState() {
// Typically, selected state
is tested by comparing the selected and
// selectedValue properties.
In this example, however, the phase
// listener value is not
null when selected.
return
getSelectedState(getTableRow());
}
// Get the selected state.
public boolean getSelectedState(RowKey rowKey) {
return
tspl.isSelected(rowKey);
}
// Get current table row.
//
// Note: To obtain a RowKey for the current table
row, the use the same
// sourceVar property given to the TableRowGroup
component. For example, if
// sourceVar="name", use "#{name.tableRow}" as the
expression string.
private RowKey getTableRow() {
FacesContext context =
FacesContext.getCurrentInstance();
ValueBinding vb =
context.getApplication().createValueBinding(
"#{name.tableRow}");
return (RowKey)
vb.getValue(context);
}
}
Preferences.java Utility Class
package table.util;
// This class provides functionality for table preferences.
public class Preferences {
private String preference = null; // Rows preference.
private int rows = 5; // Rows per page.
// Default constructor.
public Preferences() {
}
// Table preferences event.
public void applyPreferences() {
try {
int
rows = Integer.parseInt(preference);
if
(rows > 0) {
this.rows = rows;
}
} catch
(NumberFormatException e) {}
}
// Get rows per page.
public int getRows() {
return rows;
}
// Get preference.
public String getPreference() {
return
Integer.toString(rows);
}
// Set preference.
public void setPreference(String value) {
preference = value;
}
}
Auto-generated component class.
Do NOT modify; all changes
will be lost!
|
Method Summary | |
public String | getAlign() | public String | getBgColor() | public int | getBorder() | public String | getCellPadding() | public String | getCellSpacing() | public String | getDeselectMultipleButtonOnClick() Scripting code that is executed when the user clicks the deselect multiple
button. | public String | getDeselectSingleButtonOnClick() Scripting code that is executed when the user clicks the deselect single button. | public String | getExtraActionBottomHtml() Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (bottom). | public String | getExtraActionTopHtml() Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (top). | public String | getExtraFooterHtml() Extra HTML code to be appended to the <td> HTML element that
is rendered for the table footer. | public String | getExtraPanelHtml() Extra HTML code to be appended to the <td> HTML element that
is rendered for an embedded panel. | public String | getExtraTitleHtml() Extra HTML code to be appended to the <caption> HTML element
that is rendered for the table title. | public String | getFamily() Return the identifier of the component family to which this
component belongs. | public String | getFilterId() The element id to be applied to the outermost HTML element that is rendered
for the dropDown component used to display filter options. | public String | getFilterPanelFocusId() | public String | getFilterText() Text to be inserted into the table title bar when a filter is applied. | public String | getFooterText() | public String | getFrame() | public String | getItemsText() Text to add to the title of an unpaginated table. | public String | getOnClick() | public String | getOnDblClick() | public String | getOnKeyDown() | public String | getOnKeyPress() | public String | getOnKeyUp() | public String | getOnMouseDown() | public String | getOnMouseMove() | public String | getOnMouseOut() | public String | getOnMouseOver() | public String | getOnMouseUp() | public String | getPreferencesPanelFocusId() | public String | getRules() | public String | getSelectMultipleButtonOnClick() | public String | getSortPanelFocusId() | public String | getStyle() | public String | getStyleClass() | public String | getSummary() | public int | getTabIndex() | public String | getTitle() | public String | getToolTip() | public String | getWidth() | public boolean | isAugmentTitle() Flag indicating that the table title should be augmented with the range of items
currently displayed and the total number of items in the table. | public boolean | isClearSortButton() In the View-Changing Controls area of the Action Bar, display a button that
clears any sorting of the table. | public boolean | isDeselectMultipleButton() In the Action Bar, display a deselect button for tables in which multiple rows
can be selected, to allow users to deselect all table rows that are currently
displayed. | public boolean | isDeselectSingleButton() In the Action Bar, display a deselect button for tables in which only a single
table row can be selected at a time. | public boolean | isHiddenSelectedRows() Flag indicating that selected rows might be currently hidden from view. | public boolean | isInternalVirtualForm() Flag indicating that this component should use a virtual form. | public boolean | isLite() | public boolean | isPaginateButton() | public boolean | isPaginationControls() Show the table pagination controls, which allow users to change which page is
displayed. | public boolean | isSelectMultipleButton() Show the button that is used for selecting multiple rows. | public boolean | isSortPanelToggleButton() | public boolean | isVisible() Use the visible attribute to indicate whether the component should be
viewable by the user in the rendered HTML page. | public void | restoreState(FacesContext _context, Object _state) | public Object | saveState(FacesContext _context) | public void | setAlign(String align) | public void | setAugmentTitle(boolean augmentTitle) Flag indicating that the table title should be augmented with the range of items
currently displayed and the total number of items in the table. | public void | setBgColor(String bgColor) | public void | setBorder(int border) | public void | setCellPadding(String cellPadding) | public void | setCellSpacing(String cellSpacing) | public void | setClearSortButton(boolean clearSortButton) In the View-Changing Controls area of the Action Bar, display a button that
clears any sorting of the table. | public void | setDeselectMultipleButton(boolean deselectMultipleButton) In the Action Bar, display a deselect button for tables in which multiple rows
can be selected, to allow users to deselect all table rows that are currently
displayed. | public void | setDeselectMultipleButtonOnClick(String deselectMultipleButtonOnClick) Scripting code that is executed when the user clicks the deselect multiple
button. | public void | setDeselectSingleButton(boolean deselectSingleButton) In the Action Bar, display a deselect button for tables in which only a single
table row can be selected at a time. | public void | setDeselectSingleButtonOnClick(String deselectSingleButtonOnClick) Scripting code that is executed when the user clicks the deselect single button. | public void | setExtraActionBottomHtml(String extraActionBottomHtml) Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (bottom). | public void | setExtraActionTopHtml(String extraActionTopHtml) Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (top). | public void | setExtraFooterHtml(String extraFooterHtml) Extra HTML code to be appended to the <td> HTML element that
is rendered for the table footer. | public void | setExtraPanelHtml(String extraPanelHtml) Extra HTML code to be appended to the <td> HTML element that
is rendered for an embedded panel. | public void | setExtraTitleHtml(String extraTitleHtml) Extra HTML code to be appended to the <caption> HTML element
that is rendered for the table title. | public void | setFilterId(String filterId) The element id to be applied to the outermost HTML element that is rendered
for the dropDown component used to display filter options. | public void | setFilterPanelFocusId(String filterPanelFocusId) | public void | setFilterText(String filterText) Text to be inserted into the table title bar when a filter is applied. | public void | setFooterText(String footerText) | public void | setFrame(String frame) | public void | setHiddenSelectedRows(boolean hiddenSelectedRows) Flag indicating that selected rows might be currently hidden from view. | public void | setInternalVirtualForm(boolean internalVirtualForm) Flag indicating that this component should use a virtual form. | public void | setItemsText(String itemsText) Text to add to the title of an unpaginated table. | public void | setLite(boolean lite) | public void | setOnClick(String onClick) | public void | setOnDblClick(String onDblClick) | public void | setOnKeyDown(String onKeyDown) | public void | setOnKeyPress(String onKeyPress) | public void | setOnKeyUp(String onKeyUp) | public void | setOnMouseDown(String onMouseDown) | public void | setOnMouseMove(String onMouseMove) | public void | setOnMouseOut(String onMouseOut) | public void | setOnMouseOver(String onMouseOver) | public void | setOnMouseUp(String onMouseUp) | public void | setPaginateButton(boolean paginateButton) | public void | setPaginationControls(boolean paginationControls) Show the table pagination controls, which allow users to change which page is
displayed. | public void | setPreferencesPanelFocusId(String preferencesPanelFocusId) | public void | setRules(String rules) | public void | setSelectMultipleButton(boolean selectMultipleButton) Show the button that is used for selecting multiple rows. | public void | setSelectMultipleButtonOnClick(String selectMultipleButtonOnClick) | public void | setSortPanelFocusId(String sortPanelFocusId) | public void | setSortPanelToggleButton(boolean sortPanelToggleButton) | public void | setStyle(String style) | public void | setStyleClass(String styleClass) | public void | setSummary(String summary) | public void | setTabIndex(int tabIndex) | public void | setTitle(String title) | public void | setToolTip(String toolTip) | public void | setVisible(boolean visible) Use the visible attribute to indicate whether the component should be
viewable by the user in the rendered HTML page. | public void | setWidth(String width) |
TableBase | public TableBase()(Code) | | Construct a new TableBase .
|
getAlign | public String getAlign()(Code) | | Sets the alignment of the table (left, right or center) on the page (deprecated in HTML 4.0)
|
getBgColor | public String getBgColor()(Code) | | Sets the background color for the table (deprecated in HTML 4.0)
|
getBorder | public int getBorder()(Code) | | Set the border width in pixels within the table
|
getCellPadding | public String getCellPadding()(Code) | | Sets the whitespace between the borders and the contents of a cell
|
getCellSpacing | public String getCellSpacing()(Code) | | Sets the whitespace between cells and also at the edges of the table
|
getDeselectMultipleButtonOnClick | public String getDeselectMultipleButtonOnClick()(Code) | | Scripting code that is executed when the user clicks the deselect multiple
button. You should use the JavaScript setTimeout() function to
invoke the script to ensure that checkboxes are deselected immediately, instead
of waiting for the script to complete.
|
getDeselectSingleButtonOnClick | public String getDeselectSingleButtonOnClick()(Code) | | Scripting code that is executed when the user clicks the deselect single button.
You should use the JavaScript setTimeout() function to invoke the
script to ensure that the radio button is deselected immediately, instead of
waiting for the script to complete.
|
getExtraActionBottomHtml | public String getExtraActionBottomHtml()(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (bottom). Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity. For example, you might set this
attribute to "style=`myActionBarStyle'" .
|
getExtraActionTopHtml | public String getExtraActionTopHtml()(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (top). Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity. For example, you might set this
attribute to "style=`myActionBarStyle'" .
|
getExtraFooterHtml | public String getExtraFooterHtml()(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for the table footer. Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity. For example, you might set this
attribute to "nowrap=`nowrap'" .
|
getExtraPanelHtml | public String getExtraPanelHtml()(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for an embedded panel. Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity.
|
getExtraTitleHtml | public String getExtraTitleHtml()(Code) | | Extra HTML code to be appended to the <caption> HTML element
that is rendered for the table title. Use only code that is valid in an HTML
<caption> element. The code you specify is inserted in the
HTML element, and is not checked for validity. For example, you might set this
attribute to "style=`myTitleStyle'" .
|
getFamily | public String getFamily()(Code) | | Return the identifier of the component family to which this
component belongs. This identifier, in conjunction with the value
of the rendererType property, may be used to select
the appropriate
Renderer for this component instance.
|
getFilterId | public String getFilterId()(Code) | | The element id to be applied to the outermost HTML element that is rendered
for the dropDown component used to display filter options. The id must be
fully qualified. This id is required for JavaScript functions to set the
dropDown styles when the embedded filter panel is opened, and to reset the
default selected value when the panel is closed. Note that if you use the
ui:dropDown tag as the only component in the filter
facet, the filterId is optional. If you use a custom component, or
use the ui:dropDown as a child component, you must specify a
filterID.
|
getFilterPanelFocusId | public String getFilterPanelFocusId()(Code) | | The element id used to set focus when the filter panel is open.
|
getFilterText | public String getFilterText()(Code) | | Text to be inserted into the table title bar when a filter is applied. This text
is expected to be the name of the filter that the user has selected. The
attribute value should be a JavaServer Faces EL expression that resolves to a
backing bean property whose value is set in your filter code. The value of the
filterText attribute is inserted into the table title, as follows: Your Table's
Title filterText Filter Applied.
|
getFooterText | public String getFooterText()(Code) | | The text to be displayed in the table footer, which expands across the width of
the table.
|
getFrame | public String getFrame()(Code) | | Specifies the width in pixels of the border around a table.
|
getItemsText | public String getItemsText()(Code) | | Text to add to the title of an unpaginated table. For example, if your table
title is "Critical" and there are 20 items in the table, the default unpaginated
table title would be Critical (20). If you specify itemsText="alerts", the title
would be Critical (20 alerts).
|
getOnClick | public String getOnClick()(Code) | | Scripting code executed when a mouse click
occurs over this component.
|
getOnDblClick | public String getOnDblClick()(Code) | | Scripting code executed when a mouse double click
occurs over this component.
|
getOnKeyDown | public String getOnKeyDown()(Code) | | Scripting code executed when the user presses down on a key while the
component has focus.
|
getOnKeyPress | public String getOnKeyPress()(Code) | | Scripting code executed when the user presses and releases a key while
the component has focus.
|
getOnKeyUp | public String getOnKeyUp()(Code) | | Scripting code executed when the user releases a key while the
component has focus.
|
getOnMouseDown | public String getOnMouseDown()(Code) | | Scripting code executed when the user presses a mouse button while the
mouse pointer is on the component.
|
getOnMouseMove | public String getOnMouseMove()(Code) | | Scripting code executed when the user moves the mouse pointer while
over the component.
|
getOnMouseOut | public String getOnMouseOut()(Code) | | Scripting code executed when a mouse out movement
occurs over this component.
|
getOnMouseOver | public String getOnMouseOver()(Code) | | Scripting code executed when the user moves the mouse pointer into
the boundary of this component.
|
getOnMouseUp | public String getOnMouseUp()(Code) | | Scripting code executed when the user releases a mouse button while
the mouse pointer is on the component.
|
getPreferencesPanelFocusId | public String getPreferencesPanelFocusId()(Code) | | The element id used to set focus when the preferences panel is open.
|
getSelectMultipleButtonOnClick | public String getSelectMultipleButtonOnClick()(Code) | | Scripting code executed when the user clicks the mouse on the select multiple
button.
|
getSortPanelFocusId | public String getSortPanelFocusId()(Code) | | The element id used to set focus when the sort panel is open.
|
getStyle | public String getStyle()(Code) | | CSS style(s) to be applied when this component is rendered.
|
getStyleClass | public String getStyleClass()(Code) | | CSS style class(es) to be applied when this component is rendered.
|
getSummary | public String getSummary()(Code) | | Summary text that describes the table for accessibility purposes
|
getTabIndex | public int getTabIndex()(Code) | | The position of this component in the tabbing order sequence
|
getTitle | public String getTitle()(Code) | | The text displayed for the table title.
|
getToolTip | public String getToolTip()(Code) | | Display the text as a tooltip for this component
|
getWidth | public String getWidth()(Code) | | Set the width of the table on the page (deprecated in HTML 4.0)
|
isAugmentTitle | public boolean isAugmentTitle()(Code) | | Flag indicating that the table title should be augmented with the range of items
currently displayed and the total number of items in the table. For example,
"(1 - 25 of 200)". If the table is not currently paginated, the title is
augmented with the number of displayed items. For example, "(18)". When set to
false, any values set for itemsText and filterText
are overridden.
|
isClearSortButton | public boolean isClearSortButton()(Code) | | In the View-Changing Controls area of the Action Bar, display a button that
clears any sorting of the table. When the button is clicked, the table items
return to the order they were in when the page was initially rendered.
|
isDeselectMultipleButton | public boolean isDeselectMultipleButton()(Code) | | In the Action Bar, display a deselect button for tables in which multiple rows
can be selected, to allow users to deselect all table rows that are currently
displayed. This button is used to deselect a column of checkboxes using the id
that was given to the selectId attribute of the ui:tableColumn tag.
|
isDeselectSingleButton | public boolean isDeselectSingleButton()(Code) | | In the Action Bar, display a deselect button for tables in which only a single
table row can be selected at a time. This button is used to deselect a column of
radio buttons using the id that was given to the selectId attribute of the
ui:tableColumn tag.
|
isHiddenSelectedRows | public boolean isHiddenSelectedRows()(Code) | | Flag indicating that selected rows might be currently hidden from view. UI
guidelines recommend that rows that are not in view are deselected. For example,
when users select rows of the table and navigate to another page, the selected
rows should be deselected automatically. Or, when a user applies a filter or
sort that hides previously selected rows from view, those selected rows should
be deselected. By deselecting hidden rows, you prevent the user from
inadvertantly invoking an action on rows that are not displayed.
However, sometimes state must be maintained aross table pages. If your table
must maintain state, you must set the hiddenSelectedRows attribute to true. The
attribute causes text to be displayed in the table title and footer to indicate
the number of selected rows that are currently hidden from view. This title and
footer text is also displayed with a count of 0 when there are no hidden
selections, to make the user aware of the possibility of hidden selections.
Note: When hiddenSelectedRows is false, the descending sort button for the
select column is disabled when the table is paginated. Disabling this button
prevents a sort from placing selected rows on a page other than the current
page.
|
isInternalVirtualForm | public boolean isInternalVirtualForm()(Code) | | Flag indicating that this component should use a virtual form. A virtual form is
equivalent to enclosing the table component in its own HTML form element,
separate from other HTML elements on the same page. As an example, consider the
case where a required text field and table appear on the same page. If the user
clicks on a table sort button, while the required text field has no value, the
sort action is never invoked because a value was required and validation failed.
Placing the table in a virtual form allows the table sort action to complete
because validation for the required text field is not processed. This is similar
to using the immediate property of a button, but allows table children to be
submitted so that selected checkbox values may be sorted, for example.
|
isLite | public boolean isLite()(Code) | | Renders the table in a style that makes the table look lighter weight, generally
by omitting the shading around the table and in the title bar.
|
isPaginateButton | public boolean isPaginateButton()(Code) | | Show table paginate button to allow users to switch between viewing all data on
a single page (unpaginated) or to see data in multiple pages (paginated).
|
isPaginationControls | public boolean isPaginationControls()(Code) | | Show the table pagination controls, which allow users to change which page is
displayed. The controls include an input field for specifying the page number, a
Go button to go to the specified page, and buttons for going to the first, last,
previous, and next page.
|
isSelectMultipleButton | public boolean isSelectMultipleButton()(Code) | | Show the button that is used for selecting multiple rows. The button is
displayed in the Action Bar (top), and allows users to select all rows currently
displayed. The button selects a column of checkboxes using the id specified in
the selectId attribute of the ui:tableColumn tag.
|
isSortPanelToggleButton | public boolean isSortPanelToggleButton()(Code) | | Show the button that is used to open and close the sort panel.
|
isVisible | public boolean isVisible()(Code) | | Use the visible attribute to indicate whether the component should be
viewable by the user in the rendered HTML page. If set to false, the
HTML code for the component is present in the page, but the component
is hidden with style attributes. By default, visible is set to true, so
HTML for the component HTML is included and visible to the user. If the
component is not visible, it can still be processed on subsequent form
submissions because the HTML is present.
|
restoreState | public void restoreState(FacesContext _context, Object _state)(Code) | | Restore the state of this component.
|
saveState | public Object saveState(FacesContext _context)(Code) | | Save the state of this component.
|
setAlign | public void setAlign(String align)(Code) | | Sets the alignment of the table (left, right or center) on the page (deprecated in HTML 4.0)
See Also: TableBase.getAlign() |
setAugmentTitle | public void setAugmentTitle(boolean augmentTitle)(Code) | | Flag indicating that the table title should be augmented with the range of items
currently displayed and the total number of items in the table. For example,
"(1 - 25 of 200)". If the table is not currently paginated, the title is
augmented with the number of displayed items. For example, "(18)". When set to
false, any values set for itemsText and filterText
are overridden.
See Also: TableBase.isAugmentTitle() |
setClearSortButton | public void setClearSortButton(boolean clearSortButton)(Code) | | In the View-Changing Controls area of the Action Bar, display a button that
clears any sorting of the table. When the button is clicked, the table items
return to the order they were in when the page was initially rendered.
See Also: TableBase.isClearSortButton() |
setDeselectMultipleButton | public void setDeselectMultipleButton(boolean deselectMultipleButton)(Code) | | In the Action Bar, display a deselect button for tables in which multiple rows
can be selected, to allow users to deselect all table rows that are currently
displayed. This button is used to deselect a column of checkboxes using the id
that was given to the selectId attribute of the ui:tableColumn tag.
See Also: TableBase.isDeselectMultipleButton() |
setDeselectMultipleButtonOnClick | public void setDeselectMultipleButtonOnClick(String deselectMultipleButtonOnClick)(Code) | | Scripting code that is executed when the user clicks the deselect multiple
button. You should use the JavaScript setTimeout() function to
invoke the script to ensure that checkboxes are deselected immediately, instead
of waiting for the script to complete.
See Also: TableBase.getDeselectMultipleButtonOnClick() |
setDeselectSingleButton | public void setDeselectSingleButton(boolean deselectSingleButton)(Code) | | In the Action Bar, display a deselect button for tables in which only a single
table row can be selected at a time. This button is used to deselect a column of
radio buttons using the id that was given to the selectId attribute of the
ui:tableColumn tag.
See Also: TableBase.isDeselectSingleButton() |
setDeselectSingleButtonOnClick | public void setDeselectSingleButtonOnClick(String deselectSingleButtonOnClick)(Code) | | Scripting code that is executed when the user clicks the deselect single button.
You should use the JavaScript setTimeout() function to invoke the
script to ensure that the radio button is deselected immediately, instead of
waiting for the script to complete.
See Also: TableBase.getDeselectSingleButtonOnClick() |
setExtraActionBottomHtml | public void setExtraActionBottomHtml(String extraActionBottomHtml)(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (bottom). Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity. For example, you might set this
attribute to "style=`myActionBarStyle'" .
See Also: TableBase.getExtraActionBottomHtml() |
setExtraActionTopHtml | public void setExtraActionTopHtml(String extraActionTopHtml)(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for the Action Bar (top). Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity. For example, you might set this
attribute to "style=`myActionBarStyle'" .
See Also: TableBase.getExtraActionTopHtml() |
setExtraFooterHtml | public void setExtraFooterHtml(String extraFooterHtml)(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for the table footer. Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity. For example, you might set this
attribute to "nowrap=`nowrap'" .
See Also: TableBase.getExtraFooterHtml() |
setExtraPanelHtml | public void setExtraPanelHtml(String extraPanelHtml)(Code) | | Extra HTML code to be appended to the <td> HTML element that
is rendered for an embedded panel. Use only code that is valid in an HTML
<td> element. The code you specify is inserted in the HTML
element, and is not checked for validity.
See Also: TableBase.getExtraPanelHtml() |
setExtraTitleHtml | public void setExtraTitleHtml(String extraTitleHtml)(Code) | | Extra HTML code to be appended to the <caption> HTML element
that is rendered for the table title. Use only code that is valid in an HTML
<caption> element. The code you specify is inserted in the
HTML element, and is not checked for validity. For example, you might set this
attribute to "style=`myTitleStyle'" .
See Also: TableBase.getExtraTitleHtml() |
setFilterId | public void setFilterId(String filterId)(Code) | | The element id to be applied to the outermost HTML element that is rendered
for the dropDown component used to display filter options. The id must be
fully qualified. This id is required for JavaScript functions to set the
dropDown styles when the embedded filter panel is opened, and to reset the
default selected value when the panel is closed. Note that if you use the
ui:dropDown tag as the only component in the filter
facet, the filterId is optional. If you use a custom component, or
use the ui:dropDown as a child component, you must specify a
filterID.
See Also: TableBase.getFilterId() |
setFilterText | public void setFilterText(String filterText)(Code) | | Text to be inserted into the table title bar when a filter is applied. This text
is expected to be the name of the filter that the user has selected. The
attribute value should be a JavaServer Faces EL expression that resolves to a
backing bean property whose value is set in your filter code. The value of the
filterText attribute is inserted into the table title, as follows: Your Table's
Title filterText Filter Applied.
See Also: TableBase.getFilterText() |
setFooterText | public void setFooterText(String footerText)(Code) | | The text to be displayed in the table footer, which expands across the width of
the table.
See Also: TableBase.getFooterText() |
setHiddenSelectedRows | public void setHiddenSelectedRows(boolean hiddenSelectedRows)(Code) | | Flag indicating that selected rows might be currently hidden from view. UI
guidelines recommend that rows that are not in view are deselected. For example,
when users select rows of the table and navigate to another page, the selected
rows should be deselected automatically. Or, when a user applies a filter or
sort that hides previously selected rows from view, those selected rows should
be deselected. By deselecting hidden rows, you prevent the user from
inadvertantly invoking an action on rows that are not displayed.
However, sometimes state must be maintained aross table pages. If your table
must maintain state, you must set the hiddenSelectedRows attribute to true. The
attribute causes text to be displayed in the table title and footer to indicate
the number of selected rows that are currently hidden from view. This title and
footer text is also displayed with a count of 0 when there are no hidden
selections, to make the user aware of the possibility of hidden selections.
Note: When hiddenSelectedRows is false, the descending sort button for the
select column is disabled when the table is paginated. Disabling this button
prevents a sort from placing selected rows on a page other than the current
page.
See Also: TableBase.isHiddenSelectedRows() |
setInternalVirtualForm | public void setInternalVirtualForm(boolean internalVirtualForm)(Code) | | Flag indicating that this component should use a virtual form. A virtual form is
equivalent to enclosing the table component in its own HTML form element,
separate from other HTML elements on the same page. As an example, consider the
case where a required text field and table appear on the same page. If the user
clicks on a table sort button, while the required text field has no value, the
sort action is never invoked because a value was required and validation failed.
Placing the table in a virtual form allows the table sort action to complete
because validation for the required text field is not processed. This is similar
to using the immediate property of a button, but allows table children to be
submitted so that selected checkbox values may be sorted, for example.
See Also: TableBase.isInternalVirtualForm() |
setItemsText | public void setItemsText(String itemsText)(Code) | | Text to add to the title of an unpaginated table. For example, if your table
title is "Critical" and there are 20 items in the table, the default unpaginated
table title would be Critical (20). If you specify itemsText="alerts", the title
would be Critical (20 alerts).
See Also: TableBase.getItemsText() |
setLite | public void setLite(boolean lite)(Code) | | Renders the table in a style that makes the table look lighter weight, generally
by omitting the shading around the table and in the title bar.
See Also: TableBase.isLite() |
setOnKeyDown | public void setOnKeyDown(String onKeyDown)(Code) | | Scripting code executed when the user presses down on a key while the
component has focus.
See Also: TableBase.getOnKeyDown() |
setOnKeyPress | public void setOnKeyPress(String onKeyPress)(Code) | | Scripting code executed when the user presses and releases a key while
the component has focus.
See Also: TableBase.getOnKeyPress() |
setOnKeyUp | public void setOnKeyUp(String onKeyUp)(Code) | | Scripting code executed when the user releases a key while the
component has focus.
See Also: TableBase.getOnKeyUp() |
setOnMouseDown | public void setOnMouseDown(String onMouseDown)(Code) | | Scripting code executed when the user presses a mouse button while the
mouse pointer is on the component.
See Also: TableBase.getOnMouseDown() |
setOnMouseMove | public void setOnMouseMove(String onMouseMove)(Code) | | Scripting code executed when the user moves the mouse pointer while
over the component.
See Also: TableBase.getOnMouseMove() |
setOnMouseOver | public void setOnMouseOver(String onMouseOver)(Code) | | Scripting code executed when the user moves the mouse pointer into
the boundary of this component.
See Also: TableBase.getOnMouseOver() |
setOnMouseUp | public void setOnMouseUp(String onMouseUp)(Code) | | Scripting code executed when the user releases a mouse button while
the mouse pointer is on the component.
See Also: TableBase.getOnMouseUp() |
setPaginateButton | public void setPaginateButton(boolean paginateButton)(Code) | | Show table paginate button to allow users to switch between viewing all data on
a single page (unpaginated) or to see data in multiple pages (paginated).
See Also: TableBase.isPaginateButton() |
setPaginationControls | public void setPaginationControls(boolean paginationControls)(Code) | | Show the table pagination controls, which allow users to change which page is
displayed. The controls include an input field for specifying the page number, a
Go button to go to the specified page, and buttons for going to the first, last,
previous, and next page.
See Also: TableBase.isPaginationControls() |
setSelectMultipleButton | public void setSelectMultipleButton(boolean selectMultipleButton)(Code) | | Show the button that is used for selecting multiple rows. The button is
displayed in the Action Bar (top), and allows users to select all rows currently
displayed. The button selects a column of checkboxes using the id specified in
the selectId attribute of the ui:tableColumn tag.
See Also: TableBase.isSelectMultipleButton() |
setSortPanelToggleButton | public void setSortPanelToggleButton(boolean sortPanelToggleButton)(Code) | | Show the button that is used to open and close the sort panel.
See Also: TableBase.isSortPanelToggleButton() |
setTabIndex | public void setTabIndex(int tabIndex)(Code) | | The position of this component in the tabbing order sequence
See Also: TableBase.getTabIndex() |
setVisible | public void setVisible(boolean visible)(Code) | | Use the visible attribute to indicate whether the component should be
viewable by the user in the rendered HTML page. If set to false, the
HTML code for the component is present in the page, but the component
is hidden with style attributes. By default, visible is set to true, so
HTML for the component HTML is included and visible to the user. If the
component is not visible, it can still be processed on subsequent form
submissions because the HTML is present.
See Also: TableBase.isVisible() |
|
|