From f85d1a050dbacfc71c7c619df7b7eb792c89d8ee Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 26 Nov 2005 17:35:40 +0000 Subject: --- demos/controls/protected/pages/HomePage.tpl | 8 +- demos/controls/protected/pages/LoginPage.tpl | 2 + framework/Exceptions/messages.txt | 9 +- framework/Web/UI/TControl.php | 8 ++ framework/Web/UI/WebControls/THiddenField.php | 121 +++++++++++++++++--------- framework/Web/UI/WebControls/TImage.php | 11 +++ 6 files changed, 111 insertions(+), 48 deletions(-) diff --git a/demos/controls/protected/pages/HomePage.tpl b/demos/controls/protected/pages/HomePage.tpl index 333439f1..eaa9179b 100644 --- a/demos/controls/protected/pages/HomePage.tpl +++ b/demos/controls/protected/pages/HomePage.tpl @@ -1,6 +1,7 @@ <%@ MasterClass="Pages.master.MasterPage" %> +

Welcome! <%=$this->User->Name %>

@@ -11,12 +12,5 @@ />
| -> -this is my first test. this is my first test.this is my first test.this is my first test.this is my first test.this is my first test. -this is my first test. this is my first test.this is my first test.this is my first test.this is my first test.this is my first test. -this is my first test. this is my first test.this is my first test.this is my first test.this is my first test.this is my first test. -this is my first test. this is my first test.this is my first test.this is my first test.this is my first test.this is my first test. -this is my first test. this is my first test.this is my first test.this is my first test.this is my first test.this is my first test. -
\ No newline at end of file diff --git a/demos/controls/protected/pages/LoginPage.tpl b/demos/controls/protected/pages/LoginPage.tpl index cbbd683b..5f2c9b2b 100644 --- a/demos/controls/protected/pages/LoginPage.tpl +++ b/demos/controls/protected/pages/LoginPage.tpl @@ -1,6 +1,8 @@ + Username:
Password:
+
\ No newline at end of file diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index eb385ead..4c6a4c87 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -137,4 +137,11 @@ 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. \ No newline at end of file +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/TControl.php b/framework/Web/UI/TControl.php index af925d98..a3c031f4 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -370,6 +370,14 @@ class TControl extends TComponent return $this->_uid; } + /** + * 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 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 * @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 Value 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 @@ -35,6 +35,17 @@ class TImage extends TWebControl return 'img'; } + /** + * 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 -- cgit v1.2.3