|
Oracle UIX API Reference Release 2.1.22.0.0 B12196-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.cabo.ui.data.tree.BrowseNodeDataObject
While the purpose of the BrowseMenuBean is to allow users to browse through complex sets of hierarchical objects, the hierarchical data isn't added to the BrowseMenu itself. BrowseNodeDataObject takes a tree of DataObjects and a current location and extracts the appropriate information.
BrowseNodeDataObject expects the nodes in the tree to use the following keys.
To begin with we will give an example of hierarchical, or tree-structured, data which we will use in subsequent examples:
private SimpleTreeData createShopNode(
String text,
String description)
{
SimpleTreeData data = new SimpleTreeData();
data.setText( text );
if ( description != null )
data.setDescription( description);
data.setDestination( "http://bali.us.oracle.com");
data.setDestinationText( "More Information");
return data;
}
private DataObject createData()
{
SimpleTreeData treeRoot = new SimpleTreeData();
SimpleTreeData shop =
createShopNode("Shop", "Spend some money!");
SimpleTreeData books =
createShopNode("Books", null);
SimpleTreeData umbrellas =
createShopNode("Umbrellas", "Rain, rain go away");
SimpleTreeData art =
createShopNode("Art", "Picasso et al");
books.addChild( art);
shop.addChild(books);
shop.addChild(umbrellas);
return shop;
}
So this is the tree:
shop
/ \
books umbrellas
|
art
So "art" and "umbrellas" are leaves and therefore items, while "shop" and "books" are categories. So "shop" is one of the 'roots' of this tree. There could theoretically be multiple roots.
So let's use BrowseMenuUtils to set up a "default" looking BrowseMenu
using this data.
In this example we are using a servlet. For those not familiar with
servlets it may help to know that the init
method is called
once when the servlet is started while the doGet
method is
called once per request.
In init
we would build the tree of UINodes and somewhere
in there we might see the following:
public void init(ServletConfig config)
throws ServletException
{
.....
// create the browse menu
BrowseMenuBean browseMenu = new BrowseMenuBean();
// give it page-wide-unique id - IMPORTANT!!
browseMenu.setID(MY_BROWSE_MENU_NAME);
// add the "default" containers
BrowseMenuUtils.configureBrowseMenu(
MY_NAMESPACEURI,
MY_LOCALNAME,
browseMenu);
// set treeData, an instance field,
// to be the tree described above
treeData = createData();
// put the browse menu in a form
FormBean form = new FormBean("myForm");
form.addIndexedChild(browseMenu);
// add hidden field with current state so that if
// another bean fires event the browseMenu's current
// state is still sent back with the form
FormValueBean hidden = new FormValueBean();
hidden.setName( MY_BROWSE_MENU_NAME + ":State");
hidden.setValueBinding( new DataBoundValue(
MY_NAMESPACEURI,
MY_LOCALNAME,
BrowseNodeDataObject.CURRENT_STATE_KEY));
form.addIndexedChild(hidden);
.....
}
Then in the servlet's doGet
we might have:
Please see below for more information about the line
public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
.....
// get the state for the current location in the tree
String currentLocation =
request.getParameter("location");
// if null then the state might have been sent
// back with the form through the hidden field
if ( currentLocation == null )
currentLocation = request.getParameter(
MY_BROWSE_MENU_NAME + ":State");
// create the data
DataObject browseData = new BrowseNodeDataObject(
treeData,
currentLocation );
// push the data on the context
TableDataProvider provider = new TableDataProvider();
provider.put(MY_NAMESPACEURI, MY_LOCALNAME, browseData);
.....
}
request.getParameter("location")
.
BrowseNodeDataObject takes a tree of data and a current location. The BrowseNodeDataObject uses the current location to go through the tree and find the current location node, to find the "books" node for example. The current location node is expected to return results when queried with:
So let's say the current location is the "books" node in the tree above. The keys above would return the following.
When the BrowseMenu's formSubmitted attribute is set to true, then the name-value pairs above are returned through form submission.
If the BrowseMenu's formSubmitted attribute is set to false or is not set
then the destinations contain the destination passed in to the constructor
to which the name-value pairs above are appended. If no destination was
passed in or the destination passed in was null, then the destination
returned by the call context.getURLEncoder().getDefaultURL()
is used.
Therefore the line request.getParameter("location")
above should
return the value associated with the parameter name 'location'. Thus if a
user has selected a category, for example, then the three name-value pairs
above are sent to the server and the line
request.getParameter("location")
will return a String
representing the new location state. The first time a client makes a
request to the servlet this parameter will not exist, in which case the
String returned will be null. When null is passed to the
BrowseNodeDataObject constructor the currentLocation will be set to the
default of "0", representing 'roots[0]'.
SimpleTreeData
,
BrowseMenuUtils
,
BrowseMenuBean
,
UIConstants
Field Summary | |
static java.lang.String |
CATEGORIES_DATA_KEY
key to pass to selectValue which returns a DataObjectList with the data for the categories child. |
static java.lang.String |
CURRENT_STATE_KEY
key to pass to selectValue which returns the String representing the current location state |
static java.lang.String |
ITEMS_DATA_KEY
key to pass to selectValue which returns a DataObjectList with the data for the items child. |
static java.lang.String |
LOCATION_DATA_KEY
key to pass to selectValue which returns a DataObjectList with the data for the location child. |
static java.lang.String |
RENDER_CATEGORIES_KEY
key to pass to selectValue which returns the Boolean value of whether or not to render the categories child |
static java.lang.String |
RENDER_CONTENT_LINK_KEY
key to pass to selectValue which returns the Boolean value of whether or not to render the contentLink child |
static java.lang.String |
RENDER_ITEMS_KEY
key to pass to selectValue which returns the Boolean value of whether or not to render the items child |
static java.lang.String |
RENDER_LOCATION_KEY
key to pass to selectValue which returns the Boolean value of whether or not to render the location child |
Constructor Summary | |
BrowseNodeDataObject(DataObject[] treeRoots,
java.lang.String currentLocation)
Constructs a DataObject with information relevant to a BrowseMenu |
|
BrowseNodeDataObject(DataObject[] treeRoots,
java.lang.String currentLocation,
java.lang.String destination)
Constructs a DataObject with information relevant to a BrowseMenu |
|
BrowseNodeDataObject(DataObjectList treeRoots,
java.lang.String currentLocation)
Constructs a DataObject with information relevant to a BrowseMenu |
|
BrowseNodeDataObject(DataObjectList treeRoots,
java.lang.String currentLocation,
java.lang.String destination)
Constructs a DataObject with information relevant to a BrowseMenu |
|
BrowseNodeDataObject(DataObject treeRoot,
java.lang.String currentLocation)
Constructs a DataObject with information relevant to a BrowseMenu |
|
BrowseNodeDataObject(DataObject treeRoot,
java.lang.String currentLocation,
java.lang.String destination)
Constructs a DataObject with information relevant to a BrowseMenu |
Method Summary | |
java.lang.Object |
selectValue(RenderingContext context,
java.lang.Object select)
Given a select object, returns the value matching that selection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CATEGORIES_DATA_KEY
public static final java.lang.String ITEMS_DATA_KEY
public static final java.lang.String LOCATION_DATA_KEY
public static final java.lang.String RENDER_ITEMS_KEY
public static final java.lang.String RENDER_CATEGORIES_KEY
public static final java.lang.String RENDER_CONTENT_LINK_KEY
public static final java.lang.String RENDER_LOCATION_KEY
public static final java.lang.String CURRENT_STATE_KEY
Constructor Detail |
public BrowseNodeDataObject(DataObject treeRoot, java.lang.String currentLocation, java.lang.String destination)
treeRoot
- the root of a tree of DataObjectscurrentLocation
- the current location state.
currentLocation
is a
comma separated String. Children of nodes are counted using a zero-based
index. If the browse menu is currently rendering the 4th child of the
root node then currentLocation
would be "0,3". That's 0 for
the root node and 3 for its fourth child.
currentLocation
for the 7th child of the 4th child of the
root node would be stored as "0,3,6" and so on. Normally a user
would start with "0" to indicate the root of the tree of data, and
this is the default if currentLocation
is null.destination
- the url to which links should go. If null it will be
set to the destination returned by
context.getURLEncoder().getDefaultURL()
.public BrowseNodeDataObject(DataObjectList treeRoots, java.lang.String currentLocation, java.lang.String destination)
treeRoots
- the roots of a tree of DataObjectscurrentLocation
- the current location state.
currentLocation
is a
comma separated String. Children of nodes are counted using a zero-based
index. If the browse menu is currently rendering the 4th child of the first
root node then currentLocation
would be "0,3". That's 0 for
the first root node and 3 for its fourth child.
currentLocation
for the 7th child of the 4th child of the
first root node would be stored as "0,3,6" and so on. Normally a user
would start with "0" or "1" to indicate one of the roots of the tree of
data. The default is "0" if currentLocation
is null.destination
- the url to which links should go. If null it will
be set to the destination returned by
context.getURLEncoder().getDefaultURL()
.public BrowseNodeDataObject(DataObject[] treeRoots, java.lang.String currentLocation, java.lang.String destination)
treeRoots
- the roots of a tree of DataObjectscurrentLocation
- the current location state.
currentLocation
is a
comma separated String. Children of nodes are counted using a zero-based
index. If the browse menu is currently rendering the 4th child of the first
root node then currentLocation
would be "0,3". That's 0 for
the first root node and 3 for its fourth child.
currentLocation
for the 7th child of the 4th child of the
first root node would be stored as "0,3,6" and so on. Normally a user
would start with "0" or "1" to indicate one of the roots of the tree of
data. The default is "0" if currentLocation
is null.destination
- the url to which links should go. If null it will
be set to the destination returned by
context.getURLEncoder().getDefaultURL()
.public BrowseNodeDataObject(DataObject treeRoot, java.lang.String currentLocation)
treeRoot
- the root of a tree of DataObjectscurrentLocation
- the current location state.
currentLocation
is a
comma separated String. Children of nodes are counted using a zero-based
index. If the browse menu is currently rendering the 4th child of the
root node then currentLocation
would be "0,3". That's 0 for
the root node and 3 for its fourth child.
currentLocation
for the 7th child of the 4th child of the
root node would be stored as "0,3,6" and so on. Normally a user
would start with "0" to indicate the root of the tree of data, and
this is the default if currentLocation
is null.public BrowseNodeDataObject(DataObjectList treeRoots, java.lang.String currentLocation)
treeRoots
- the roots of a tree of DataObjectscurrentLocation
- the current location state.
currentLocation
is a
comma separated String. Children of nodes are counted using a zero-based
index. If the browse menu is currently rendering the 4th child of the first
root node then currentLocation
would be "0,3". That's 0 for
the first root node and 3 for its fourth child.
currentLocation
for the 7th child of the 4th child of the
first root node would be stored as "0,3,6" and so on. Normally a user
would start with "0" or "1" to indicate one of the roots of the tree of
data. The default is "0" if currentLocation
is null.public BrowseNodeDataObject(DataObject[] treeRoots, java.lang.String currentLocation)
treeRoots
- the roots of a tree of DataObjectscurrentLocation
- the current location state.
currentLocation
is a
comma separated String. Children of nodes are counted using a zero-based
index. If the browse menu is currently rendering the 4th child of the first
root node then currentLocation
would be "0,3". That's 0 for
the first root node and 3 for its fourth child.
currentLocation
for the 7th child of the 4th child of the
first root node would be stored as "0,3,6" and so on. Normally a user
would start with "0" or "1" to indicate one of the roots of the tree of
data. The default is "0" if currentLocation
is null.Method Detail |
public java.lang.Object selectValue(RenderingContext context, java.lang.Object select)
selectValue
in interface DataObject
oracle.cabo.ui.data.DataObject
context
- the current rendering contextselect
- a select criterion, syntax as defined by the data object
|
Oracle UIX API Reference Release 2.1.22.0.0 B12196-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |