throws PAPIException {
MarinerPageContext pageContext
= ContextInternals.getMarinerPageContext(context);
XFOptionAttributes attributes = (XFOptionAttributes) papiAttributes;
// Create a new protocol attributes object every time, as this element
// could be reused before the attributes have actually been finished with
// by the protocol.
com.volantis.mcs.protocols.SelectOption pattributes
= new com.volantis.mcs.protocols.SelectOption();
// Copy the base attributes.
pattributes.setId(attributes.getId());
pattributes.setTagName("xfoption");
// get styles for the current element and set it on the MCSAttributes
final StylingEngine stylingEngine = pageContext.getStylingEngine();
pattributes.setStyles(stylingEngine.getStyles());
PolicyReferenceResolver resolver =
pageContext.getPolicyReferenceResolver();
TextAssetReference object;
// Process the caption as a mariner expression.
object = resolver.resolveQuotedTextExpression(attributes.getCaption());
pattributes.setCaption(object);
// Process the prompt as a mariner expression.
object = resolver.resolveQuotedTextExpression(attributes.getPrompt());
pattributes.setPrompt(object);
// Set the value attribute.
pattributes.setValue(attributes.getValue());
// Find the caption pane
PaneInstance captionPaneInstance = getPaneInstance(
pageContext, attributes.getCaptionPane());
if ((captionPaneInstance != null) &&
(captionPaneInstance.getFormat() != null)) {
pattributes.setCaptionContainerInstance(captionPaneInstance);
}
// And the entry pane
PaneInstance entryPaneInstance = getPaneInstance(
pageContext, attributes.getEntryPane());
if ((entryPaneInstance != null) &&
(entryPaneInstance.getFormat() != null)) {
pattributes.setEntryContainerInstance(entryPaneInstance);
}
// Set the styles for the caption
final String captionClass = attributes.getCaptionClass();
if (captionClass != null) {
final String namespace = XDIMESchemata.CDM_NAMESPACE;
final PAPIAttributes genericAttributes =
attributes.getGenericAttributes();
genericAttributes.setAttributeValue(null, "class", captionClass);
stylingEngine.startElement(namespace, "xfoption",
(Attributes) genericAttributes);
pattributes.setCaptionStyles(stylingEngine.getStyles());
stylingEngine.endElement(namespace, "xfoption");
}
// Set the selected attribute
String selected = attributes.getSelected();
if (selected != null) {
boolean isSelected = new Boolean(selected).booleanValue();
pattributes.setSelected(isSelected);
}