summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2005-12-30 22:19:07 +0000
committerxue <>2005-12-30 22:19:07 +0000
commit71ca767f51b53d6b162bd6fdccfb125f2dc94d35 (patch)
treee239318ea5ef056900440bd89af7fced400539ae
parentf5545817ebd1aeea0fd1527720ab83954665689e (diff)
Added TListBox samples.
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page121
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php46
-rw-r--r--framework/Exceptions/messages.txt1
-rw-r--r--framework/Web/UI/TControl.php2
-rw-r--r--framework/Web/UI/WebControls/TListControl.php4
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 @@
<com:TContent ID="body">
-<h1>TTextBox Samples</h1>
+<h1>TListBox Samples</h1>
<div class="samplepanel">
-<div class="sampletitle">SingleLine and Password Text Boxes</div>
-
-Text box with default settings:
-<com:TTextBox />
-<br/>
-
-Password text box:
-<com:TTextBox TextMode="Password" />
+<div class="sampletitle"><tt>Single</tt> Selection List Box</div>
+List box with default settings:<br/>
+<com:TListBox />
<br/>
-Text box with customized color, font, columns, maximum length:
-<com:TTextBox
- Text="text"
- ForeColor="yellow"
- BackColor="blue"
- Font.Size="14pt"
- Columns="4"
- MaxLength="6"
-/>
+List box with initial items:<br/>
+<com:TListBox>
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+</com:TListBox>
<br/>
-Disabled text box:
-<com:TTextBox Text="disabled" Enabled="false" />
+List box with customized row number, color and font:<br/>
+<com:TListBox Rows="3" ForeColor="blue" Font.Size="14pt">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+</com:TListBox>
<br/>
-Read-only text box:
-<com:TTextBox Text="read only" ReadOnly="true" />
+Auto postback list box:<br/>
+<com:TListBox AutoPostBack="true" SelectedIndexChanged="selectionChanged">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+</com:TListBox>
+<com:TLabel ID="SelectionResult" ForeColor="red" />
<br/>
-Auto postback text box:
-<com:TTextBox Text="change me" AutoPostBack="true" TextChanged="textChanged" />
+List box's behavior upon postback:<br/>
+<com:TListBox ID="ListBox1">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" />
+</com:TListBox>
+<com:TButton Text="Submit" Click="buttonClicked"/>
+<com:TLabel ID="SelectionResult2" ForeColor="red" />
<br/>
-
-Text box's behavior upon postback:
-<com:TTextBox ID="TextBox1" Text="text" />
-<com:TButton Text="Submit" Click="submitText" />
-
</div>
<div class="samplepanel">
-<div class="sampletitle">MultiLine Text Boxes</div>
-
-Text box with default settings:<br/>
-<com:TTextBox TextMode="MultiLine" />
+<div class="sampletitle"><tt>Multiple</tt> Selection List Box</div>
+<i>Use Shift + Left Click to change selection</i>
<br/>
-
-Text box with customized dimensions, font and content:<br/>
-<com:TTextBox TextMode="MultiLine" Rows="6" Columns="60" Font.Italic="true">
-<prop:Text>
-This is a multiline text box.
-In HTML, it is displayed as a textarea.
-</prop:Text>
-</com:TTextBox>
+List box with default settings:<br/>
+<com:TListBox SelectionMode="Multiple" />
<br/>
-Disabled text box:<br/>
-<com:TTextBox
- TextMode="MultiLine"
- Text="disabled"
- Enabled="false" />
+List box with initial items:<br/>
+<com:TListBox SelectionMode="Multiple">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" Selected="true" />
+</com:TListBox>
<br/>
-Read-only text box with text-wrapping disabled:<br/>
-<com:TTextBox
- TextMode="MultiLine"
- Text="This is a read-only text box with text-wrapping disabled."
- ReadOnly="true"
- Wrap="false"/>
+Auto postback list box:<br/>
+<br/>
+<com:TListBox AutoPostBack="true" SelectionMode="Multiple" SelectedIndexChanged="multiSelectionChanged">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" Selected="true" />
+</com:TListBox>
+<br/>
+<com:TLabel ID="MultiSelectionResult" ForeColor="red" />
<br/>
-Auto postback text box:<br/>
-<com:TTextBox TextMode="MultiLine" Text="change me" AutoPostBack="true" TextChanged="textChanged" />
+List box's behavior upon postback:<br/>
+<com:TListBox ID="ListBox2" SelectionMode="Multiple">
+ <com:TListItem Value="value 1" Text="item 1" />
+ <com:TListItem Value="value 2" Text="item 2" Selected="true" />
+ <com:TListItem Value="value 3" Text="item 3" />
+ <com:TListItem Value="value 4" Text="item 4" Selected="true" />
+</com:TListBox>
+<com:TButton Text="Submit" Click="buttonClicked2" />
<br/>
-</div>
+<com:TLabel ID="MultiSelectionResult2" ForeColor="red" />
+</div>
</com:TContent> \ 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 @@
<?php
-class Samples extends TPage
+class Home extends TPage
{
- public function textChanged($sender,$param)
+ public function selectionChanged($sender,$param)
{
- $sender->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;