summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls
diff options
context:
space:
mode:
authorwei <>2006-05-06 02:26:20 +0000
committerwei <>2006-05-06 02:26:20 +0000
commita7f6c6640ac9295eec3ae2edbb2250179eb85e33 (patch)
tree8a3879c747dfc3bcd5d65f334341ea7c81ced268 /framework/Web/UI/WebControls
parent46155621cbf97191fca495cbd09a2eedd82afa82 (diff)
Adding TActiveButton and TActiveTextBox
Diffstat (limited to 'framework/Web/UI/WebControls')
-rw-r--r--framework/Web/UI/WebControls/TBulletedList.php11
-rw-r--r--framework/Web/UI/WebControls/TButton.php23
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php11
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php20
-rw-r--r--framework/Web/UI/WebControls/TImageMap.php11
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php19
-rw-r--r--framework/Web/UI/WebControls/TListControl.php15
-rw-r--r--framework/Web/UI/WebControls/TRadioButton.php11
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php15
9 files changed, 103 insertions, 33 deletions
diff --git a/framework/Web/UI/WebControls/TBulletedList.php b/framework/Web/UI/WebControls/TBulletedList.php
index 05cbaab1..fad77232 100644
--- a/framework/Web/UI/WebControls/TBulletedList.php
+++ b/framework/Web/UI/WebControls/TBulletedList.php
@@ -321,9 +321,9 @@ class TBulletedList extends TListControl implements IPostBackEventHandler
else
{
$this->_currentRenderItemIndex = $index;
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TBulletedList',$this->getPostBackOptions());
$writer->addAttribute('id', $this->getClientID().$index);
$writer->addAttribute('href', "javascript:;//".$this->getClientID().$index);
+ $this->renderClientControlScript($writer);
}
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -331,6 +331,15 @@ 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 b9872a64..ba523168 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -72,14 +72,8 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
$writer->addAttribute('value',$this->getText());
- if($this->getEnabled(true))
- {
- if($this->canCauseValidation())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TButton',$this->getPostBackOptions());
- }
- }
+ if($this->getEnabled(true) )
+ $this->renderClientControlScript($writer);
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
@@ -87,6 +81,19 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ if($this->canCauseValidation())
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+ }
+
+ /**
* @return boolean whether to perform validation if the button is clicked
*/
protected function canCauseValidation()
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index da389948..cb8fb30d 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -351,7 +351,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$page=$this->getPage();
if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- $page->getClientScript()->registerPostBackControl('Prado.WebUI.TCheckBox',$this->getPostBackOptions());
+ $this->renderClientControlScript($writer);
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -364,6 +364,15 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+
+ /**
* Gets the post back options for this checkbox.
* @return array
*/
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index 109f53a8..4b482721 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -88,19 +88,25 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
if($this->getEnabled(true))
- {
- if($this->canCauseValidation())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TImageButton',$this->getPostBackOptions());
- }
- }
+ $this->renderClientControlScript($writer);
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ if($this->canCauseValidation())
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+ }
+ /**
* @return boolean whether to perform validation if the button is clicked
*/
protected function canCauseValidation()
diff --git a/framework/Web/UI/WebControls/TImageMap.php b/framework/Web/UI/WebControls/TImageMap.php
index 9444df46..ae2d6be3 100644
--- a/framework/Web/UI/WebControls/TImageMap.php
+++ b/framework/Web/UI/WebControls/TImageMap.php
@@ -109,7 +109,7 @@ class TImageMap extends TImage implements IPostBackEventHandler
$options['EventParameter']="$i";
$options['CausesValidation']=$hotspot->getCausesValidation();
$options['ValidationGroup']=$hotspot->getValidationGroup();
- $cs->registerPostBackControl('Prado.WebUI.TImageMap',$options);
+ $cs->renderClientControlScript($writer,$options);
}
$hotspot->render($writer);
$writer->writeLine();
@@ -118,6 +118,15 @@ 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);
+ }
/**
* Raises the postback event.
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index bca4a8f6..7f9baab8 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -81,15 +81,22 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonC
parent::addAttributesToRender($writer);
if($this->getEnabled(true))
- {
- //create unique no-op url references
- $nop = "#".$this->getClientID();
- $writer->addAttribute('href', $nop);
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TLinkButton',$this->getPostBackOptions());
- }
+ $this->renderClientControlScript($writer);
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
}
+
+ /**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ //create unique no-op url references
+ $nop = "#".$this->getClientID();
+ $writer->addAttribute('href', $nop);
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
/**
* Returns postback specifications for the button.
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 1c615edc..1c7fe11b 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -113,16 +113,23 @@ abstract class TListControl extends TDataBoundControl
if($this->getIsMultiSelect())
$writer->addAttribute('multiple','multiple');
if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.'.get_class($this),$this->getPostBackOptions());
- }
+ $this->renderClientControlScript($writer);
if(!$this->getEnabled(true) && $this->getEnabled())
$writer->addAttribute('disabled','disabled');
parent::addAttributesToRender($writer);
}
/**
+ * Renders the client-script code.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+
+ /**
* @return array postback options for JS postback code
*/
protected function getPostBackOptions()
diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php
index 9a523b55..6a5ade4d 100644
--- a/framework/Web/UI/WebControls/TRadioButton.php
+++ b/framework/Web/UI/WebControls/TRadioButton.php
@@ -154,7 +154,7 @@ class TRadioButton extends TCheckBox
$page=$this->getPage();
if($this->getEnabled(true) && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- $page->getClientScript()->registerPostBackControl('Prado.WebUI.TRadioButton',$this->getPostBackOptions());
+ $this->renderClientControlScript($writer);
if(($accesskey=$this->getAccessKey())!=='')
$writer->addAttribute('accesskey',$accesskey);
@@ -165,6 +165,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());
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index feea6227..b443fa59 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -143,14 +143,21 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
if($isEnabled && $this->getAutoPostBack() && $page->getClientSupportsJavaScript())
- {
- $writer->addAttribute('id',$this->getClientID());
- $this->getPage()->getClientScript()->registerPostBackControl('Prado.WebUI.TTextBox',$this->getPostBackOptions());
- }
+ $this->renderClientControlScript($writer);
parent::addAttributesToRender($writer);
}
/**
+ * Renders the javascript for textbox.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ $writer->addAttribute('id',$this->getClientID());
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerPostBackControl(get_class($this),$this->getPostBackOptions());
+ }
+
+ /**
* Gets the post back options for this textbox.
* @return array
*/