From 1c6f1f79d011579a158e87459040075331b636b7 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 12 Jun 2006 03:10:47 +0000 Subject: Minor updates. --- framework/Web/UI/WebControls/TLinkButton.php | 510 +++++++++++++-------------- 1 file changed, 255 insertions(+), 255 deletions(-) (limited to 'framework/Web/UI/WebControls/TLinkButton.php') diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index e7fea0b5..84e1d5a4 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -1,255 +1,255 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ - * @package System.Web.UI.WebControls - */ - -/** - * TLinkButton class - * - * TLinkButton creates a hyperlink style button on the page. - * TLinkButton has the same appearance as a hyperlink. However, it is mainly - * used to submit data to a page. Like {@link TButton}, you can create either - * a submit button or a command button. - * - * A command button has a command name (specified by - * the {@link setCommandName CommandName} property) and and a command parameter - * (specified by {@link setCommandParameter CommandParameter} property) - * associated with the button. This allows you to create multiple TLinkButton - * components on a Web page and programmatically determine which one is clicked - * with what parameter. You can provide an event handler for - * {@link onCommand OnCommand} event to programmatically control the actions performed - * when the command button is clicked. In the event handler, you can determine - * the {@link setCommandName CommandName} property value and - * the {@link setCommandParameter CommandParameter} property value - * through the {@link TCommandParameter::getName Name} and - * {@link TCommandParameter::getParameter Parameter} properties of the event - * parameter which is of type {@link TCommandEventParameter}. - * - * A submit button does not have a command name associated with the button - * and clicking on it simply posts the Web page back to the server. - * By default, a TLinkButton component is a submit button. - * You can provide an event handler for the {@link onClick OnClick} event - * to programmatically control the actions performed when the submit button is clicked. - * - * Clicking on button can trigger form validation, if - * {@link setCausesValidation CausesValidation} is true. - * And the validation may be restricted within a certain group of validator - * controls by setting {@link setValidationGroup ValidationGroup} property. - * If validation is successful, the data will be post back to the same page. - * - * TLinkButton will display the {@link setText Text} property value - * as the hyperlink text. If {@link setText Text} is empty, the body content - * of TLinkButton will be displayed. Therefore, you can use TLinkButton - * as an image button by enclosing an <img> tag as the body of TLinkButton. - * - * @author Qiang Xue - * @version $Revision: $ $Date: $ - * @package System.Web.UI.WebControls - * @since 3.0 - */ -class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonControl -{ - /** - * @return string tag name of the button - */ - protected function getTagName() - { - return 'a'; - } - - /** - * Adds attribute name-value pairs to renderer. - * This overrides the parent implementation with additional button specific attributes. - * @param THtmlWriter the writer used for the rendering purpose - */ - protected function addAttributesToRender($writer) - { - $page=$this->getPage(); - $page->ensureRenderInForm($this); - - $writer->addAttribute('id',$this->getClientID()); - - // We call parent implementation here because some attributes - // may be overwritten in the following - parent::addAttributesToRender($writer); - - if($this->getEnabled(true)) - $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 = "javascript:;//".$this->getClientID(); - $writer->addAttribute('href', $nop); - $cs = $this->getPage()->getClientScript(); - $cs->registerPostBackControl('Prado.WebUI.TLinkButton',$this->getPostBackOptions()); - } - - /** - * Returns postback specifications for the button. - * This method is used by framework and control developers. - * @return array parameters about how the button defines its postback behavior. - */ - protected function getPostBackOptions() - { - $options['ID'] = $this->getClientID(); - $options['EventTarget'] = $this->getUniqueID(); - $options['CausesValidation'] = $this->getCausesValidation(); - $options['ValidationGroup'] = $this->getValidationGroup(); - $options['StopEvent'] = true; - - return $options; - } - - /** - * Renders the body content enclosed between the control tag. - * If {@link getText Text} is not empty, it will be rendered. Otherwise, - * the body content enclosed in the control tag will be rendered. - * @param THtmlWriter the writer used for the rendering purpose - */ - public function renderContents($writer) - { - if(($text=$this->getText())==='') - parent::renderContents($writer); - else - $writer->write($text); - } - - /** - * @return string the text caption of the button - */ - public function getText() - { - return $this->getViewState('Text',''); - } - - /** - * @param string the text caption to be set - */ - public function setText($value) - { - $this->setViewState('Text',$value,''); - } - - /** - * @return string the command name associated with the {@link onCommand OnCommand} event. - */ - public function getCommandName() - { - return $this->getViewState('CommandName',''); - } - - /** - * @param string the command name associated with the {@link onCommand OnCommand} event. - */ - public function setCommandName($value) - { - $this->setViewState('CommandName',$value,''); - } - - /** - * @return string the parameter associated with the {@link onCommand OnCommand} event - */ - public function getCommandParameter() - { - return $this->getViewState('CommandParameter',''); - } - - /** - * @param string the parameter associated with the {@link onCommand OnCommand} event. - */ - public function setCommandParameter($value) - { - $this->setViewState('CommandParameter',$value,''); - } - - /** - * @return boolean whether postback event trigger by this button will cause input validation - */ - public function getCausesValidation() - { - return $this->getViewState('CausesValidation',true); - } - - /** - * Sets the value indicating whether postback event trigger by this button will cause input validation. - * @param string the text caption to be set - */ - public function setCausesValidation($value) - { - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); - } - - /** - * @return string the group of validators which the button causes validation upon postback - */ - public function getValidationGroup() - { - return $this->getViewState('ValidationGroup',''); - } - - /** - * @param string the group of validators which the button causes validation upon postback - */ - public function setValidationGroup($value) - { - $this->setViewState('ValidationGroup',$value,''); - } - - /** - * Raises the postback event. - * This method is required by {@link IPostBackEventHandler} interface. - * If {@link getCausesValidation CausesValidation} is true, it will - * invoke the page's {@link TPage::validate validate} method first. - * It will raise {@link onClick OnClick} and {@link onCommand OnCommand} events. - * This method is mainly used by framework and control developers. - * @param TEventParameter the event parameter - */ - public function raisePostBackEvent($param) - { - if($this->getCausesValidation()) - $this->getPage()->validate($this->getValidationGroup()); - $this->onClick(null); - $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); - } - - /** - * This method is invoked when the button is clicked. - * The method raises 'OnClick' event to fire up the event handlers. - * If you override this method, be sure to call the parent implementation - * so that the event handler can be invoked. - * @param TEventParameter event parameter to be passed to the event handlers - */ - public function onClick($param) - { - $this->raiseEvent('OnClick',$this,$param); - } - - /** - * This method is invoked when the button is clicked. - * The method raises 'OnCommand' event to fire up the event handlers. - * If you override this method, be sure to call the parent implementation - * so that the event handlers can be invoked. - * @param TCommandEventParameter event parameter to be passed to the event handlers - */ - public function onCommand($param) - { - $this->raiseEvent('OnCommand',$this,$param); - $this->raiseBubbleEvent($this,$param); - } -} - -?> + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + */ + +/** + * TLinkButton class + * + * TLinkButton creates a hyperlink style button on the page. + * TLinkButton has the same appearance as a hyperlink. However, it is mainly + * used to submit data to a page. Like {@link TButton}, you can create either + * a submit button or a command button. + * + * A command button has a command name (specified by + * the {@link setCommandName CommandName} property) and and a command parameter + * (specified by {@link setCommandParameter CommandParameter} property) + * associated with the button. This allows you to create multiple TLinkButton + * components on a Web page and programmatically determine which one is clicked + * with what parameter. You can provide an event handler for + * {@link onCommand OnCommand} event to programmatically control the actions performed + * when the command button is clicked. In the event handler, you can determine + * the {@link setCommandName CommandName} property value and + * the {@link setCommandParameter CommandParameter} property value + * through the {@link TCommandParameter::getName Name} and + * {@link TCommandParameter::getParameter Parameter} properties of the event + * parameter which is of type {@link TCommandEventParameter}. + * + * A submit button does not have a command name associated with the button + * and clicking on it simply posts the Web page back to the server. + * By default, a TLinkButton component is a submit button. + * You can provide an event handler for the {@link onClick OnClick} event + * to programmatically control the actions performed when the submit button is clicked. + * + * Clicking on button can trigger form validation, if + * {@link setCausesValidation CausesValidation} is true. + * And the validation may be restricted within a certain group of validator + * controls by setting {@link setValidationGroup ValidationGroup} property. + * If validation is successful, the data will be post back to the same page. + * + * TLinkButton will display the {@link setText Text} property value + * as the hyperlink text. If {@link setText Text} is empty, the body content + * of TLinkButton will be displayed. Therefore, you can use TLinkButton + * as an image button by enclosing an <img> tag as the body of TLinkButton. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0 + */ +class TLinkButton extends TWebControl implements IPostBackEventHandler, IButtonControl +{ + /** + * @return string tag name of the button + */ + protected function getTagName() + { + return 'a'; + } + + /** + * Adds attribute name-value pairs to renderer. + * This overrides the parent implementation with additional button specific attributes. + * @param THtmlWriter the writer used for the rendering purpose + */ + protected function addAttributesToRender($writer) + { + $page=$this->getPage(); + $page->ensureRenderInForm($this); + + $writer->addAttribute('id',$this->getClientID()); + + // We call parent implementation here because some attributes + // may be overwritten in the following + parent::addAttributesToRender($writer); + + if($this->getEnabled(true)) + $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 = "javascript:;//".$this->getClientID(); + $writer->addAttribute('href', $nop); + $cs = $this->getPage()->getClientScript(); + $cs->registerPostBackControl('Prado.WebUI.TLinkButton',$this->getPostBackOptions()); + } + + /** + * Returns postback specifications for the button. + * This method is used by framework and control developers. + * @return array parameters about how the button defines its postback behavior. + */ + protected function getPostBackOptions() + { + $options['ID'] = $this->getClientID(); + $options['EventTarget'] = $this->getUniqueID(); + $options['CausesValidation'] = $this->getCausesValidation(); + $options['ValidationGroup'] = $this->getValidationGroup(); + $options['StopEvent'] = true; + + return $options; + } + + /** + * Renders the body content enclosed between the control tag. + * If {@link getText Text} is not empty, it will be rendered. Otherwise, + * the body content enclosed in the control tag will be rendered. + * @param THtmlWriter the writer used for the rendering purpose + */ + public function renderContents($writer) + { + if(($text=$this->getText())==='') + parent::renderContents($writer); + else + $writer->write($text); + } + + /** + * @return string the text caption of the button + */ + public function getText() + { + return $this->getViewState('Text',''); + } + + /** + * @param string the text caption to be set + */ + public function setText($value) + { + $this->setViewState('Text',$value,''); + } + + /** + * @return string the command name associated with the {@link onCommand OnCommand} event. + */ + public function getCommandName() + { + return $this->getViewState('CommandName',''); + } + + /** + * @param string the command name associated with the {@link onCommand OnCommand} event. + */ + public function setCommandName($value) + { + $this->setViewState('CommandName',$value,''); + } + + /** + * @return string the parameter associated with the {@link onCommand OnCommand} event + */ + public function getCommandParameter() + { + return $this->getViewState('CommandParameter',''); + } + + /** + * @param string the parameter associated with the {@link onCommand OnCommand} event. + */ + public function setCommandParameter($value) + { + $this->setViewState('CommandParameter',$value,''); + } + + /** + * @return boolean whether postback event trigger by this button will cause input validation + */ + public function getCausesValidation() + { + return $this->getViewState('CausesValidation',true); + } + + /** + * Sets the value indicating whether postback event trigger by this button will cause input validation. + * @param string the text caption to be set + */ + public function setCausesValidation($value) + { + $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); + } + + /** + * @return string the group of validators which the button causes validation upon postback + */ + public function getValidationGroup() + { + return $this->getViewState('ValidationGroup',''); + } + + /** + * @param string the group of validators which the button causes validation upon postback + */ + public function setValidationGroup($value) + { + $this->setViewState('ValidationGroup',$value,''); + } + + /** + * Raises the postback event. + * This method is required by {@link IPostBackEventHandler} interface. + * If {@link getCausesValidation CausesValidation} is true, it will + * invoke the page's {@link TPage::validate validate} method first. + * It will raise {@link onClick OnClick} and {@link onCommand OnCommand} events. + * This method is mainly used by framework and control developers. + * @param TEventParameter the event parameter + */ + public function raisePostBackEvent($param) + { + if($this->getCausesValidation()) + $this->getPage()->validate($this->getValidationGroup()); + $this->onClick(null); + $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); + } + + /** + * This method is invoked when the button is clicked. + * The method raises 'OnClick' event to fire up the event handlers. + * If you override this method, be sure to call the parent implementation + * so that the event handler can be invoked. + * @param TEventParameter event parameter to be passed to the event handlers + */ + public function onClick($param) + { + $this->raiseEvent('OnClick',$this,$param); + } + + /** + * This method is invoked when the button is clicked. + * The method raises 'OnCommand' event to fire up the event handlers. + * If you override this method, be sure to call the parent implementation + * so that the event handlers can be invoked. + * @param TCommandEventParameter event parameter to be passed to the event handlers + */ + public function onCommand($param) + { + $this->raiseEvent('OnCommand',$this,$param); + $this->raiseBubbleEvent($this,$param); + } +} + +?> -- cgit v1.2.3