public function startRender(__IComponent &$component) { $component_id = $component->getId(); $event_handler = __EventHandlerManager::getInstance()->getEventHandler($component->getViewCode()); $component_to_validate = $component->getComponentToValidate(); $component_to_validate_id = $component_to_validate->getId(); if (__ResponseWriterManager::getInstance()->hasResponseWriter('livevalidation')) { $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('livevalidation'); } else { $jod_response_writer = new __JavascriptOnDemandResponseWriter('livevalidation'); $jod_response_writer->addJsFileRef('livevalidation/livevalidation_1.3.1.js'); $jod_response_writer->addLoadCheckingVariable('Validate'); $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript'); $javascript_rw->addResponseWriter($jod_response_writer); } $configuration = array('validMessage : ""'); if ($component->getValidateOnlyOnBlur()) { $configuration[] = 'onlyOnBlur: true'; } else { if ($component->getValidateOnlyOnSubmit()) { $configuration[] = 'onlyOnSubmit: true'; } else { $configuration[] = 'wait: ' . $component->getWait(); } } $report_after_component = $component->getComponentForErrorReporting(); $report_after_element = $component->getReportAfterElement(); if ($report_after_component != null) { $configuration[] = 'insertAfterWhatNode: "' . $report_after_component->getId() . '"'; } else { if ($report_after_element != null) { $configuration[] = 'insertAfterWhatNode: "' . $report_after_element . '"'; } } if ($event_handler->isEventHandled('validate', $component_to_validate->getName())) { $configuration[] = 'onValid: function() { (__ClientEventHandler.getInstance()).sendEvent("validate", { validationRule : "' . $component_id . '"}, "' . $component_to_validate_id . '", true); }'; } else { if ($event_handler->isEventHandled('validate', $component->getName())) { $configuration[] = 'onValid: function() { (__ClientEventHandler.getInstance()).sendEvent("validate", { validationRule : "' . $component_id . '"}, "' . $component_id . '", true); }'; } } $on_invalid = $component->getOnInvalid(); if (!empty($on_invalid)) { $configuration[] = 'onInvalid: ' . $on_invalid; } $js_code = "if(\$(\"{$component_to_validate_id}\")) {\n"; $js_code .= "if(!window['{$component_id}']) {\n"; $js_code .= ' window[\'' . $component_id . '\'] = new LiveValidation("' . $component_to_validate_id . '", {' . join(', ', $configuration) . '});' . "\n"; $js_code .= "} else {\n"; $js_code .= ' ' . $component_id . '.initialize("' . $component_to_validate_id . '", {' . join(', ', $configuration) . '});' . "\n"; $js_code .= "}\n"; $js_code .= $this->_getValidLengthJsPart($component); $js_code .= $this->_getValidFormatJsPart($component); $js_code .= $this->_getComponentMatchJsPart($component); $js_code .= $this->_getMandatoryJsPart($component); $js_code .= $this->_getAcceptanceJsPart($component); $js_code .= $this->_getShowMessageJsPart($component); $js_code .= $this->_getAllowedExtensionsJsPart($component); $js_code .= $this->_getNumericalityJsPart($component); $js_code .= $this->_getListenValidateEvent($component); $js_code .= "}\n"; $jod_response_writer->addJsCode($js_code); }