[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/UI/WebControls/ -> THiddenField.php (source)

   1  <?php
   2  /**
   3   * THiddenField class file.
   4   *
   5   * @author Qiang Xue <qiang.xue@gmail.com>
   6   * @link http://www.xisc.com/
   7   * @copyright Copyright &copy; 2004-2005, Qiang Xue
   8   * @license http://www.opensource.org/licenses/bsd-license.php BSD License
   9   * @version $Id: THiddenField.php 1397 2006-09-07 07:55:53Z wei $
  10   * @package System.Web.UI.WebControls
  11   */
  12  
  13  /**
  14   * THiddenField class
  15   *
  16   * THiddenField displays a hidden input field on a Web page.
  17   * The value of the input field can be accessed via {@link getValue Value} property.
  18   * If upon postback the value is changed, a {@link onValueChanged OnValueChanged}
  19   * event will be raised.
  20   *
  21   * @author Qiang Xue <qiang.xue@gmail.com>
  22   * @version $Id: THiddenField.php 1397 2006-09-07 07:55:53Z wei $
  23   * @package System.Web.UI.WebControls
  24   * @since 3.0
  25   */
  26  class THiddenField extends TControl implements IPostBackDataHandler, IValidatable
  27  {
  28      /**
  29       * @return string tag name of the hidden field.
  30       */
  31  	protected function getTagName()
  32      {
  33          return 'input';
  34      }
  35  
  36      /**
  37       * Sets focus to this control.
  38       * This method overrides the parent implementation by forbidding setting focus to this control.
  39       */
  40  	public function focus()
  41      {
  42          throw new TNotSupportedException('hiddenfield_focus_unsupported');
  43      }
  44  
  45      /**
  46       * Renders the control.
  47       * This method overrides the parent implementation by rendering
  48       * the hidden field input element.
  49       * @param THtmlWriter the writer used for the rendering purpose
  50       */
  51  	public function render($writer)
  52      {
  53          $uniqueID=$this->getUniqueID();
  54          $this->getPage()->ensureRenderInForm($this);
  55          $writer->addAttribute('type','hidden');
  56          if($uniqueID!=='')
  57              $writer->addAttribute('name',$uniqueID);
  58          if($this->getID()!=='')
  59              $writer->addAttribute('id',$this->getClientID());
  60          if(($value=$this->getValue())!=='')
  61              $writer->addAttribute('value',$value);
  62          $writer->renderBeginTag('input');
  63          $writer->renderEndTag();
  64      }
  65  
  66      /**
  67       * Loads hidden field data.
  68       * This method is primarly used by framework developers.
  69       * @param string the key that can be used to retrieve data from the input data collection
  70       * @param array the input data collection
  71       * @return boolean whether the data of the component has been changed
  72       */
  73  	public function loadPostData($key,$values)
  74      {
  75          $value=$values[$key];
  76          if($value===$this->getValue())
  77              return false;
  78          else
  79          {
  80              $this->setValue($value);
  81              return true;
  82          }
  83      }
  84  
  85      /**
  86       * Returns the value to be validated.
  87       * This methid is required by IValidatable interface.
  88       * @return mixed the value of the property to be validated.
  89       */
  90  	public function getValidationPropertyValue()
  91      {
  92          return $this->getValue();
  93      }
  94  
  95      /**
  96       * Raises postdata changed event.
  97       * This method calls {@link onValueChanged} method.
  98       * This method is primarly used by framework developers.
  99       */
 100  	public function raisePostDataChangedEvent()
 101      {
 102          $this->onValueChanged(null);
 103      }
 104  
 105      /**
 106       * This method is invoked when the value of the {@link getValue Value} property changes between posts to the server.
 107       * The method raises 'OnValueChanged' event to fire up the event delegates.
 108       * If you override this method, be sure to call the parent implementation
 109       * so that the attached event handlers can be invoked.
 110       * @param TEventParameter event parameter to be passed to the event handlers
 111       */
 112  	public function onValueChanged($param)
 113      {
 114          $this->raiseEvent('OnValueChanged',$this,$param);
 115      }
 116  
 117      /**
 118       * @return string the value of the THiddenField
 119       */
 120  	public function getValue()
 121      {
 122          return $this->getViewState('Value','');
 123      }
 124  
 125      /**
 126       * Sets the value of the THiddenField
 127       * @param string the value to be set
 128       */
 129  	public function setValue($value)
 130      {
 131          $this->setViewState('Value',$value,'');
 132      }
 133  
 134      /**
 135       * @return boolean whether theming is enabled for this control. Defaults to false.
 136       */
 137  	public function getEnableTheming()
 138      {
 139          return false;
 140      }
 141  
 142      /**
 143       * @param boolean whether theming is enabled for this control.
 144       * @throws TNotSupportedException This method is always thrown when calling this method.
 145       */
 146  	public function setEnableTheming($value)
 147      {
 148          throw new TNotSupportedException('hiddenfield_theming_unsupported');
 149      }
 150  
 151      /**
 152       * @param string Skin ID
 153       * @throws TNotSupportedException This method is always thrown when calling this method.
 154       */
 155  	public function setSkinID($value)
 156      {
 157          throw new TNotSupportedException('hiddenfield_skinid_unsupported');
 158      }
 159  }
 160  
 161  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7