From 6b1d87352911e43672b46b7a65a3c90dd8e5b8b1 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 30 Sep 2006 01:49:58 +0000 Subject: Fixed #403 --- .../ActiveControls/TActiveListControlAdapter.php | 30 +++++++++++++++++++--- .../protected/pages/ActiveDropDownList.page | 1 + .../protected/pages/ActiveDropDownList.php | 15 ++++++++--- .../tests/ActiveDropDownListTestCase.php | 6 +++++ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php index 9bdef077..49cb07c8 100644 --- a/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php @@ -44,8 +44,11 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo public function setSelectedIndex($index) { if($this->canUpdateClientSide()) + { + $this->updateListItems(); $this->getPage()->getCallbackClient()->select( $this->getControl(), 'Index', $index); + } } /** @@ -56,6 +59,7 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo { if($this->canUpdateClientSide()) { + $this->updateListItems(); $n = $this->getControl()->getItemCount(); $list = array(); foreach($indices as $index) @@ -77,8 +81,11 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo public function setSelectedValue($value) { if($this->canUpdateClientSide()) + { + $this->updateListItems(); $this->getPage()->getCallbackClient()->select( $this->getControl(), 'Value', $value); + } } /** @@ -89,6 +96,7 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo { if($this->canUpdateClientSide()) { + $this->updateListItems(); $list = array(); foreach($values as $value) $list[] = $value; @@ -104,7 +112,10 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo public function clearSelection() { if($this->canUpdateClientSide()) + { + $this->updateListItems(); $this->getPage()->getCallbackClient()->select($this->getControl(), 'Clear'); + } } /** @@ -112,11 +123,14 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo */ public function updateListItems() { - if($this->canUpdateClientSide() && $this->getControl()->getHasItems()) + if($this->canUpdateClientSide()) { $items = $this->getControl()->getItems(); - if($items instanceof TActiveListItemCollection && $items->getListHasChanged()) - $this->getPage()->getCallbackClient()->setListItems($this->getControl(), $items); + if($items instanceof TActiveListItemCollection + && $items->getListHasChanged()) + { + $items->updateClientSide(); + } } } } @@ -182,6 +196,16 @@ class TActiveListItemCollection extends TListItemCollection return $this->_hasChanged; } + /** + * Update client-side list items. + */ + public function updateClientSide() + { + $client = $this->getControl()->getPage()->getCallbackClient(); + $client->setListItems($this->getControl(), $this); + $this->_hasChanged=false; + } + /** * Inserts an item into the collection. * The new option is added on the client-side during callback. diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.page index 8b8962a8..49b18520 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.page +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.page @@ -19,6 +19,7 @@ + diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.php index 7060d84b..10541885 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveDropDownList.php @@ -4,7 +4,7 @@ class ActiveDropDownList extends TPage { function list1_changed($sender) { - $this->label1->setText("Selection 1: ".$sender->getSelectedValue()); + $this->label1->setText("Selection 1: ".$sender->getSelectedValue()); $this->addOptionsToList2($sender->getSelectedValue()); } @@ -19,21 +19,28 @@ class ActiveDropDownList extends TPage { $this->label1->setText("Selection 2: ".$sender->getSelectedValue()); } - + function select_index_3() { $this->list1->setSelectedIndex(3); } - + function clear_selections() { $this->list1->clearSelection(); } - + function select_value_2() { $this->list1->setSelectedValue("value 2"); } + + function select_index_3_plus() + { + $this->list1->setSelectedValue("value 3"); + $this->list1_changed($this->list1); + $this->list2->setSelectedValue("value 3 - item 3"); + } } ?> \ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php index 9d3ad9c3..44435199 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveDropDownListTestCase.php @@ -35,6 +35,12 @@ class ActiveDropDownListTestCase extends SeleniumTestCase $this->pause(800); $this->assertText("label1", "Selection 2: value 3 - item 5"); + $this->click('button4'); + $this->pause(800); + $this->assertSelected('list1', 'item 3'); + $this->pause(300); + $this->assertSelected('list2', 'value 3 - item 3'); + } } -- cgit v1.2.3