}
elementIndex--;
}
TextAssetReference caption =
((XFFormFieldAttributes)protocolAttributes).getCaption();
// when we found wizard we have to associate this submit button
// with complete action on wizard.
if(null != wizard){
VolantisProtocol protocol = getProtocol(context);
ButtonScriptHandlerAttributes buttonAttributes = new ButtonScriptHandlerAttributes();
String submitId = protocolAttributes.getId();
if(null == submitId){
submitId = protocol.getMarinerPageContext().generateUniqueFCID();
protocolAttributes.setId(submitId);
}
buttonAttributes.setId(submitId);
//if xf:label element was not specified for xf:submit element
//then set label to the default value
if (null == caption) {
((XFFormFieldAttributes)protocolAttributes)
.setCaption(new LiteralTextAssetReference(
DEFAULT_SUBMIT_CAPTION));
}
// wizard is embracing this element
// wizard id is needed for proper action reference desciption
WizardAttributes wizardAttrs = (WizardAttributes)wizard.getProtocolAttributes();
final String wizardId = wizardAttrs.getId();
// associate button with complete action
final List memberList = new ArrayList();
memberList.add(ActionName.COMPLETE);
buttonAttributes.setActionReference(new ActionReference() {
public String getWidgetId() {return wizardId;}
public List getMemberNames() {return memberList;}
});
WidgetModule widgetModule = protocol.getWidgetModule();
try {
WidgetRenderer renderer =
widgetModule.getWidgetRenderer(buttonAttributes);
renderer.renderClose(protocol, buttonAttributes);
WizardRenderer wizardRenderer = (WizardRenderer)
widgetModule.getWidgetRenderer(wizardAttrs);
// remember submit id in wizard renderer
wizardRenderer.setSubmitId(submitId);
} catch (ProtocolException e) {
throw new XDIMEException(e);
}
}
// If an action field is tagged to indicate that its query parameters
// should contain an extra name value pair (used to indicate things
// like which of two submit buttons was pressed to trigger the
// submission) then HTMLActionFieldHandler appends this name value pair
// using the name and initial value specified in the field descriptor.
// If this submit element had a child setvalue element, then it
// requires this name value pair and we should set the flag. We set the
// flag to the caption string (for backwards compatibility with XDIME1
// - there is no other reason to set it to this string).
if (caption != null) {
// We only want to map fields that have an initial value (i.e. had
// a child setvalue element with either a value attribute or some
// body content).
if (fieldDescriptor.getInitialValue() != null) {
String captionString =
caption.getText(TextEncoding.PLAIN);
fieldDescriptor.setFieldTag(captionString);
((XFFormFieldAttributes)protocolAttributes).
setFieldDescriptor(fieldDescriptor);
}
}