diff options
4 files changed, 70 insertions, 24 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page index 161f68a4..9f9bf162 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.page @@ -94,7 +94,7 @@ List box's behavior upon postback:  <h2>List Boxes in Multiple Selection Mode</h2>
 -<i>Use Shift + Mouse Click to change selection</i>
 +<i>Use Ctrl + Mouse Click to change selection</i>
  <br/>
  <table class="sampletable">
 @@ -159,7 +159,7 @@ Auto postback list box:  </table>
  <h2>List Boxes with DataBinding</h2>
 -<i>Use Shift + Mouse Click to change selection</i>
 +<i>Use Ctrl + Mouse Click to change selection</i>
  <br/>
  <table class="sampletable">
 @@ -206,4 +206,55 @@ Databind with DataTextField and DataValueField specified:  </tr>
  </table>
 +
 +
 +<h2>List Boxes with Validation</h2>
 +
 +<table class="sampletable">
 +
 +<tr>
 +<td class="samplenote">
 +List box is being validated:
 +</td>
 +<td class="sampleaction">
 +<com:TListBox ID="VListBox1">
 +  <com:TListItem Value="value 1" Text="item 1" />
 +  <com:TListItem Value="value 2" Text="item 2" />
 +  <com:TListItem Value="value 3" Text="item 3" />
 +  <com:TListItem Value="value 4" Text="item 4" />
 +</com:TListBox>
 +<com:TRequiredFieldValidator
 +	ControlToValidate="VListBox1"
 +	ErrorMessage="You must make a selection"
 +	Display="Dynamic"
 +	ValidationGroup="Group1"
 +	/>
 +<com:TButton Text="Submit" ValidationGroup="Group1" />
 +</td>
 +</tr>
 +
 +<tr>
 +<td class="samplenote">
 +List box causing validation:
 +</td>
 +<td class="sampleaction">
 +<com:TTextBox ID="TextBox" />
 +<com:TRequiredFieldValidator
 +	ControlToValidate="TextBox"
 +	ErrorMessage="You must enter a value"
 +	Display="Dynamic"
 +	ValidationGroup="Group2"
 +	/>
 +<com:TListBox
 +	ID="VListBox2"
 +	AutoPostBack="true"
 +	ValidationGroup="Group2">
 +  <com:TListItem Text="Agree" />
 +  <com:TListItem Text="Disagree" />
 +</com:TListBox>
 +</td>
 +</tr>
 +
 +</table>
 +
  </com:TContent>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php index 168c7ef0..34ff005f 100644 --- a/framework/Web/UI/WebControls/TCheckBoxList.php +++ b/framework/Web/UI/WebControls/TCheckBoxList.php @@ -328,13 +328,8 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont  	 */
  	public function raisePostDataChangedEvent()
  	{
 -		$page=$this->getPage();
 -		if($this->getAutoPostBack() && !$page->getPostBackEventTarget())
 -		{
 -			$page->setPostBackEventTarget($this);
 -			if($this->getCausesValidation())
 -				$page->validate($this->getValidationGroup());
 -		}
 +		if($this->getAutoPostBack() && $this->getCausesValidation())
 +			$this->getPage()->validate($this->getValidationGroup());
  		$this->onSelectedIndexChanged(null);
  	}
 diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php index 3c459057..a3c02c15 100644 --- a/framework/Web/UI/WebControls/TDropDownList.php +++ b/framework/Web/UI/WebControls/TDropDownList.php @@ -72,13 +72,8 @@ class TDropDownList extends TListControl implements IPostBackDataHandler  	 */
  	public function raisePostDataChangedEvent()
  	{
 -		$page=$this->getPage();
 -		if($this->getAutoPostBack() && !$page->getPostBackEventTarget())
 -		{
 -			$page->setPostBackEventTarget($this);
 -			if($this->getCausesValidation())
 -				$page->validate($this->getValidationGroup());
 -		}
 +		if($this->getAutoPostBack() && $this->getCausesValidation())
 +			$this->getPage()->validate($this->getValidationGroup());
  		$this->onSelectedIndexChanged(null);
  	}
 diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php index 47165c99..50cf3873 100644 --- a/framework/Web/UI/WebControls/TListBox.php +++ b/framework/Web/UI/WebControls/TListBox.php @@ -29,7 +29,7 @@ Prado::using('System.Web.UI.WebControls.TListControl');   * @package System.Web.UI.WebControls
   * @since 3.0
   */
 -class TListBox extends TListControl implements IPostBackDataHandler
 +class TListBox extends TListControl implements IPostBackDataHandler, IValidatable
  {
  	/**
  	 * Adds attribute name-value pairs to renderer.
 @@ -131,13 +131,8 @@ class TListBox extends TListControl implements IPostBackDataHandler  	 */
  	public function raisePostDataChangedEvent()
  	{
 -		$page=$this->getPage();
 -		if($this->getAutoPostBack() && !$page->getPostBackEventTarget())
 -		{
 -			$page->setPostBackEventTarget($this);
 -			if($this->getCausesValidation())
 -				$page->validate($this->getValidationGroup());
 -		}
 +		if($this->getAutoPostBack() && $this->getCausesValidation())
 +			$this->getPage()->validate($this->getValidationGroup());
  		$this->onSelectedIndexChanged(null);
  	}
 @@ -184,5 +179,15 @@ class TListBox extends TListControl implements IPostBackDataHandler  	{
  		$this->setViewState('SelectionMode',TPropertyValue::ensureEnum($value,array('Single','Multiple')),'Single');
  	}
 +
 +	/**
 +	 * Returns the value to be validated.
 +	 * This methid is required by IValidatable interface.
 +	 * @return mixed the value of the property to be validated.
 +	 */
 +	public function getValidationPropertyValue()
 +	{
 +		return $this->getSelectedValue();
 +	}
  }
  ?>
\ No newline at end of file  | 
