From 71ca767f51b53d6b162bd6fdccfb125f2dc94d35 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 30 Dec 2005 22:19:07 +0000 Subject: Added TListBox samples. --- .../pages/Controls/Samples/TListBox/Home.page | 121 +++++++++++---------- .../pages/Controls/Samples/TListBox/Home.php | 46 +++++++- framework/Exceptions/messages.txt | 1 + framework/Web/UI/TControl.php | 2 + framework/Web/UI/WebControls/TListControl.php | 4 +- 5 files changed, 111 insertions(+), 63 deletions(-) diff --git a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page index 43ab16f7..776fc073 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page @@ -1,81 +1,92 @@ -

TTextBox Samples

+

TListBox Samples

-
SingleLine and Password Text Boxes
- -Text box with default settings: - -
- -Password text box: - +
Single Selection List Box
+List box with default settings:
+
-Text box with customized color, font, columns, maximum length: - +List box with initial items:
+ + + + + +
-Disabled text box: - +List box with customized row number, color and font:
+ + + + + +
-Read-only text box: - +Auto postback list box:
+ + + + + + +
-Auto postback text box: - +List box's behavior upon postback:
+ + + + + + + +
- -Text box's behavior upon postback: - - -
-
MultiLine Text Boxes
- -Text box with default settings:
- +
Multiple Selection List Box
+Use Shift + Left Click to change selection
- -Text box with customized dimensions, font and content:
- - -This is a multiline text box. -In HTML, it is displayed as a textarea. - - +List box with default settings:
+
-Disabled text box:
- +List box with initial items:
+ + + + + +
-Read-only text box with text-wrapping disabled:
- +Auto postback list box:
+
+ + + + + + +
+
-Auto postback text box:
- +List box's behavior upon postback:
+ + + + + + +
-
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php index 5f812c9e..6b1d07e1 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php @@ -1,15 +1,51 @@ Text="text changed"; + $index=$sender->SelectedIndex; + $value=$sender->SelectedValue; + $text=$sender->SelectedItem->Text; + $this->SelectionResult->Text="Your selection is (Index: $index, Value: $value, Text: $text)."; } - public function submitText($sender,$param) + public function buttonClicked($sender,$param) { - $this->TextBox1->Text="You just entered '".$this->TextBox1->Text."'."; + $index=$this->ListBox1->SelectedIndex; + $value=$this->ListBox1->SelectedValue; + $text=$this->ListBox1->SelectedItem->Text; + $this->SelectionResult2->Text="Your selection is (Index: $index, Value: $value, Text: $text)."; + } + + public function multiSelectionChanged($sender,$param) + { + $indices=$sender->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$sender->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)\n"; + } + if($result==='') + $this->MultiSelectionResult->Text='Your selection is empty.'; + else + $this->MultiSelectionResult->Text='Your selection is: '.$result; + } + + public function buttonClicked2($sender,$param) + { + $indices=$this->ListBox2->SelectedIndices; + $result=''; + foreach($indices as $index) + { + $item=$this->ListBox2->Items[$index]; + $result.="(Index: $index, Value: $item->Value, Text: $item->Text)\n"; + } + if($result==='') + $this->MultiSelectionResult2->Text='Your selection is empty.'; + else + $this->MultiSelectionResult2->Text='Your selection is: '.$result; } } diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index c31c49d2..8547527f 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -130,6 +130,7 @@ theme_databind_forbidden = Databind cannot be used in theme '%s' for control theme_property_readonly = Skin is being applied to a read-only control property '%s.%s'. theme_property_undefined = Skin is being applied to an inexistent control property '%s.%s'. +control_object_reregistered = Duplicated object ID '%s' found. control_id_invalid = %s.ID '%s' is invalid. Only alphanumeric and underline characters are allowed. The first character must be an alphabetic or underline character. control_skinid_unchangeable = %s.SkinID cannot be modified after a skin has been applied to the control or the child controls have been created. control_enabletheming_unchangeable = %s.EnableTheming cannot be modified after the child controls have been created. diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 372e87df..545bdf66 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -828,6 +828,8 @@ class TControl extends TComponent */ public function registerObject($name,$object) { + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) + throw new TInvalidOperationException('control_object_reregistered',$name); $this->_rf[self::RF_NAMED_OBJECTS][$name]=$object; } diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 7e81fd6c..ec7df0c9 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -24,6 +24,7 @@ abstract class TListControl extends TDataBoundControl $writer->addAttribute('multiple','multiple'); if($this->getAutoPostBack() && $page->getClientSupportsJavaScript()) { + $writer->addAttribute('id',$this->getClientID()); $options = $this->getAutoPostBackOptions(); $scripts = $this->getPage()->getClientScript(); $postback = $scripts->getPostBackEventReference($this,'',$options,false); @@ -387,9 +388,6 @@ abstract class TListControl extends TDataBoundControl } } - - - class TListItemCollection extends TList { private $_items=null; -- cgit v1.2.3