function BindStatus($path, $textDomain = '', $htmlEscape = null) { $this->path = $path; $this->htmlEscape = is_html_escape($htmlEscape) === true; $this->textDomain = $textDomain; // determine name of the object and property $beanName = null; $dotPos = strpos($path, NESTED_PATH_SEPARATOR); if ($dotPos === FALSE) { // property not set, only the object itself $beanName = $path; $this->expression = null; } else { $beanName = substr($path, 0, $dotPos); $this->expression = substr($path, $dotPos + 1); } $this->bindingResult =& RequestUtils::getBindingResult($beanName); if ($this->bindingResult != null) { // Usual case: A BindingResult is available as request attribute. // Can determine error codes and messages for the given expression. // Can use a custom PropertyEditor, as registered by a form controller. if ($this->expression != null) { if ("*" == $this->expression) { $this->objectErrors =& $this->bindingResult->getAllErrors(); } else { if (str_ends_with($this->expression, "*")) { $this->objectErrors = $this->bindingResult->getFieldErrors($this->expression); } else { $this->objectErrors = $this->bindingResult->getFieldErrors($this->expression); $this->value = $this->bindingResult->getFieldValue($this->expression); $this->valueType = $this->bindingResult->getFieldType($this->expression); $this->editor =& $this->bindingResult->getCustomEditor($this->expression); } } } else { $this->objectErrors =& $this->bindingResult->getGlobalErrors(); } $this->_initErrorCodes(); } else { // No BindingResult available as request attribute: // Probably forwarded directly to a form view. // Let's do the best we can: extract a plain target if appropriate. $target =& RequestUtils::getModelObject($beanName); if ($target == null) { show_error('BindStatus', "Neither BindingResult nor plain target object for bean name '" . $beanName . "' available as request attribute"); } if ($this->expression != null && $this->expression != "*" && !str_ends_with($this->expression, "*")) { $bw =& new BeanWrapper($target); $this->valueType =& $bw->getPropertyType($this->expression); $this->value =& $bw->getPropertyValue($this->expression); } $this->errorCodes = array(); $this->errorMessages = array(); } if ($htmlEscape && is_string($this->value)) { $this->value = specialchars($this->value); } }