summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2005-12-06 18:59:31 +0000
committerxue <>2005-12-06 18:59:31 +0000
commitfa1bc21a7f5346c702490dffbe3cf3f9940b3cd0 (patch)
tree79bf8f120f89e26b6c810bfa4ee136f50de1ee00
parent10ae6ed6ee263644d3d7780153520af76215d178 (diff)
-rw-r--r--demos/controls/protected/pages/HomePage.php5
-rw-r--r--demos/controls/protected/pages/HomePage.tpl2
-rw-r--r--framework/Exceptions/messages.txt5
-rw-r--r--framework/Web/UI/WebControls/TButton.php126
-rw-r--r--framework/Web/UI/WebControls/THiddenField.php11
-rw-r--r--framework/Web/UI/WebControls/TImage.php13
-rw-r--r--framework/Web/UI/WebControls/TImageButton.php234
-rw-r--r--framework/Web/UI/WebControls/TLinkButton.php15
-rw-r--r--framework/Web/UI/WebControls/TLiteral.php11
9 files changed, 236 insertions, 186 deletions
diff --git a/demos/controls/protected/pages/HomePage.php b/demos/controls/protected/pages/HomePage.php
index d7f7e1be..d599dd95 100644
--- a/demos/controls/protected/pages/HomePage.php
+++ b/demos/controls/protected/pages/HomePage.php
@@ -18,6 +18,11 @@ class HomePage extends TPage
$this->TextBox->focus();
}
+ public function clickImage($sender,$param)
+ {
+ $this->TextBox->Text="You Clicked (".$param->X.", ".$param->Y.")";
+ }
+
public function linkClicked($sender,$param)
{
$sender->Text="Hello World";
diff --git a/demos/controls/protected/pages/HomePage.tpl b/demos/controls/protected/pages/HomePage.tpl
index 9cb24d3f..d3cc53df 100644
--- a/demos/controls/protected/pages/HomePage.tpl
+++ b/demos/controls/protected/pages/HomePage.tpl
@@ -10,7 +10,7 @@
<com:System.Web.UI.WebControls.TButton text="Toggle Button" ForeColor="red" Font.size="18" Click="testClick" /> (requires membership)<br/>
<com:TCheckBox Text="Checkbox" ID="checkbox"/><br/>
<com:TImage ImageUrl=<%~/fungii_logo.gif %> />
-<com:TImageButton ImageUrl=<%~/fungii_logo.gif %> /><br/>
+<com:TImageButton ImageUrl=<%~/fungii_logo.gif %> Click="clickImage"/><br/>
<com:THyperLink Text="Visit a 'classless' page" NavigateUrl="?sp=page.plain" /> |
<com:THyperLink Text="Visit member only page" NavigateUrl="?sp=page.private.member" />
<com:TLinkButton Text="Click Me" Click="linkClicked" OnClientClick="javascript:alert('you hit me')"/>
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt
index 8a20b0c0..e706ebbf 100644
--- a/framework/Exceptions/messages.txt
+++ b/framework/Exceptions/messages.txt
@@ -137,11 +137,6 @@ webcontrol_style_invalid = %s.Style must take string value only.
label_associatedcontrol_invalid = TLabel.AssociatedControl '%s' cannot be found.
-literal_body_forbidden = TLiteral controls do not allow body contents.
-
-image_body_forbidden = TImage controls do not allow body contents.
-
-hiddenfield_body_forbidden = THiddenField controls do not allow body contents.
hiddenfield_focus_unsupported = THiddenField does not support setting input focus.
hiddenfield_theming_unsupported = THiddenField does not support theming.
hiddenfield_skinid_unsupported = THiddenField does not support control skin. \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index 472dd818..a9eac8ac 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -13,20 +13,42 @@
/**
* TButton class
*
- * TButton creates a click button on the page.
+ * TButton creates a click button on the page. It is used to submit data to a page.
+ * You can create either a <b>submit</b> button or a <b>command</b> button.
*
- * You can create either a <b>submit</b> button or a <b>client</b> button by setting
- * <b>UseSubmitBehavior</b> property. Set <b>Text</b> property to specify the button's caption.
- * Upon clicking on the button, on the server side two events are raised by the button:
- * <b>OnClick</b> and <b>OnCommand</b>. You can attach event handlers to these events
- * to respond to the button click action. For <b>OnCommand</b> event, you can associate
- * it with a command name and parameter by setting <b>CommandName</b> and <b>CommandParameter</b>
- * properties, respectively. They are passed as the event parameter to the <b>OnCommand</b>
- * event handler (see {@link TCommandEventParameter}).
+ * A <b>command</b> 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 Command} 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}.
*
- * Clicking on button can trigger form validation, if <b>CausesValidation</b> is true.
- * And the validation may be restricted within a certain group of validator controls by
- * setting <b>ValidationGroup</b> property.
+ * A <b>submit</b> 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 TButton component is a submit button.
+ * You can provide an event handler for the {@link onClick Click} 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.
+ * You can change the postback target by setting the {@link setPostBackUrl PostBackUrl}
+ * property.
+ *
+ * To set the client-side javascript associated with the user's click action,
+ * use the {@link setOnClientClick OnClientClick} property. The value will be rendered
+ * as the <b>onclick</b> attribute of the button.
+ *
+ * TButton displays the {@link setText Text} property as the button caption.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -44,18 +66,6 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * Processes an object that is created during parsing template.
- * This overrides the parent implementation by forbidding any body components.
- * @param mixed the newly created object in template
- * @throws TInvalidOperationException if a component is found within body
- */
- public function addParsedObject($object)
- {
- if(!is_string($object))
- throw new TInvalidOperationException('body_contents_not_allowed',get_class($this).':'.$this->getUniqueID());
- }
-
- /**
* 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
@@ -64,30 +74,45 @@ class TButton extends TWebControl implements IPostBackEventHandler
{
$page=$this->getPage();
$page->ensureRenderInForm($this);
- if($this->getUseSubmitBehavior())
- $writer->addAttribute('type','submit');
- else
- $writer->addAttribute('type','button');
+ $writer->addAttribute('type',$this->getUseSubmitBehavior()?'submit':'button');
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
$writer->addAttribute('value',$this->getText());
- $onclick='';
if($this->getEnabled(true))
{
- $onclick=$this->getOnClientClick();
- if($onclick!=='')
- $onclick=rtrim($onclick,';').';';
+ $onclick='';
+ $onclick=$this->hasAttribute('onclick')?$this->getAttributes()->remove('onclick'):'';
+ $onclick=THttpUtility::trimJavaScriptString($onclick).THttpUtility::trimJavaScriptString($this->getOnClientClick());
$onclick.=$page->getClientScript()->getPostBackEventReference($this,'',$this->getPostBackOptions(),false);
+ if(!empty($onclick))
+ $writer->addAttribute('onclick','javascript:'.$onclick);
}
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
- if($onclick!=='')
- $writer->addAttribute('onclick','javascript:'.$onclick);
parent::addAttributesToRender($writer);
}
/**
+ * Returns postback specifications for the button.
+ * This method is used by framework and control developers.
+ * @return TPostBackOptions parameters about how the button defines its postback behavior.
+ */
+ protected function getPostBackOptions()
+ {
+ $options=new TPostBackOptions();
+ if($this->getCausesValidation() && $this->getPage()->getValidators($this->getValidationGroup())->getCount()>0)
+ {
+ $options->setPerformValidation(true);
+ $options->setValidationGroup($this->getValidationGroup());
+ }
+ if($this->getPostBackUrl()!=='')
+ $options->setActionUrl($this->getPostBackUrl());
+ $options->setClientSubmit(!$this->getUseSubmitBehavior());
+ return $options;
+ }
+
+ /**
* Renders the body content enclosed between the control tag.
* This overrides the parent implementation with nothing to be rendered.
* @param THtmlWriter the writer used for the rendering purpose
@@ -139,27 +164,6 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * Returns postback specifications for the button.
- * This method is used by framework and control developers.
- * @return TPostBackOptions parameters about how the button defines its postback behavior.
- */
- protected function getPostBackOptions()
- {
- $options=new TPostBackOptions();
- $options->setClientSubmit(false);
- $page=$this->getPage();
- if($this->getCausesValidation() && $page->getValidators($this->getValidationGroup())->getCount()>0)
- {
- $options->setPerformValidation(true);
- $options->setValidationGroup($this->getValidationGroup());
- }
- if($this->getPostBackUrl()!=='')
- $options->setActionUrl($this->getPostBackUrl());
- $options->setClientSubmit(!$this->getUseSubmitBehavior());
- return $options;
- }
-
- /**
* @return string caption of the button
*/
public function getText()
@@ -192,7 +196,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * @return string the command name associated with the <b>OnCommand</b> event.
+ * @return string the command name associated with the {@link onCommand Command} event.
*/
public function getCommandName()
{
@@ -200,7 +204,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * Sets the command name associated with the <b>OnCommand</b> event.
+ * Sets the command name associated with the {@link onCommand Command} event.
* @param string the text caption to be set
*/
public function setCommandName($value)
@@ -209,7 +213,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * @return string the parameter associated with the <b>OnCommand</b> event
+ * @return string the parameter associated with the {@link onCommand Command} event
*/
public function getCommandParameter()
{
@@ -217,7 +221,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * Sets the parameter associated with the <b>OnCommand</b> event.
+ * Sets the parameter associated with the {@link onCommand Command} event.
* @param string the text caption to be set
*/
public function setCommandParameter($value)
@@ -274,7 +278,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * @return string the javascript to be executed when the button is clicked
+ * @return string the javascript to be executed when the button is clicked.
*/
public function getOnClientClick()
{
@@ -282,7 +286,7 @@ class TButton extends TWebControl implements IPostBackEventHandler
}
/**
- * @param string the javascript to be executed when the button is clicked. Do not prefix it with "javascript:".
+ * @param string the javascript to be executed when the button is clicked.
*/
public function setOnClientClick($value)
{
diff --git a/framework/Web/UI/WebControls/THiddenField.php b/framework/Web/UI/WebControls/THiddenField.php
index 2da9773c..5c8605f7 100644
--- a/framework/Web/UI/WebControls/THiddenField.php
+++ b/framework/Web/UI/WebControls/THiddenField.php
@@ -43,17 +43,6 @@ class THiddenField extends TControl implements IPostBackDataHandler
}
/**
- * Processes an object that is created during parsing template.
- * This method overrides the parent implementation by forbidding any child controls.
- * @param string|TComponent text string or component parsed and instantiated in template
- */
- public function addParsedObject($object)
- {
- if($object instanceof TComponent)
- throw new TConfigurationException('hiddenfield_body_forbidden');
- }
-
- /**
* Renders the control.
* This method overrides the parent implementation by rendering
* the hidden field input element.
diff --git a/framework/Web/UI/WebControls/TImage.php b/framework/Web/UI/WebControls/TImage.php
index 452bae4e..3f7b8f49 100644
--- a/framework/Web/UI/WebControls/TImage.php
+++ b/framework/Web/UI/WebControls/TImage.php
@@ -36,17 +36,6 @@ class TImage extends TWebControl
}
/**
- * Processes an object that is created during parsing template.
- * This method overrides the parent implementation by forbidding any child controls.
- * @param string|TComponent text string or component parsed and instantiated in template
- */
- public function addParsedObject($object)
- {
- if($object instanceof TComponent)
- throw new TConfigurationException('image_body_forbidden');
- }
-
- /**
* Adds attributes related to an HTML image element to renderer.
* @param THtmlWriter the writer used for the rendering purpose
*/
@@ -126,7 +115,7 @@ class TImage extends TWebControl
}
/**
- * @return string link to long description
+ * @return string the URL to long description
*/
public function getDescriptionUrl()
{
diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php
index 4c8ae251..669e517e 100644
--- a/framework/Web/UI/WebControls/TImageButton.php
+++ b/framework/Web/UI/WebControls/TImageButton.php
@@ -18,24 +18,44 @@ Prado::using('System.Web.UI.WebControls.TImage');
/**
* TImageButton class
*
- * TImageButton displays an image on the Web page and responds to mouse clicks on the image.
- * It is similar to the {@link TButton} control except that the TImageButton also captures the
- * coordinates where the image is clicked.
+ * TImageButton creates an image button on the page. It is used to submit data to a page.
+ * You can create either a <b>submit</b> button or a <b>command</b> button.
*
- * Write a <b>OnClick</b> event handler to programmatically determine the coordinates
- * where the image is clicked. The coordinates can be accessed through <b>x</b> and <b>y</b>
- * properties of the event parameter which is of type <b>TImageClickEventParameter</b>.
- * Note the origin (0, 0) is located at the upper left corner of the image.
+ * A <b>command</b> 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 Command} 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}.
*
- * Write a <b>OnCommand</b> event handler to make the TImageButton component behave
- * like a command button. A command name can be associated with the component by using
- * the <b>CommandName</b> property. The <b>CommandParameter</b> property
- * can also be used to pass additional information about the command,
- * such as specifying ascending order. This allows multiple TImageButton components to be placed
- * on the same Web page. In the event handler, you can also determine
- * the <b>CommandName</b> property value and the <b>CommandParameter</b> property value
- * through <b>name</b> and <b>parameter</b> of the event parameter which is of
- * type <b>TCommandEventParameter</b>.
+ * A <b>submit</b> 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 TImageButton control is a submit button.
+ * You can provide an event handler for the {@link onClick Click} event
+ * to programmatically control the actions performed when the submit button is clicked.
+ * The coordinates of the clicking point can be obtained from the {@link onClick Click}
+ * event parameter, which is of type {@link TImageClickEventParameter}.
+ *
+ * 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.
+ * You can change the postback target by setting the {@link setPostBackUrl PostBackUrl}
+ * property.
+ *
+ * To set the client-side javascript associated with the user's click action,
+ * use the {@link setOnClientClick OnClientClick} property. The value will be rendered
+ * as the <b>onclick</b> attribute of the button.
+ *
+ * TImageButton displays the {@link setText Text} property as the hint text to the displayed image.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -44,7 +64,13 @@ Prado::using('System.Web.UI.WebControls.TImage');
*/
class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEventHandler
{
+ /**
+ * @var integer x coordinate that the image is being clicked at
+ */
private $_x=0;
+ /**
+ * @var integer y coordinate that the image is being clicked at
+ */
private $_y=0;
/**
@@ -68,13 +94,14 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
- $onclick='';
if($this->getEnabled(true))
{
- $onclick=$this->getOnClientClick();
- if($onclick!=='')
- $onclick=rtrim($onclick,';').';';
+ $onclick='';
+ $onclick=$this->hasAttribute('onclick')?$this->getAttributes()->remove('onclick'):'';
+ $onclick=THttpUtility::trimJavaScriptString($onclick).THttpUtility::trimJavaScriptString($this->getOnClientClick());
$onclick.=$page->getClientScript()->getPostBackEventReference($this,'',$this->getPostBackOptions(),false);
+ if(!empty($onclick))
+ $writer->addAttribute('onclick','javascript:'.$onclick);
}
else if($this->getEnabled()) // in this case, parent will not render 'disabled'
$writer->addAttribute('disabled','disabled');
@@ -91,15 +118,14 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
protected function getPostBackOptions()
{
$options=new TPostBackOptions();
- $options->ClientSubmit=false;
- $page=$this->getPage();
- if($this->getCausesValidation() && $page->getValidators($this->getValidationGroup())->getCount()>0)
+ if($this->getCausesValidation() && $this->getPage()->getValidators($this->getValidationGroup())->getCount()>0)
{
- $options->PerformValidation=true;
- $options->ValidationGroup=$this->getValidationGroup();
+ $options->setPerformValidation(true);
+ $options->setValidationGroup($this->getValidationGroup());
}
if($this->getPostBackUrl()!=='')
- $options->ActionUrl=THttpUtility::quoteJavaScriptString($this->getPostBackUrl());
+ $options->setActionUrl($this->getPostBackUrl());
+ $options->setClientSubmit(false);
return $options;
}
@@ -117,27 +143,12 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
{
$this->_x=intval($values["{$uid}_x"]);
$this->_y=intval($values["{$uid}_y"]);
- $page=$this->getPage()->setPostBackEventTarget($this);
+ $this->getPage()->setPostBackEventTarget($this);
}
return false;
}
/**
- * Raises postback event.
- * The implementation of this function should raise appropriate event(s) (e.g. OnClick, OnCommand)
- * indicating the component is responsible for the postback event.
- * This method is primarily used by framework developers.
- * @param string the parameter associated with the postback event
- */
- public function raisePostBackEvent($param)
- {
- if($this->getCausesValidation())
- $this->getPage()->validate($this->getValidationGroup());
- $this->onClick(new TImageClickEventParameter($this->_x,$this->_y));
- $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter()));
- }
-
- /**
* A dummy implementation for the IPostBackDataHandler interface.
*/
public function raisePostDataChangedEvent()
@@ -146,11 +157,11 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
- * This method is invoked when the component is clicked.
- * The method raises 'Click' event to fire up the event delegates.
+ * This method is invoked when the button is clicked.
+ * The method raises 'Click' event to fire up the event handlers.
* If you override this method, be sure to call the parent implementation
- * so that the event delegates can be invoked.
- * @param TEventParameter event parameter to be passed to the event handlers
+ * so that the event handler can be invoked.
+ * @param TImageClickEventParameter event parameter to be passed to the event handlers
*/
public function onClick($param)
{
@@ -158,10 +169,10 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
- * This method is invoked when the component is clicked.
- * The method raises 'Command' event to fire up the event delegates.
+ * This method is invoked when the button is clicked.
+ * The method raises 'Command' event to fire up the event handlers.
* If you override this method, be sure to call the parent implementation
- * so that the event delegates can be invoked.
+ * so that the event handlers can be invoked.
* @param TCommandEventParameter event parameter to be passed to the event handlers
*/
public function onCommand($param)
@@ -170,61 +181,71 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
$this->raiseBubbleEvent($this,$param);
}
- protected function onPreRender($param)
+ /**
+ * 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 Click} and {@link onCommand Command} events.
+ * This method is mainly used by framework and control developers.
+ * @param TEventParameter the event parameter
+ */
+ public function raisePostBackEvent($param)
{
- parent::onPreRender($param);
- $this->getPage()->registerRequiresPostBack($this);
+ if($this->getCausesValidation())
+ $this->getPage()->validate($this->getValidationGroup());
+ $this->onClick(new TImageClickEventParameter($this->_x,$this->_y));
+ $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter()));
}
/**
- * @return string the command name associated with the <b>OnCommand</b> event.
+ * @return boolean whether postback event trigger by this button will cause input validation, default is true
*/
- public function getCommandName()
+ public function getCausesValidation()
{
- return $this->getViewState('CommandName','');
+ return $this->getViewState('CausesValidation',true);
}
/**
- * Sets the command name associated with the <b>OnCommand</b> event.
- * @param string the text caption to be set
+ * @param boolean whether postback event trigger by this button will cause input validation
*/
- public function setCommandName($value)
+ public function setCausesValidation($value)
{
- $this->setViewState('CommandName',$value,'');
+ $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true);
}
/**
- * @return string the parameter associated with the <b>OnCommand</b> event
+ * @return string the command name associated with the {@link onCommand Command} event.
*/
- public function getCommandParameter()
+ public function getCommandName()
{
- return $this->getViewState('CommandParameter','');
+ return $this->getViewState('CommandName','');
}
/**
- * Sets the parameter associated with the <b>OnCommand</b> event.
+ * Sets the command name associated with the {@link onCommand Command} event.
* @param string the text caption to be set
*/
- public function setCommandParameter($value)
+ public function setCommandName($value)
{
- $this->setViewState('CommandParameter',$value,'');
+ $this->setViewState('CommandName',$value,'');
}
/**
- * @return boolean whether postback event trigger by this button will cause input validation
+ * @return string the parameter associated with the {@link onCommand Command} event
*/
- public function getCausesValidation()
+ public function getCommandParameter()
{
- return $this->getViewState('CausesValidation',true);
+ return $this->getViewState('CommandParameter','');
}
/**
- * Sets the value indicating whether postback event trigger by this button will cause input validation.
+ * Sets the parameter associated with the {@link onCommand Command} event.
* @param string the text caption to be set
*/
- public function setCausesValidation($value)
+ public function setCommandParameter($value)
{
- $this->setViewState('CausesValidation',$value,true);
+ $this->setViewState('CommandParameter',$value,'');
}
/**
@@ -260,7 +281,7 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
- * @return string the javascript to be executed when the button is clicked
+ * @return string the javascript to be executed when the button is clicked.
*/
public function getOnClientClick()
{
@@ -268,7 +289,7 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
}
/**
- * @param string the javascript to be executed when the button is clicked. Do not prefix it with "javascript:".
+ * @param string the javascript to be executed when the button is clicked.
*/
public function setOnClientClick($value)
{
@@ -290,17 +311,31 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven
{
$this->setAlternateText($value);
}
+
+ /**
+ * Registers the image button to receive postback data during postback.
+ * This is necessary because an image button, when postback, does not have
+ * direct mapping between post data and the image button name.
+ * This method overrides the parent implementation and is invoked before render.
+ * @param mixed event parameter
+ */
+ protected function onPreRender($param)
+ {
+ parent::onPreRender($param);
+ $this->getPage()->registerRequiresPostBack($this);
+ }
}
/**
* TImageClickEventParameter class
*
- * TImageClickEventParameter encapsulates the parameter data for <b>OnClick</b>
- * event of TImageButton components.
+ * TImageClickEventParameter encapsulates the parameter data for
+ * {@link TImageButton::onClick Click} event of {@link TImageButton} controls.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version v1.0, last update on 2004/08/13 21:44:52
+ * @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
+ * @since 3.0
*/
class TImageClickEventParameter extends TEventParameter
{
@@ -308,12 +343,55 @@ class TImageClickEventParameter extends TEventParameter
* the X coordinate of the clicking point
* @var integer
*/
- public $x=0;
+ public $_x=0;
/**
* the Y coordinate of the clicking point
* @var integer
*/
- public $y=0;
+ public $_y=0;
+
+ /**
+ * Constructor.
+ * @param integer X coordinate of the clicking point
+ * @param integer Y coordinate of the clicking point
+ */
+ public function __construct($x,$y)
+ {
+ $this->_x=$x;
+ $this->_y=$y;
+ }
+
+ /**
+ * @return integer X coordinate of the clicking point, defaults to 0
+ */
+ public function getX()
+ {
+ return $this->_x;
+ }
+
+ /**
+ * @param integer X coordinate of the clicking point
+ */
+ public function setX($value)
+ {
+ $this->_x=TPropertyValue::ensureInteger($value);
+ }
+
+ /**
+ * @return integer Y coordinate of the clicking point, defaults to 0
+ */
+ public function getY()
+ {
+ return $this->_y;
+ }
+
+ /**
+ * @param integer Y coordinate of the clicking point
+ */
+ public function setY($value)
+ {
+ $this->_y=TPropertyValue::ensureInteger($value);
+ }
}
?> \ No newline at end of file
diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php
index 517a2f8b..d3be1ade 100644
--- a/framework/Web/UI/WebControls/TLinkButton.php
+++ b/framework/Web/UI/WebControls/TLinkButton.php
@@ -38,9 +38,10 @@
* You can provide an event handler for the {@link onClick Click} event
* to programmatically control the actions performed when the submit button is clicked.
*
- * By default, clicking on a TLinkButton will cause input validation (if any)
- * to be performed. You can turn this on or off by setting
- * the {@link setCausesValidation CausesValidation} property.
+ * 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.
* You can change the postback target by setting the {@link setPostBackUrl PostBackUrl}
* property.
@@ -148,7 +149,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler
}
/**
- * @return string the command name associated with the <b>OnCommand</b> event.
+ * @return string the command name associated with the {@link onCommand Command} event.
*/
public function getCommandName()
{
@@ -156,7 +157,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler
}
/**
- * Sets the command name associated with the <b>OnCommand</b> event.
+ * Sets the command name associated with the {@link onCommand Command} event.
* @param string the text caption to be set
*/
public function setCommandName($value)
@@ -165,7 +166,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler
}
/**
- * @return string the parameter associated with the <b>OnCommand</b> event
+ * @return string the parameter associated with the {@link onCommand Command} event
*/
public function getCommandParameter()
{
@@ -173,7 +174,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler
}
/**
- * Sets the parameter associated with the <b>OnCommand</b> event.
+ * Sets the parameter associated with the {@link onCommand Command} event.
* @param string the text caption to be set
*/
public function setCommandParameter($value)
diff --git a/framework/Web/UI/WebControls/TLiteral.php b/framework/Web/UI/WebControls/TLiteral.php
index cda144dd..6ba5e4be 100644
--- a/framework/Web/UI/WebControls/TLiteral.php
+++ b/framework/Web/UI/WebControls/TLiteral.php
@@ -31,17 +31,6 @@
class TLiteral extends TControl
{
/**
- * Processes an object that is created during parsing template.
- * This method overrides the parent implementation by forbidding any child controls.
- * @param string|TComponent text string or component parsed and instantiated in template
- */
- public function addParsedObject($object)
- {
- if($object instanceof TComponent)
- throw new TConfigurationException('literal_body_forbidden');
- }
-
- /**
* @return string the static text of the TLiteral
*/
public function getText()