From 5042df3f7a3f4ea7932a4329559dd93477290322 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Thu, 23 Mar 2006 21:10:05 +0000
Subject: Fixed a bug in triggering onActiveStepChanged event.

---
 framework/Web/UI/WebControls/TMultiView.php | 14 +++++++++-----
 framework/Web/UI/WebControls/TWizard.php    | 18 ++++--------------
 2 files changed, 13 insertions(+), 19 deletions(-)

(limited to 'framework')

diff --git a/framework/Web/UI/WebControls/TMultiView.php b/framework/Web/UI/WebControls/TMultiView.php
index 42e76349..5e9398f3 100644
--- a/framework/Web/UI/WebControls/TMultiView.php
+++ b/framework/Web/UI/WebControls/TMultiView.php
@@ -95,7 +95,7 @@ class TMultiView extends TControl
 			$this->setControlState('ActiveViewIndex',$index,-1);
 			$this->_cachedActiveViewIndex=-1;
 			if($index>=0)
-				$this->activateView($views->itemAt($index));
+				$this->activateView($views->itemAt($index),true);
 		}
 		else
 			throw new TInvalidDataValueException('multiview_activeviewindex_invalid',$index);
@@ -115,7 +115,7 @@ class TMultiView extends TControl
 			return null;
 		$view=$views->itemAt($index);
 		if(!$view->getActive())
-			$this->activateView($view);
+			$this->activateView($view,false);
 		return $view;
 	}
 
@@ -135,20 +135,24 @@ class TMultiView extends TControl
 	 * Activates the specified view.
 	 * If there is any view currently active, it will be deactivated.
 	 * @param TView the view to be activated
+	 * @param boolean whether to trigger OnActiveViewChanged event.
 	 */
-	protected function activateView($view)
+	protected function activateView($view,$triggerViewChangedEvent=true)
 	{
 		if($view->getActive())
 			return;
-		$triggerEvent=$this->getControlStage()>=TControl::CS_STATE_LOADED || !$this->getPage() || !$this->getPage()->getIsPostBack();
+		$triggerEvent=($this->getControlStage()>=TControl::CS_STATE_LOADED || ($this->getPage() && !$this->getPage()->getIsPostBack()));
 		foreach($this->getViews() as $v)
 		{
 			if($v===$view)
 			{
 				$view->setActive(true);
 				if($triggerEvent)
+				{
 					$view->onActivate(null);
-				$this->onActiveViewChanged(null);
+					if($triggerViewChangedEvent)
+						$this->onActiveViewChanged(null);
+				}
 			}
 			else if($v->getActive())
 			{
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index 4591e475..729b1c8f 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -20,8 +20,8 @@ Prado::using('System.Web.UI.WebControls.TDataList');
 /**
  * Class TWizard.
  *
- * TWizard splits a large form and present the user with a series of smaller
- * form to complete. TWizard is analogous to the installation wizard commonly
+ * TWizard splits a large form and presents the user with a series of smaller
+ * forms to complete. TWizard is analogous to the installation wizard commonly
  * used to install software in Windows.
  *
  * The smaller forms are called wizard steps ({@link TWizardStep}, which can be accessed via
@@ -698,9 +698,9 @@ class TWizard extends TWebControl implements INamingContainer
 	public function onInit($param)
 	{
 		parent::onInit($param);
+		$this->ensureChildControls();
 		if($this->getActiveStepIndex()<0 && $this->getWizardSteps()->getCount()>0)
 			$this->setActiveStepIndex(0);
-		$this->ensureChildControls();
 	}
 
 	/**
@@ -1091,8 +1091,8 @@ class TWizard extends TWebControl implements INamingContainer
 		$multiView=$this->getMultiView();
 		$this->_stepContent=new TPanel;
 		$this->_stepContent->getControls()->add($multiView);
-		$multiView->setActiveViewIndex(0);
 		$this->getControls()->add($this->_stepContent);
+		$multiView->setActiveViewIndex(0);
 	}
 
 	/**
@@ -1600,16 +1600,6 @@ class TTemplatedWizardStep extends TWizardStep implements INamingContainer
 	 */
 	private $_navigationContainer=null;
 
-	/**
-	 * Forbids any body content.
-	 * This method overrides the parent implementation and is
-	 * invoked when template is being instantiated.
-	 * @param mixed object instantiated in template
-	 */
-	public function addParsedObject($object)
-	{
-	}
-
 	/**
 	 * Creates child controls.
 	 * This method mainly instantiates the content template, if any.
-- 
cgit v1.2.3