/** * Handles an UI event by executing a method associated to the given event * * @param __UIEvent $event The event to handle * @return mixed */ public function handleEvent(__UIEvent &$event) { $return_value = null; //get event info: $component = $event->getComponent(); $event_name = $event->getEventName(); $extra_info = $event->getExtraInfo(); if ($event_name != 'beforeRender' && $event_name != 'afterRender' && $event_name != 'create') { __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code)->setDirty(true); } try { //handle an event associated to a component: if ($component != null) { //get component name: $component_name = $component->getName(); //if the component can handle the event, will call to the component event handler if ($component->isEventHandled($event_name)) { $component->handleEvent($event); } //after that, even if the component has handle the event, will execute the event handler method: //1. resolve the concrete handler method: $event_handler_method = $this->_getEventHandlerMethod($event_name, $component_name); //2. call to the concrete handler method: if (method_exists($this, $event_handler_method)) { $return_value = call_user_func(array($this, $event_handler_method), $event); switch (strtoupper($event_name)) { case 'VALIDATE': //first, let's return true if no __ValidationException has been sent $return_value = true; //and reset in case of, any validation component associated to the event's component if (is_array($extra_info) && key_exists('validationRule', $extra_info)) { $validation_rule = __ComponentPool::getInstance()->getComponent($extra_info['validationRule']); $validation_rule->setErrorMessage(null); } break; } } } } catch (__ValidationException $validation_exception) { $return_value = false; //set to false, because a validation exception has been raised if (is_array($extra_info) && key_exists('validationRule', $extra_info)) { $validation_rule = __ComponentPool::getInstance()->getComponent($extra_info['validationRule']); $validation_rule->setErrorMessage($validation_exception->getMessage()); } } return $return_value; }
public function handleEvent(__UIEvent &$event) { if (strtoupper($event->getEventName()) == 'CLOSE') { $this->_visible = false; } }
public function handleEvent(__UIEvent &$event) { $event_name = strtoupper($event->getEventName()); switch ($event_name) { case 'UPLOADING': //free the session to allow more incoming requests: //@todo change the session handler to synchronize sessions between requests __SessionManager::getInstance()->endSession(); $this->setStatus(__IUploaderComponent::UPLOAD_STATUS_UPLOADING); $this->setProgress(0); while ($this->getStatus() == __IUploaderComponent::UPLOAD_STATUS_UPLOADING) { $this->updateStatus(); sleep(1); } break; case 'CANCELUPLOAD': $this->reset(); $this->setStatus(__IUploaderComponent::UPLOAD_STATUS_CANCELLED); break; } }