private DOMOutputBuffer stringOutputBuffer;
// Javadoc inherited.
public void doRenderOpen(VolantisProtocol protocol,
MCSAttributes attributes) throws ProtocolException {
DOMProtocol domProtocol = (DOMProtocol) protocol;
require(WidgetScriptModules.BASE_COMMON,protocol, attributes);
// Open a placeholder span element for the widget
// content, which will converted to the JavaScript string.
// Generate a HTML ID for it, so that it can be referenced
// from JavaScript code.
placeholderSpanAttributes = new SpanAttributes();
placeholderSpanAttributes.copy(attributes);
if (placeholderSpanAttributes.getId() == null) {
placeholderSpanAttributes.setId(protocol.getMarinerPageContext().generateUniqueFCID());
}
// Now, this is a hack to better the user experience.
// In almost most cases, the 'display' stylistic attribute for this
// element is 'none', because we don't want the user to see rendered
// string on the page. But in the most common configuration, MCS renders
// that property into the stylesheet. Some browsers before
// downloading stylesheets, displays the RAW content of the page,
// including this string. This looks very messy. That's why we
// put display:none into the inline styles right here.
if (attributes.getStyles()
.getPropertyValues()
.getComputedValue(StylePropertyDetails.DISPLAY) == DisplayKeywords.NONE) {
Element element = openSpanElement(protocol, attributes);
element.setAttribute("style", "display:none");
}
// Create and output buffer for the widget content.
// This will be an instance of DOMOutputBuffer, because the protocol
// used is an instance of DOMProtocol.
stringOutputBuffer = (DOMOutputBuffer) domProtocol.getOutputBufferFactory().createOutputBuffer();
// Push the buffer on the stack, so that the widget content will be
// rendered to that buffer.
protocol.getMarinerPageContext().pushOutputBuffer(stringOutputBuffer);
}