UINode node
) throws IOException
{
Object newPath = context.getLocalProperty(0, _NEW_PATH_KEY, null);
UIXHierarchy component = getHierarchyBase(context, node);
Object oldPath = component.getRowKey(); // Save the current key
component.setRowKey(null);
String nameString =
BaseLafUtils.getStringAttributeValue(context, node, NAME_ATTR);
String idString =
BaseLafUtils.getStringAttributeValue(context, node, ID_ATTR);
component.setRowKey(newPath);
URLEncoder encoder = context.getURLEncoder();
String eventKey = encoder.encodeParameter(EVENT_PARAM);
String sourceKey = encoder.encodeParameter(SOURCE_PARAM);
String valueKey = encoder.encodeParameter(VALUE_PARAM);
String sizeKey = encoder.encodeParameter(SIZE_PARAM);
String partialTargetsKey = encoder.encodeParameter(PARTIAL_TARGETS_PARAM);
// Get any partial targets - encoded in String form
String partialTargets = _getPartialTargets(context, node);
int totalItems = component.getRowCount();
int selectedIndex = component.getRowIndex();
if (totalItems <= 0)
{
component.setRowKey(oldPath);
return;
}
int currentIndex = component.getRowIndex();
UIComponent stamp = component.getFacet(UIXProcess.NODE_STAMP_FACET);
int backButtonIndex = ProcessUtils.getBackIndex(component,
stamp,
currentIndex);
int nextButtonIndex = ProcessUtils.getNextIndex(component,
stamp,
currentIndex);
boolean showBackButton = backButtonIndex != ProcessUtils.NO_INDEX;
boolean showNextButton = nextButtonIndex != ProcessUtils.NO_INDEX;
boolean narrowScreenPDA = supportsNarrowScreen(context);
// bail if no buttons shown
if (!showBackButton && !showNextButton)
{
component.setRowKey(oldPath);
return;
}
// get form name (#1308799)
String formName = XhtmlLafUtils.getParentFormName(context);
// If we don't support navigation (e.g., printable pages),
// lie and claim we support scripting (even though we probably don't).
// This will give us the highest fidelity output - that is,
// we avoid creating submit buttons.
boolean supportsScripting = (supportsScripting(context) ||
!supportsNavigation(context));
if (supportsScripting)
{
// render hidden fields to hold the form data
_renderHiddenFields( context,
formName,
eventKey,
sourceKey,
valueKey,
sizeKey,
partialTargetsKey,
partialTargets);
}
UINode backButton = null;
Object nonJSBackButtonText = null;
// In the case of narrow-screen PDAs, the next and previous buttons
// are not rendered to reduce the component's width.
showBackButton = showBackButton && !narrowScreenPDA;
showNextButton = showNextButton && !narrowScreenPDA;
// set up the back button
if (showBackButton)
{
BoundValue buttonTextandAccessKeyBV =
new SkinTranslatedBoundValue( _SINGLE_BACK_TEXT_KEY);
Object buttonTextBV = new AccessKeyBoundValue(buttonTextandAccessKeyBV,
false);
Object buttonAccessKeyBV = new AccessKeyBoundValue(
buttonTextandAccessKeyBV,
true);
if (supportsScripting)
{
component.setRowIndex(backButtonIndex);
boolean immediate = Boolean.TRUE.equals(
stamp.getAttributes().get(UIXCommand.IMMEDIATE_KEY));
Object destination = stamp.getAttributes().get("destination");
component.setRowIndex(currentIndex);
backButton = createSingleItemSubmitButton(
true,
buttonTextBV,
buttonAccessKeyBV,
destination,
ProcessUtils.getSubmitScriptCall(
context,
formName,
eventKey,
sourceKey,
nameString,
valueKey,
selectedIndex - 1,
sizeKey,
0,
!immediate,
null,
null));
}
else
{
nonJSBackButtonText = buttonTextBV;
}
}
UINode nextButton = null;
// set up the next button
if (showNextButton)
{
String buttonTextKey = ((totalItems == 2)
? _SINGLE_CONTINUE_TEXT_KEY
: _SINGLE_NEXT_TEXT_KEY);
BoundValue buttonTextandAccessKeyBV =
new SkinTranslatedBoundValue(buttonTextKey);
Object buttonTextBV = new AccessKeyBoundValue( buttonTextandAccessKeyBV,
false);
Object buttonAccessKeyBV = new AccessKeyBoundValue(
buttonTextandAccessKeyBV,
true);
// The navBar needs its initial focus to be on the Next button,
// according to the BLAF. Render a special id on the Next button
// if this navBar is to have the initial focus. (unless it needs
// initial focus, the Next button does not have an id on it)
String buttonID = _getIDForFocus(context, node);
// set the destination
if (supportsScripting)
{
component.setRowIndex(nextButtonIndex);
boolean immediate = Boolean.TRUE.equals(
stamp.getAttributes().get(UIXCommand.IMMEDIATE_KEY));
Object destination = stamp.getAttributes().get("destination");
component.setRowIndex(currentIndex);
MutableUINode mutableNextButton =
createSingleItemSubmitButton(false,
buttonTextBV,
buttonAccessKeyBV,
destination,
ProcessUtils.getSubmitScriptCall(
context,
formName,
eventKey,
sourceKey,
nameString,
valueKey,
selectedIndex + 1,
sizeKey,
1,
!immediate, null, null));
if (buttonID != null)
{
mutableNextButton.setID(buttonID);
}
nextButton = mutableNextButton;
context.setLocalProperty(_NEXT_BUTTON_KEY, nextButton);
}
else
{
// For Non-JavaScript browsers, encode the parameter name and value
// pairs required for the next button's funtionality. This encoded
// value would be used as the name attribute of the element that
// would be rendered for the next button's funtionality.
String nameAttri = XhtmlUtils.getEncodedNameAttribute (
// Array should be in the order of parameter
// name and value pair
new String[]{SOURCE_PARAM,
nameString,
EVENT_PARAM,
UIConstants.GOTO_EVENT,
VALUE_PARAM,
Long.toString(selectedIndex + 1),
SIZE_PARAM,
Integer.toString(1)});
context.setLocalProperty(_NON_JS_NEXT_BUTTON_NAME_ATTR, nameAttri);
context.setLocalProperty(_NON_JS_NEXT_BUTTON_TEXT, buttonTextBV);
}
}
// start the rendering
ResponseWriter writer = context.getResponseWriter();
boolean renderAsTable = _renderAsTable(context, node);
if (renderAsTable)
{
writer.startElement("table", NodeUtils.getUIComponent(context, node));
renderLayoutTableAttributes(context, "0", null);
String uniqueId = UniqueCompositeId.getId(idString, null);
writer.writeAttribute("id", uniqueId, null);
writer.startElement("tr", null);
}
// we only want to render the ID in the "td" if renderAsTable is false.
// render the base ID the first time only, then we render the subIDs.
_renderStartTableCell(context, node, writer, renderAsTable, true);
// don't render back button on first step
if (showBackButton)
{
if (supportsScripting)
{
backButton.render(context);
}
else
{
// For Non-JavaScript browsers, render an input element(type= submit)
// to submit the page. The name attribute of this element is encoded
// with parameter name and value pairs thus it would enable browsers
// to include the name of this element in its payLoad if it submits the
// page.
String nameAttri = XhtmlUtils.getEncodedNameAttribute (
// Array should be in the order of parameter name
// and value pair
new String[]{SOURCE_PARAM,
nameString,
EVENT_PARAM,
UIConstants.GOTO_EVENT,
VALUE_PARAM,
Long.toString(selectedIndex - 1),
SIZE_PARAM,
Integer.toString(0)});
String buttonText = ((AccessKeyBoundValue)nonJSBackButtonText)
.getValue(context).toString();
_renderSubmitButtonNonJSBrowser(context, buttonText, nameAttri);
}
writer.endElement("td");
_renderSpacerCell(context);
// we only want to render the ID in the "td" if renderAsTable is false.
// render the subID.
_renderStartTableCell(context, node, writer, renderAsTable, false);
}
//
// create the label and render it
//
writer.writeAttribute(NOWRAP_ATTRIBUTE, Boolean.TRUE, null);
component.setRowKey(oldPath);
}