summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php17
-rw-r--r--framework/Web/UI/WebControls/TBulletedList.php22
-rw-r--r--framework/Web/UI/WebControls/TButton.php6
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php4
-rw-r--r--framework/Web/UI/WebControls/TCheckBoxList.php10
-rw-r--r--framework/Web/UI/WebControls/TCompareValidator.php14
-rw-r--r--framework/Web/UI/WebControls/TCustomValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TDataTypeValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TDropDownList.php10
-rw-r--r--framework/Web/UI/WebControls/TEmailAddressValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php4
-rw-r--r--framework/Web/UI/WebControls/TImageMap.php6
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php2
-rw-r--r--framework/Web/UI/WebControls/TListBox.php10
-rw-r--r--framework/Web/UI/WebControls/TListControl.php25
-rw-r--r--framework/Web/UI/WebControls/TListControlValidator.php12
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php8
-rw-r--r--framework/Web/UI/WebControls/TRadioButtonList.php10
-rw-r--r--framework/Web/UI/WebControls/TRangeValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TRegularExpressionValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TRequiredFieldValidator.php16
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php4
22 files changed, 180 insertions, 50 deletions
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index 3c76db30..3fe9ee03 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -264,16 +264,21 @@ abstract class TBaseValidator extends TLabel implements IValidator
{
if($this->getEnabled(true))
{
- $class = get_class($this);
- $scriptKey = "prado:".$this->getClientID();
- $scripts = $this->getPage()->getClientScript();
- $options = TJavaScript::encode($this->getClientScriptOptions());
- $js = "new Prado.WebUI.{$class}({$options});";
- $scripts->registerEndScript($scriptKey, $js);
+ $key = 'prado:'.$this->getClientID();
+ $options = TJavaScript::encode($this->getClientScriptOptions());
+ $script = 'new '.$this->getClientClassName().'('.$options.');';
+ $this->getPage()->getClientScript()->registerEndScript($key, $script);
}
}
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ abstract protected function getClientClassName();
+
+ /**
* This method overrides the parent implementation to forbid setting ForControl.
* @param string the associated control ID
* @throws TNotSupportedException whenever this method is called
diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php
index fad77232..dfed0b6e 100644
--- a/framework/Web/UI/WebControls/TBulletedList.php
+++ b/framework/Web/UI/WebControls/TBulletedList.php
@@ -84,6 +84,16 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
}
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TBulletedList';
+ }
+
+ /**
* Adds attribute name-value pairs to renderer.
* This overrides the parent implementation with additional bulleted list specific attributes.
* @param THtmlWriter the writer used for the rendering purpose
@@ -323,7 +333,8 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
$this->_currentRenderItemIndex = $index;
$writer->addAttribute('id', $this->getClientID().$index);
$writer->addAttribute('href', "javascript:;//".$this->getClientID().$index);
- $this->renderClientControlScript($writer);
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl('Prado.WebUI.TBulletedList',$this->getPostBackOptions());
}
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -331,15 +342,6 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
$writer->write(THttpUtility::htmlEncode($item->getText()));
$writer->renderEndTag();
}
-
- /**
- * Renders the client-script code.
- */
- protected function renderClientControlScript($writer)
- {
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
- }
/**
* @return array postback options used for linkbuttons.
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index 75d60695..f1302853 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -87,9 +87,9 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
{
if($this->canCauseValidation())
{
- $writer->addAttribute('id',$this->getClientID());
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl('Prado.WebUI.TButton',$this->getPostBackOptions());
}
}
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index fda0480d..37ea0369 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -375,8 +375,8 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
*/
protected function renderClientControlScript($writer)
{
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl('Prado.WebUI.TCheckBox',$this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php
index 2a16673c..e6ca3642 100644
--- a/framework/Web/UI/WebControls/TCheckBoxList.php
+++ b/framework/Web/UI/WebControls/TCheckBoxList.php
@@ -106,6 +106,16 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
}
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCheckBoxList';
+ }
+
+ /**
* @return string the alignment of the text caption, defaults to 'Right'.
*/
public function getTextAlign()
diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php
index b5ebd3ab..93664b2e 100644
--- a/framework/Web/UI/WebControls/TCompareValidator.php
+++ b/framework/Web/UI/WebControls/TCompareValidator.php
@@ -31,8 +31,8 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
* type before the comparison operation is performed. The following value types are supported:
* - <b>Integer</b> A 32-bit signed integer data type.
* - <b>Float</b> A double-precision floating point number data type.
- * - <b>Date</b> A date data type. The format can be specified by the
- * {@link setDateFormat DateFormat} property
+ * - <b>Date</b> A date data type. The format can be specified by the
+ * {@link setDateFormat DateFormat} property
* - <b>String</b> A string data type.
*
* Use the {@link setOperator Operator} property to specify the type of comparison
@@ -47,6 +47,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TCompareValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCompareValidator';
+ }
+
+ /**
* @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
*/
public function getDataType()
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php
index 27cfa67a..32510f89 100644
--- a/framework/Web/UI/WebControls/TCustomValidator.php
+++ b/framework/Web/UI/WebControls/TCustomValidator.php
@@ -55,6 +55,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TCustomValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TCustomValidator';
+ }
+
+ /**
* @return string the name of the custom client-side script function used for validation.
*/
public function getClientValidationFunction()
diff --git a/framework/Web/UI/WebControls/TDataTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php
index ebcaace7..bd7569fc 100644
--- a/framework/Web/UI/WebControls/TDataTypeValidator.php
+++ b/framework/Web/UI/WebControls/TDataTypeValidator.php
@@ -37,6 +37,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TDataTypeValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TDataTypeValidator';
+ }
+
+ /**
* @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
*/
public function getDataType()
diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php
index 14a4dac4..860fe69c 100644
--- a/framework/Web/UI/WebControls/TDropDownList.php
+++ b/framework/Web/UI/WebControls/TDropDownList.php
@@ -39,6 +39,16 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid
}
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TDropDownList';
+ }
+
+ /**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php
index 3534d1d0..e1150233 100644
--- a/framework/Web/UI/WebControls/TEmailAddressValidator.php
+++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php
@@ -36,6 +36,16 @@ class TEmailAddressValidator extends TRegularExpressionValidator
const EMAIL_REGEXP="\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TEmailAddressValidator';
+ }
+
+ /**
* @return string the regular expression that determines the pattern used to validate a field.
*/
public function getRegularExpression()
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index 4b482721..df8ace43 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -102,8 +102,8 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
if($this->canCauseValidation())
{
$writer->addAttribute('id',$this->getClientID());
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl('Prado.WebUI.TImageButton',$this->getPostBackOptions());
}
}
/**
diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php
index ae2d6be3..be7bfea9 100644
--- a/framework/Web/UI/WebControls/TImageMap.php
+++ b/framework/Web/UI/WebControls/TImageMap.php
@@ -118,14 +118,14 @@ class TImageMap extends TImage implements IPostBackEventHandler
$writer->renderEndTag();
}
}
-
+
/**
* Renders the client-script code.
*/
protected function renderClientControlScript($writer,$options)
{
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$options);
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl('Prado.WebUI.TImageMap',$options);
}
/**
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index 7487b37a..e7fea0b5 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -95,7 +95,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC
$nop = "javascript:;//".$this->getClientID();
$writer->addAttribute('href', $nop);
$cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ $cs->registerPostBackControl('Prado.WebUI.TLinkButton',$this->getPostBackOptions());
}
/**
diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php
index 5ee3f58e..972ebbcb 100644
--- a/framework/Web/UI/WebControls/TListBox.php
+++ b/framework/Web/UI/WebControls/TListBox.php
@@ -48,6 +48,16 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl
}
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TListBox';
+ }
+
+ /**
* Registers the list control to load post data on postback.
* This method overrides the parent implementation.
* @param mixed event parameter
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index f20ff4cc..2c42c462 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -113,22 +113,25 @@ abstract class TListControl extends TDataBoundControl
$page->ensureRenderInForm($this);
if($this->getIsMultiSelect())
$writer->addAttribute('multiple','multiple');
- if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- $this->renderClientControlScript($writer);
- if(!$this->getEnabled(true) && $this->getEnabled())
+ if($this->getEnabled(true))
+ {
+ if($this->getAutoPostBack() && $page->getClientSupportsJavaScript())
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
+ }
+ }
+ else if($this->getEnabled())
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
}
/**
- * Renders the client-script code.
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
*/
- protected function renderClientControlScript($writer)
- {
- $writer->addAttribute('id',$this->getClientID());
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
- }
+ abstract protected function getClientClassName();
/**
* @return array postback options for JS postback code
@@ -812,4 +815,4 @@ class TListItemCollection extends TList
}
}
-?> \ No newline at end of file
+?>
diff --git a/framework/Web/UI/WebControls/TListControlValidator.php b/framework/Web/UI/WebControls/TListControlValidator.php
index be69085d..010a7e77 100644
--- a/framework/Web/UI/WebControls/TListControlValidator.php
+++ b/framework/Web/UI/WebControls/TListControlValidator.php
@@ -64,6 +64,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TListControlValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TListControlValidator';
+ }
+
+ /**
* @return integer min number of selections. Defaults to -1, meaning not set.
*/
public function getMinSelection()
@@ -195,7 +205,7 @@ class TListControlValidator extends TBaseValidator
if(!$control instanceof TListControl)
{
throw new TConfigurationException(
- 'tlistcontrolvalidator_invalid_control',
+ 'listcontrolvalidator_invalid_control',
$this->getID(),$this->getControlToValidate(), get_class($control));
}
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index dc7ba057..688b99bf 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -168,15 +168,15 @@ class TRadioButton extends TCheckBox
$writer->renderBeginTag('input');
$writer->renderEndTag();
}
-
+
/**
* Renders the client-script code.
*/
protected function renderClientControlScript($writer)
{
- $cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
- }
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl('Prado.WebUI.TRadioButton',$this->getPostBackOptions());
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TRadioButtonList.php b/framework/Web/UI/WebControls/TRadioButtonList.php
index b0a36c9d..95725836 100644
--- a/framework/Web/UI/WebControls/TRadioButtonList.php
+++ b/framework/Web/UI/WebControls/TRadioButtonList.php
@@ -53,6 +53,16 @@ class TRadioButtonList extends TCheckBoxList
}
/**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRadioButtonList';
+ }
+
+ /**
* Loads user input data.
* This method is primarly used by framework developers.
* @param string the key that can be used to retrieve data from the input data collection
diff --git a/framework/Web/UI/WebControls/TRangeValidator.php b/framework/Web/UI/WebControls/TRangeValidator.php
index b7387522..9d23eb5e 100644
--- a/framework/Web/UI/WebControls/TRangeValidator.php
+++ b/framework/Web/UI/WebControls/TRangeValidator.php
@@ -43,6 +43,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TRangeValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRangeValidator';
+ }
+
+ /**
* @return string the minimum value of the validation range.
*/
public function getMinValue()
diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php
index e73fd5be..3099514b 100644
--- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php
+++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php
@@ -50,6 +50,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TRegularExpressionValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRegularExpressionValidator';
+ }
+
+ /**
* @return string the regular expression that determines the pattern used to validate a field.
*/
public function getRegularExpression()
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
index 04e333eb..b8a939ad 100644
--- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php
+++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
@@ -21,7 +21,7 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
* TRequiredFieldValidator makes the associated input control a required field.
* The input control fails validation if its value does not change from
* the {@link setInitialValue InitialValue} property upon losing focus.
- *
+ *
* Validation will also succeed if input is of TListControl type and the number
* of selected values different from the initial value is greater than zero.
*
@@ -33,6 +33,16 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
class TRequiredFieldValidator extends TBaseValidator
{
/**
+ * Gets the name of the javascript class responsible for performing validation for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TRequiredFieldValidator';
+ }
+
+ /**
* @return string the initial value of the associated input control. Defaults to empty string.
* If the associated input control does not change from this initial value
* upon postback, the validation fails.
@@ -56,11 +66,11 @@ class TRequiredFieldValidator extends TBaseValidator
* This method overrides the parent's implementation.
* The validation succeeds if the input component changes its data
* from the {@link getInitialValue InitialValue} or the input control is not given.
- *
+ *
* Validation will also succeed if input is of TListControl type and the
* number of selected values different from the initial value is greater
* than zero.
- *
+ *
* @return boolean whether the validation succeeds
*/
protected function evaluateIsValid()
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index b443fa59..73b1e9cc 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -152,9 +152,9 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
*/
protected function renderClientControlScript($writer)
{
- $writer->addAttribute('id',$this->getClientID());
+ $writer->addAttribute('id',$this->getClientID());
$cs = $this->getPage()->getClientScript();
- $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ $cs->registerPostBackControl('Prado.WebUI.TTextBox',$this->getPostBackOptions());
}
/**