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;
// 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;
// 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
{
backButton = ProcessUtils.createSubmitButton(context,
buttonTextBV,
buttonAccessKeyBV,
null,
formName,
false,
eventKey,
sourceKey,
nameString,
valueKey,
selectedIndex - 1,
sizeKey,
0);
}
}
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;
}
else
{
nextButton = ProcessUtils.createSubmitButton(context,
buttonTextBV,
buttonAccessKeyBV,
buttonID,
formName,
false,
eventKey,
sourceKey,
nameString,
valueKey,
selectedIndex + 1,
sizeKey,
1);
}
context.setLocalProperty(_NEXT_BUTTON_KEY, nextButton);
}
// 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)
{
backButton.render(context);
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);
}