| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TActiveHiddenField class file.
|
|
|
4 |
*
|
|
|
5 |
* @author Carl G. Mathisen <carlgmathisen@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id$
|
|
|
10 |
* @package System.Web.UI.ActiveControls
|
|
|
11 |
*/
|
|
|
12 |
Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
|
|
|
13 |
/**
|
|
|
14 |
* TActiveHiddenField class
|
|
|
15 |
*
|
|
|
16 |
* TActiveHiddenField 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 |
*
|
|
|
19 |
* @author Carl G. Mathisen <carlgmathisen@gmail.com>
|
|
|
20 |
* @package System.Web.UI.ActiveControls
|
|
|
21 |
* @since 3.1
|
|
|
22 |
*/
|
|
|
23 |
class TActiveHiddenField extends THiddenField implements ICallbackEventHandler, IActiveControl
|
|
|
24 |
{
|
|
|
25 |
/**
|
|
|
26 |
* Creates a new callback control, sets the adapter to
|
|
|
27 |
* TActiveControlAdapter. If you override this class, be sure to set the
|
|
|
28 |
* adapter appropriately by, for example, by calling this constructor.
|
|
|
29 |
*/
|
|
|
30 |
public function __construct()
|
|
|
31 |
{
|
|
|
32 |
parent::__construct();
|
|
|
33 |
$this->setAdapter(new TActiveControlAdapter($this));
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* @return TBaseActiveCallbackControl standard callback control options.
|
|
|
38 |
*/
|
|
|
39 |
public function getActiveControl()
|
|
|
40 |
{
|
|
|
41 |
return $this->getAdapter()->getBaseActiveControl();
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* @return TCallbackClientSide client side request options.
|
|
|
46 |
*/
|
|
|
47 |
public function getClientSide()
|
|
|
48 |
{
|
|
|
49 |
return $this->getAdapter()->getBaseActiveControl()->getClientSide();
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Client-side Value property can only be updated after the OnLoad stage.
|
|
|
54 |
* @param string text content for the hidden field
|
|
|
55 |
*/
|
|
|
56 |
public function setValue($value)
|
|
|
57 |
{
|
|
|
58 |
parent::setValue($value);
|
|
|
59 |
if($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData())
|
|
|
60 |
$this->getPage()->getCallbackClient()->setValue($this, $value);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Raises the callback event. This method is required by {@link
|
|
|
65 |
* ICallbackEventHandler} interface.
|
|
|
66 |
* This method is mainly used by framework and control developers.
|
|
|
67 |
* @param TCallbackEventParameter the event parameter
|
|
|
68 |
*/
|
|
|
69 |
public function raiseCallbackEvent($param)
|
|
|
70 |
{
|
|
|
71 |
$this->onCallback($param);
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
* This method is invoked when a callback is requested. The method raises
|
|
|
76 |
* 'OnCallback' event to fire up the event handlers. If you override this
|
|
|
77 |
* method, be sure to call the parent implementation so that the event
|
|
|
78 |
* handler can be invoked.
|
|
|
79 |
* @param TCallbackEventParameter event parameter to be passed to the event handlers
|
|
|
80 |
*/
|
|
|
81 |
public function onCallback($param)
|
|
|
82 |
{
|
|
|
83 |
$this->raiseEvent('OnCallback', $this, $param);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Gets the name of the javascript class responsible for performing postback for this control.
|
|
|
88 |
* This method overrides the parent implementation.
|
|
|
89 |
* @return string the javascript class name
|
|
|
90 |
*/
|
|
|
91 |
protected function getClientClassName()
|
|
|
92 |
{
|
|
|
93 |
return 'Prado.WebUI.TActiveHiddenField';
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
/**
|
|
|
97 |
* Override parent implementation, no javascript is rendered here instead
|
|
|
98 |
* the javascript required for active control is registered in {@link addAttributesToRender}.
|
|
|
99 |
*/
|
|
|
100 |
protected function renderClientControlScript($writer)
|
|
|
101 |
{
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
/**
|
|
|
105 |
* Ensure that the ID attribute is rendered and registers the javascript code
|
|
|
106 |
* for initializing the active control.
|
|
|
107 |
*/
|
|
|
108 |
protected function addAttributesToRender($writer)
|
|
|
109 |
{
|
|
|
110 |
parent::addAttributesToRender($writer);
|
|
|
111 |
$writer->addAttribute('id',$this->getClientID());
|
|
|
112 |
$this->getActiveControl()->registerCallbackClientScript(
|
|
|
113 |
$this->getClientClassName(), $this->getPostBackOptions());
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|