Key properties can be requested as part of an Oracle Commerce Navigation query (ENEQuery).
By
default, key properties are not returned by navigation requests to avoid extra
communication when not needed. To request key properties, use the
ENEQuery.setNavKeyProperties method:
ENEQuery query = ... query.setNavKeyProperties(KEY_PROPS_ALL);
To retrieve the key properties from the corresponding Navigation result, use the Navigation.getKeyProperties method:
ENEQueryResults results = … Map keyPropMap = results.getNavigation().getKeyProperties();
This method returns a Map from String key names to KeyProperties
objects, which implement the
com.endeca.navigation.PropertyContainer interface,
providing access to property values through the same interface as an Oracle Commerce
record (ERec object).
Example 57. Example: rendering all key properties
For example, to render all of the key properties returned by the MDEX Engine, one could use the following code sample:
Map keyProps = nav.getKeyProperties();
Iterator props = keyProps.values().iterator();
while (props.hasNext()) {
KeyProperties prop = (KeyProperties)props.next();
// Each key property has a key and a set of values
String keyPropName = (String)prop.getKey();
// Get the values which are stored as a PropertyMap
PropertyMap propVals = (PropertyMap)prop.getProperties();
%>
<tr><td <%= keyPropName %> </td></tr>
<%
// Display properties
Iterator containedProps = propVals.entrySet().iterator();
// Iterate over the properties
while (containedProps.hasNext()) {
// Display property
Property propMap = (Property)containedProps.next();
String propKey = (String)propMap.getKey();
String propVal = (String)propMap.getValue();
%>
<tr><td><%= propKey %>:</td><td><%= propVal %></td></tr>
<%
}
}

