summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-05-04 02:36:22 +0000
committerxue <>2006-05-04 02:36:22 +0000
commita14913019919d7b6c2d13769b151a645b5226e02 (patch)
tree6a52d262a2d400cf1097ddc23e912d7e32f8715d
parent57284b8cfbd15a04d8a23f324e76f694d6bd3dfe (diff)
Fixed an issue about instantiating a template: direct child controls are added to page hierarchy at the last.
-rw-r--r--framework/Web/UI/TTemplateManager.php33
-rw-r--r--framework/Web/UI/WebControls/TWizard.php10
2 files changed, 37 insertions, 6 deletions
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 86567243..ee38405b 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -259,6 +259,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
if(($page=$tplControl->getPage())===null)
$page=$this->getService()->getRequestedPage();
$controls=array();
+ $directChildren=array();
foreach($this->_tpl as $key=>$object)
{
$parent=isset($controls[$object[0]])?$controls[$object[0]]:$tplControl;
@@ -290,7 +291,10 @@ class TTemplate extends TApplicationComponent implements ITemplate
// apply attributes
foreach($properties as $name=>$value)
$this->configureControl($component,$name,$value);
- $component->createdOnTemplate($parent);
+ if($parent===$tplControl)
+ $directChildren[]=$component;
+ else
+ $component->createdOnTemplate($parent);
}
else if($component instanceof TComponent)
{
@@ -304,7 +308,10 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
foreach($properties as $name=>$value)
$this->configureComponent($component,$name,$value);
- $parent->addParsedObject($component);
+ if($parent===$tplControl)
+ $directChildren[]=$component;
+ else
+ $parent->addParsedObject($component);
}
}
else // string
@@ -314,12 +321,30 @@ class TTemplate extends TApplicationComponent implements ITemplate
// need to clone a new object because the one in template is reused
$o=clone $object[1];
$o->setContainer($tplControl);
- $parent->addParsedObject($o);
+ if($parent===$tplControl)
+ $directChildren[]=$o;
+ else
+ $parent->addParsedObject($o);
}
else
- $parent->addParsedObject($object[1]);
+ {
+ if($parent===$tplControl)
+ $directChildren[]=$object[1];
+ else
+ $parent->addParsedObject($object[1]);
+ }
}
}
+ // delay setting parent till now because the parent may cause
+ // the child to do lifecycle catchup which may cause problem
+ // if the child needs its own child controls.
+ foreach($directChildren as $control)
+ {
+ if($control instanceof TControl)
+ $control->createdOnTemplate($tplControl);
+ else
+ $tplControl->addParsedObject($control);
+ }
}
/**
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index 3af09a95..fb0c941d 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -894,8 +894,13 @@ class TWizard extends TWebControl implements INamingContainer
$activeStep=$this->getActiveStep();
$activeStepIndex=$this->getActiveStepIndex();
- if(!$this->_navigation || $activeStepIndex<0 || $activeStepIndex>=$wizardSteps->getCount())
+ if(!$this->_navigation)
return;
+ else if($activeStepIndex<0 || $activeStepIndex>=$wizardSteps->getCount())
+ {
+ $this->_navigation->setVisible(false);
+ return;
+ }
// set visibility of different types of navigation panel
$showStandard=true;
@@ -1184,7 +1189,8 @@ class TWizard extends TWebControl implements INamingContainer
$this->_stepContent=new TPanel;
$this->_stepContent->getControls()->add($multiView);
$this->getControls()->add($this->_stepContent);
- $multiView->setActiveViewIndex(0);
+ if($multiView->getViews()->getCount())
+ $multiView->setActiveViewIndex(0);
}
/**