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 | |
| parent | 33edf4e00ca2411a7849e6b479048c25c4a3ce6c (diff) | |
| -rw-r--r-- | demos/controls/protected/pages/HomePage.tpl | 8 | ||||
| -rw-r--r-- | demos/controls/protected/pages/LoginPage.tpl | 2 | ||||
| -rw-r--r-- | framework/Exceptions/messages.txt | 9 | ||||
| -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 | 
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" %>
  <com:TContent id="header" >
  <com:TForm>
 +<com:THiddenField Value="test" />
  <h1>Welcome! <%=$this->User->Name %></h1>
  <com:TLiteral Text="<literal>" Encode="true"/>
  <com:TTextBox Text="textbox" />
 @@ -11,12 +12,5 @@  <com:TImageButton ImageUrl=<%~/fungii_logo.gif %> /><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:TPanel GroupingText="test" Direction="rtl" BackImageUrl=<%~/fungii_logo.gif%>>
 -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.
 -</com:TPanel>
  </com:TForm>
  </com:TContent>
\ 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 @@  <com:TForm>
 +<com:TPanel GroupingText="Login" Width="300px">
  Username: <com:TTextBox ID="username" /><br/>
  Password: <com:TTextBox ID="password" TextMode="Password" /><br/>
  <com:TButton Text="Login" Click="login" />
  <com:TLabel ID="error" />
 +</com:TPanel>
  </com:TForm>
\ 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 @@ -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
  	 */
  | 
