private function _getComponentSetupCommands(__IComponent &$component)
 {
     $return_value = array();
     //update client end-point with current component state:
     $component->updateClient();
     //get all commands from client end-points
     $binding_codes = $component->getBindingCodes();
     foreach ($binding_codes as $binding_code) {
         $ui_binding = __UIBindingManager::getInstance()->getUIBinding($binding_code);
         if ($ui_binding != null) {
             $command = $ui_binding->getClientEndPoint()->getSetupCommand();
             if ($command != null) {
                 $return_value[] = $command;
             }
         }
     }
     $handled_events = __EventHandlerManager::getInstance()->getEventHandler($component->getViewCode())->getComponentHandledEvents($component->getName());
     foreach ($handled_events as $handled_event) {
         if ($handled_event != 'submit') {
             $command = new __AsyncMessageCommand();
             $command->setClass('__RegisterEventListenerCommand');
             $command->setData(array('element' => $component->getId(), 'event' => $handled_event));
             $return_value[] = $command;
         }
     }
     return $return_value;
 }
 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);
 }
 /**
  * Sets the component
  *
  * @param __IComponent $component The component
  */
 public function setComponent(__IComponent &$component)
 {
     $this->_component_id = $component->getId();
     $this->_view_code = $component->getViewCode();
 }