diff options
author | xue <> | 2006-01-24 05:13:51 +0000 |
---|---|---|
committer | xue <> | 2006-01-24 05:13:51 +0000 |
commit | 85a8e37118107312b971aba4065be4e850441866 (patch) | |
tree | 5b8a320a42dbca31718bf537a00bd0159a1fcdee | |
parent | 230067c5425f9e95e601d682a8b9bb523190856e (diff) |
Added TRadioButton demo and FT.
7 files changed, 198 insertions, 8 deletions
diff --git a/.gitattributes b/.gitattributes index 7d860080..11565ffe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -83,6 +83,8 @@ demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.page -text demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TPanel/hello_world.gif -text +demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.page -text +demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.page -text demos/quickstart/protected/pages/Controls/Samples/TRadioButtonList/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TRegularExpressionValidator/Home.page -text @@ -649,6 +651,7 @@ tests/FunctionalTests/quickstart_tests/Controls/ImageTestCase.php -text tests/FunctionalTests/quickstart_tests/Controls/LabelTestCase.php -text tests/FunctionalTests/quickstart_tests/Controls/LinkButtonTestCase.php -text tests/FunctionalTests/quickstart_tests/Controls/PanelTestCase.php -text +tests/FunctionalTests/quickstart_tests/Controls/RadioButtonTestCase.php -text tests/FunctionalTests/quickstart_tests/Controls/TableTestCase.php -text tests/FunctionalTests/quickstart_tests/Controls/TextBoxTestCase.php -text tests/FunctionalTests/quickstart_tests/Fundamentals/HangmanTestCase.php -text diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.page new file mode 100644 index 00000000..4cda20d8 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.page @@ -0,0 +1,102 @@ +<com:TContent ID="body">
+
+<h1>TRadioButton Samples</h1>
+
+<table class="sampletable">
+
+<tr><td class="samplenote">
+A radiobutton with customized text alignment, color and font:
+</td><td class="sampleaction">
+<com:TRadioButton
+ Text="radiobutton"
+ TextAlign="Left"
+ ForeColor="silver"
+ BackColor="green"
+ Font.Size="14pt"
+/>
+</td></tr>
+
+<tr><td class="samplenote">
+A radiobutton with label and input attributes:
+</td><td class="sampleaction">
+<com:TRadioButton
+ Text="click me"
+ InputAttributes.value="value"
+ LabelAttributes.style="color:red"
+/>
+</td></tr>
+
+<tr><td class="samplenote">
+An auto postback radiobutton:
+</td><td class="sampleaction">
+<com:TRadioButton
+ AutoPostBack="true"
+ Text="click me"
+ OnCheckedChanged="radiobuttonClicked"
+ />
+</td></tr>
+
+<tr><td class="samplenote">
+A radiobutton causing validation on a textbox:
+</td><td class="sampleaction">
+<com:TTextBox ID="TextBox" />
+<com:TRequiredFieldValidator
+ ControlToValidate="TextBox"
+ Display="Dynamic"
+ ErrorMessage="input required in the textbox"
+ ValidationGroup="Group"
+ />
+<com:TRadioButton
+ Text="submit"
+ AutoPostBack="true"
+ ValidationGroup="Group"
+ />
+</td></tr>
+
+<tr><td class="samplenote">
+A radiobutton validated by a required field validator:
+</td><td class="sampleaction">
+<com:TRadioButton
+ ID="RadioButton"
+ Text="Consent"
+ ValidationGroup="Group2"
+ />
+<com:TButton Text="Submit" ValidationGroup="Group2" />
+<com:TRequiredFieldValidator
+ ControlToValidate="RadioButton"
+ Display="Dynamic"
+ ErrorMessage="You must consent."
+ ValidationGroup="Group2"
+ />
+</td></tr>
+
+<tr><td class="samplenote">
+A radiobutton group:
+</td><td class="sampleaction">
+<com:TRadioButton
+ ID="Radio1"
+ GroupName="RadioGroup"
+ Text="Option 1"
+ />
+<com:TRadioButton
+ ID="Radio2"
+ GroupName="RadioGroup"
+ Text="Option 2"
+ />
+<com:TRadioButton
+ ID="Radio3"
+ GroupName="RadioGroup"
+ Text="Option 3"
+ />
+<com:TRadioButton
+ ID="Radio4"
+ Text="Option 4 (in a different group)"
+ />
+<br/>
+<com:TButton Text="Submit" OnClick="selectRadioButton" />
+<com:TLabel ID="Result" />
+</td></tr>
+
+</table>
+
+</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php new file mode 100644 index 00000000..034d2fcc --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TRadioButton/Home.php @@ -0,0 +1,27 @@ +<?php
+
+class Home extends TPage
+{
+ public function radiobuttonClicked($sender,$param)
+ {
+ $sender->Text="I'm clicked";
+ }
+
+ public function selectRadioButton($sender,$param)
+ {
+ $selection='';
+ if($this->Radio1->Checked)
+ $selection.='1';
+ if($this->Radio2->Checked)
+ $selection.='2';
+ if($this->Radio3->Checked)
+ $selection.='3';
+ if($this->Radio4->Checked)
+ $selection.='4';
+ if($selection==='')
+ $selection='empty';
+ $this->Result->Text='Your selection is '.$selection;
+ }
+}
+
+?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 98084009..77145d48 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -311,13 +311,14 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl */
protected function getValueAttribute()
{
- if(($value=$this->getAttribute('value'))===null)
+ $attributes=$this->getViewState('InputAttributes',null);
+ if($attributes && $attributes->contains('value'))
{
- $value=$this->getID();
+ $value=$attributes->itemAt('value');
return $value===''?$this->getUniqueID():$value;
}
else
- return $value;
+ return $this->getUniqueID();
}
/**
diff --git a/tests/FunctionalTests/quickstart_tests/Controls/CheckBoxTestCase.php b/tests/FunctionalTests/quickstart_tests/Controls/CheckBoxTestCase.php index 80158343..b68f22d3 100644 --- a/tests/FunctionalTests/quickstart_tests/Controls/CheckBoxTestCase.php +++ b/tests/FunctionalTests/quickstart_tests/Controls/CheckBoxTestCase.php @@ -38,16 +38,16 @@ class CheckBoxTestCase extends SeleniumTestCase $this->click("//input[@type='submit' and @value='Submit']", "");
$this->pause(1000);
$this->verifyVisible('ctl0_body_ctl6');
- $this->click("//input[@name='ctl0\$body\$CheckBox' and @value='CheckBox']", "");
+ $this->click("//input[@name='ctl0\$body\$CheckBox' and @value='ctl0\$body\$CheckBox']", "");
$this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
$this->verifyNotVisible('ctl0_body_ctl6');
// a checkbox validated by a required field validator using AutoPostBack
$this->verifyNotVisible('ctl0_body_ctl7');
- $this->click("//input[@name='ctl0\$body\$CheckBox2' and @value='CheckBox2']", "");
+ $this->click("//input[@name='ctl0\$body\$CheckBox2' and @value='ctl0\$body\$CheckBox2']", "");
$this->pause(1000);
$this->verifyVisible('ctl0_body_ctl7');
- $this->clickAndWait("//input[@name='ctl0\$body\$CheckBox2' and @value='CheckBox2']", "");
+ $this->clickAndWait("//input[@name='ctl0\$body\$CheckBox2' and @value='ctl0\$body\$CheckBox2']", "");
$this->verifyNotVisible('ctl0_body_ctl7');
}
}
diff --git a/tests/FunctionalTests/quickstart_tests/Controls/HyperLinkTestCase.php b/tests/FunctionalTests/quickstart_tests/Controls/HyperLinkTestCase.php index 7fb22b04..5ef103f0 100644 --- a/tests/FunctionalTests/quickstart_tests/Controls/HyperLinkTestCase.php +++ b/tests/FunctionalTests/quickstart_tests/Controls/HyperLinkTestCase.php @@ -6,8 +6,7 @@ class HyperLinkTestCase extends SeleniumTestCase {
$this->open("../../demos/quickstart/index.php?page=Controls.Samples.THyperLink.Home&functionaltest=true", "");
$this->verifyTitle("PRADO QuickStart Sample", "");
- //$this->verifyAttribute("//a[@href=\"http://www.pradosoft.com/\"]/@target","_blank");
- $this->verifyHTMLPresent('<a href="http://www.pradosoft.com/" target="_blank" style="background-color:silver;font-style:italic;">PradoSoft.com</a>');
+ $this->verifyElementPresent("//a[@href=\"http://www.pradosoft.com/\" and @target=\"_blank\"]");
$this->verifyTextPresent("Welcome to", "");
$this->verifyTextPresent("Body contents", "");
$this->verifyElementPresent("//a[img/@alt='Hello World']");
diff --git a/tests/FunctionalTests/quickstart_tests/Controls/RadioButtonTestCase.php b/tests/FunctionalTests/quickstart_tests/Controls/RadioButtonTestCase.php new file mode 100644 index 00000000..24b5f6c9 --- /dev/null +++ b/tests/FunctionalTests/quickstart_tests/Controls/RadioButtonTestCase.php @@ -0,0 +1,58 @@ +<?php
+
+class RadioButtonTestCase extends SeleniumTestCase
+{
+ function test ()
+ {
+ $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRadioButton.Home&functionaltest=true", "");
+
+ $this->verifyTitle("PRADO QuickStart Sample", "");
+
+ // a regular radiobutton
+ $this->click("//input[@name='ctl0\$body\$ctl0' and @value='ctl0\$body\$ctl0']", "");
+
+ // a radiobutton with customized value
+ $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value']", "");
+
+ // an auto postback radiobutton
+ $this->verifyTextNotPresent("I'm clicked");
+ $this->clickAndWait("//input[@name='ctl0\$body\$ctl2' and @value='ctl0\$body\$ctl2']", "");
+ $this->verifyTextPresent("I'm clicked");
+ $this->clickAndWait("//input[@name='ctl0\$body\$ctl2' and @value='ctl0\$body\$ctl2']", "");
+ $this->verifyTextPresent("I'm clicked");
+
+ // a radiobutton causing validation on a textbox
+ $this->verifyNotVisible('ctl0_body_ctl3');
+ $this->click("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", "");
+ $this->pause(1000);
+ $this->verifyVisible('ctl0_body_ctl3');
+ $this->click("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", "");
+ $this->pause(1000);
+ $this->verifyVisible('ctl0_body_ctl3');
+ $this->type("ctl0\$body\$TextBox", "test");
+ $this->clickAndWait("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", "");
+ $this->verifyNotVisible('ctl0_body_ctl3');
+
+ // a radiobutton validated by a required field validator
+ $this->verifyNotVisible('ctl0_body_ctl6');
+ $this->click("//input[@type='submit' and @value='Submit']", "");
+ $this->pause(1000);
+ $this->verifyVisible('ctl0_body_ctl6');
+ $this->click("//input[@name='ctl0\$body\$RadioButton' and @value='ctl0\$body\$RadioButton']", "");
+ $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
+ $this->verifyNotVisible('ctl0_body_ctl6');
+
+ // a radiobutton group
+ $this->clickAndWait("name=ctl0\$body\$ctl7", "");
+ $this->verifyTextPresent("Your selection is empty");
+ $this->click("//input[@name='ctl0\$body\$RadioGroup' and @value='ctl0\$body\$Radio2']", "");
+ $this->clickAndWait("name=ctl0\$body\$ctl7", "");
+ $this->verifyTextPresent("Your selection is 2");
+ $this->click("//input[@name='ctl0\$body\$RadioGroup' and @value='ctl0\$body\$Radio3']", "");
+ $this->click("//input[@name='ctl0\$body\$Radio4' and @value='ctl0\$body\$Radio4']", "");
+ $this->clickAndWait("name=ctl0\$body\$ctl7", "");
+ $this->verifyTextPresent("Your selection is 34");
+ }
+}
+
+?>
\ No newline at end of file |