summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-01-25 14:11:32 +0000
committerxue <>2006-01-25 14:11:32 +0000
commit3afd35b166267c00f368239b00662866c79bb090 (patch)
tree9406d19428734aa05250f58b064ddbdad20c1c85
parentbf66ad7bb36e881f53437491333940d74d77139e (diff)
Changed back the usage of ensureChildControls in TTemplateControl. Added TControl::getRegisteredObject. Modified LabeledTextBox accordingly.
-rw-r--r--framework/Web/UI/TControl.php12
-rw-r--r--framework/Web/UI/TTemplateControl.php1
-rw-r--r--tests/FunctionalTests/protected/pages/UI/LabeledTextBox.php6
3 files changed, 16 insertions, 3 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index a87563b4..8b272f30 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -871,6 +871,18 @@ class TControl extends TComponent
}
/**
+ * Returns the named registered object.
+ * A component with explicit ID on a template will be registered to
+ * the template owner. This method allows you to obtain this component
+ * with the ID.
+ * @return mixed the named registered object. Null if object is not found.
+ */
+ public function getRegisteredObject($name)
+ {
+ return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null;
+ }
+
+ /**
* This method is invoked after the control is instantiated by a template.
* When this method is invoked, the control should have a valid TemplateControl
* and has its properties initialized according to template configurations.
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index e3c4d3e9..72731ecd 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -65,7 +65,6 @@ class TTemplateControl extends TControl implements INamingContainer
{
foreach($tpl->getDirective() as $name=>$value)
$this->setSubProperty($name,$value);
- $this->ensureChildControls();
}
}
diff --git a/tests/FunctionalTests/protected/pages/UI/LabeledTextBox.php b/tests/FunctionalTests/protected/pages/UI/LabeledTextBox.php
index 3a3eba2d..15702d29 100644
--- a/tests/FunctionalTests/protected/pages/UI/LabeledTextBox.php
+++ b/tests/FunctionalTests/protected/pages/UI/LabeledTextBox.php
@@ -15,7 +15,8 @@ class LabeledTextBox extends TTemplateControl
*/
public function getTextBox()
{
- return $this->textbox;
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('textbox');
}
/**
@@ -23,7 +24,8 @@ class LabeledTextBox extends TTemplateControl
*/
public function getLabel()
{
- return $this->label;
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('label');
}
}