private void render(VolantisProtocol protocol, MultipleValidatorBuilder builder,
MultipleValidator validator) throws ProtocolException {
// This should always work, since this implementation of rendered is
// tightly coupled with XHTMLBasic protocol
XHTMLBasic actualProtocol = (XHTMLBasic) protocol;
// Render script element.
DOMOutputBuffer currentBuffer = getCurrentBuffer(protocol);
openScriptElement(currentBuffer);
StringWriter scriptWriter = new StringWriter();
StylesExtractor stylesExtractor = new StylesExtractor();
try {
// Render multiple validator registration.
String id = validator.getAttributes().getId();
boolean renderRegistration = (id != null);
if (renderRegistration) {
scriptWriter.write("Widget.register(" + createJavaScriptString(id) + ",");
}
// Render multiple validator instantiation
scriptWriter.write("new Widget.MultipleValidator({");
// Render fields involved in validation.
scriptWriter.write("fields:{");
Iterator fieldsIterator = validator.getFieldsIterator();
boolean firstField = true;
while (fieldsIterator.hasNext()) {
FieldAttributes fieldAttributes = (FieldAttributes) fieldsIterator.next();
// Get attributes of refered input element.
String inputId = fieldAttributes.getRef();
XFFormFieldAttributes formFieldAttributes = actualProtocol.getFormFieldAttributes(inputId);
// If no attributes were found, it means that the refered text
// input field
// does not exist. In that case, don't render it.
if (formFieldAttributes != null) {