diff options
author | xue <> | 2005-11-26 17:35:40 +0000 |
---|---|---|
committer | xue <> | 2005-11-26 17:35:40 +0000 |
commit | f85d1a050dbacfc71c7c619df7b7eb792c89d8ee (patch) | |
tree | ed60f90732748e6f82c2f112e7dc7d156b79be87 /framework/Web/UI | |
parent | 33edf4e00ca2411a7849e6b479048c25c4a3ce6c (diff) |
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/TControl.php | 8 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/THiddenField.php | 121 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TImage.php | 11 |
3 files changed, 100 insertions, 40 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index af925d98..a3c031f4 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -371,6 +371,14 @@ class TControl extends TComponent }
/**
+ * Sets input focus to this control.
+ */
+ public function focus()
+ {
+ $this->getPage()->setFocus($this);
+ }
+
+ /**
* Returns the client ID of the control.
* The client ID can be used to uniquely identify
* the control in client-side scripts (such as JavaScript).
diff --git a/framework/Web/UI/WebControls/THiddenField.php b/framework/Web/UI/WebControls/THiddenField.php index c46f1cda..2da9773c 100644 --- a/framework/Web/UI/WebControls/THiddenField.php +++ b/framework/Web/UI/WebControls/THiddenField.php @@ -13,6 +13,11 @@ /**
* THiddenField class
*
+ * THiddenField displays a hidden input field on a Web page.
+ * The value of the input field can be accessed via {@link getValue Value} property.
+ * If upon postback the value is changed, a {@link onValueChanged ValueChanged}
+ * event will be raised.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -21,61 +26,54 @@ class THiddenField extends TControl implements IPostBackDataHandler
{
/**
- * @return string tag name of the hyperlink
+ * @return string tag name of the hidden field.
*/
protected function getTagName()
{
return 'input';
}
+ /**
+ * Sets focus to this control.
+ * This method overrides the parent implementation by forbidding setting focus to this control.
+ */
public function focus()
{
- throw new TInvalidOperationException('xxx');
- }
-
- protected function addAttributesToRender($writer)
- {
- $page=$this->getPage();
- $page->ensureRenderInForm($this);
- $writer->addAttribute('type','hidden');
- if(($uid=$this->getUniqueID())!=='')
- $writer->addAttribute('name',$uid);
- if(($id=$this->getID())!=='')
- $writer->addAttribute('id',$id);
- if(($value=$this->getValue())!=='')
- $writer->addAttribute('value',$value);
+ throw new TNotSupportedException('hiddenfield_focus_unsupported');
}
/**
- * @return string the value of the THiddenField
+ * 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 getValue()
+ public function addParsedObject($object)
{
- return $this->getViewState('Value','');
+ if($object instanceof TComponent)
+ throw new TConfigurationException('hiddenfield_body_forbidden');
}
/**
- * Sets the value of the THiddenField
- * @param string the value to be set
+ * Renders the control.
+ * This method overrides the parent implementation by rendering
+ * the hidden field input element.
+ * @param THtmlWriter the writer used for the rendering purpose
*/
- public function setValue($value)
- {
- $this->setViewState('Value',$value,'');
- }
-
- public function getEnableTheming()
- {
- return false;
- }
-
- public function setEnableTheming($value)
+ protected function render($writer)
{
- throw new TInvalidOperationException('no_theming_support');
- }
-
- public function setSkinID($value)
- {
- throw new TInvalidOperationException('no_theming_support');
+ $uniqueID=$this->getUniqueID();
+ $page=$this->getPage();
+ $page->ensureRenderInForm($this);
+ //$page->getClientScript()->registerForEventValidation($uniqueID);
+ $writer->addAttribute('type','hidden');
+ if($uniqueID!=='')
+ $writer->addAttribute('name',$uniqueID);
+ if($this->getID()!=='')
+ $writer->addAttribute('id',$this->getClientID());
+ if(($value=$this->getValue())!=='')
+ $writer->addAttribute('value',$value);
+ $writer->renderBeginTag('input');
+ $writer->renderEndTag();
}
/**
@@ -104,20 +102,63 @@ class THiddenField extends TControl implements IPostBackDataHandler */
public function raisePostDataChangedEvent()
{
- $this->onValueChanged(new TEventParameter);
+ $this->onValueChanged(null);
}
/**
- * This method is invoked when the value of the <b>Value</b> property changes between posts to the server.
+ * This method is invoked when the value of the {@link getValue Value} property changes between posts to the server.
* The method raises 'ValueChanged' event to fire up the event delegates.
* If you override this method, be sure to call the parent implementation
- * so that the event delegates can be invoked.
+ * so that the attached event handlers can be invoked.
* @param TEventParameter event parameter to be passed to the event handlers
*/
public function onValueChanged($param)
{
$this->raiseEvent('ValueChanged',$this,$param);
}
+
+ /**
+ * @return string the value of the THiddenField
+ */
+ public function getValue()
+ {
+ return $this->getViewState('Value','');
+ }
+
+ /**
+ * Sets the value of the THiddenField
+ * @param string the value to be set
+ */
+ public function setValue($value)
+ {
+ $this->setViewState('Value',$value,'');
+ }
+
+ /**
+ * @return boolean whether theming is enabled for this control. Defaults to false.
+ */
+ public function getEnableTheming()
+ {
+ return false;
+ }
+
+ /**
+ * @param boolean whether theming is enabled for this control.
+ * @throws TNotSupportedException This method is always thrown when calling this method.
+ */
+ public function setEnableTheming($value)
+ {
+ throw new TNotSupportedException('hiddenfield_theming_unsupported');
+ }
+
+ /**
+ * @param string Skin ID
+ * @throws TNotSupportedException This method is always thrown when calling this method.
+ */
+ public function setSkinID($value)
+ {
+ throw new TNotSupportedException('hiddenfield_skinid_unsupported');
+ }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TImage.php b/framework/Web/UI/WebControls/TImage.php index dd0387a5..452bae4e 100644 --- a/framework/Web/UI/WebControls/TImage.php +++ b/framework/Web/UI/WebControls/TImage.php @@ -36,6 +36,17 @@ 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
*/
|