Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
The prado frame controls the born method of piece
In the process of using prado, for the sake of born more complicated with the interface of amity, need us to write to lately control a piece.
Total of to say, have two kinds of born lately control the way of piece:The combination has been already exist of control a piece and expand have already exist of control a piece.These are two kinds of born control the ways of piece all need their types inherit from TControl perhaps it of son.
Underneath's two kinds of to these method carries on introduction:
A, the combination has been already exist of control a piece
The combination is lately born to control the most simple way of piece, we needing to be be absorbed in have already exist of control a piece, there are two kinds of ways which is born to lately control a piece through a combination, 1 kind expands TCompositeControl and overlay TControl:: createChildControls() this method;Another is son which expands TTemplateControl perhaps it, write a control template., Opposite but speech, the latter wants in brief at 1:00, and passes this kind of way can the layout of very easy understanding interface, but the efficiency of the former want compare the latter Gao, because it doesn't need to analyze template.
In the actual development process of interface, we may usually need to control a labele piece and a textbox to control a combination usage, if ability will these two space set put together born 1 lately controls a piece and would that make our developments easily a lot of?The example of underneath is to pass two above-mentioned kind born process which lately controls a LabeledTextBox with a method:
1, pass to write a way of control a template to combine to lately control a piece
This kind of way needs two documents:Control piece LabeledTextBox.php and control the LabeledTextBox.tpl of a template document, these two documents have to put in the same of catalogue.
With write the document of prado page about, below is the code which controls a template LabeledTextBox.tpl:
<com:TLabel ID="Label" ForControl="TextBox"/>
<com:TTextBox ID="TextBox"/>
It declared an id to control a piece for the TTextBox that the Label TLabel controls piece and an id as TextBox and we needed to register these 2 to control a piece.We can pass to control a piece to define an attribute respectively for these 2 in the LabeledTextBox document, for example, we define a Label attribute:
class LabeledTextBox extends TTemplateControl {
public function getLabel() {
$this->ensureChildControls();
return $this->getRegisteredObject('Label');
}
}
In the code of top, ensureChildControls() this adjusted to use to promise to successfully establish label and textbox these 2 to control a piece when the Label attribute be visit and the TextBox attribute is also such.
While using that method to combine to lately control a piece need to be include in the page Php document should lately control the path of piece, for example:Example.php(the LabeledTextBox control a piece to place in the pages/ NewControls under the path)
<?php
Prado::using('Application.pages.NewControls.LabeledTextBox');
class Home extends TPage
{
public function buttonClicked($sender,$param)
{
$sender->Text=$this->Input->TextBox->Text;
}
}
?>
2, pass a way combination of overlay the createChildControls() to lately control a piece
In the process of combining to lately control a piece, the best way is to pass to expand TCompositeControl to overlay a createChildControls() method, it doesn't need template, so can save time of analyze the template, lift thus high-efficiency.
The underneath is to completely pass to expand TCompositeControl case a code:
class LabeledTextBox extends TCompositeControl {
private $_label;
private $_textbox;
protected function createChildControls() {
$this->_label=new TLabel;
$this->_label->setID('Label');
// add the label as a child of LabeledTextBox
$this->getControls()->add($this->_label);
$this->_textbox=new TTextBox;
$this->_textbox->setID('TextBox');
$this->_label->setForControl('TextBox');
// add the textbox as a child of LabeledTextBox
$this->getControls()->add($this->_textbox);
}
public function getLabel() {
$this->ensureChildControls();
return $this->_label;
}
public function getTextBox() {
$this->ensureChildControls();
return $this->_textbox;
}
}
Lately control a piece already born, how should we use?
<com:LabeledTextBox ID="Input" Label.Text="Username"/>
And the usage be common of the prado control one similar, isn't easy?The Label.Text is a lable writing description.
Two, expand have already exist of control a piece
Expand have already exist of control a piece to inherit a way with traditional type similar, pass this kind of method, we can pass to overlay their attribute, method, affairs processing…etc. to make to order some have already exist of control piece.
The difficulty of this kind of way lies in being overlay of control piece scale, give examples to say, in make to order the TLabel control the piece, we the color that need to be made the lable recognize tacitly be a red, this only needs us a constitution a ForeColor attribute in the structure function ok.Establish is more difficult a has new function of control a piece, usually, this kind of control of way piece needs to inherit low level foundation, such as TControl perhaps TWebControl.
1, expand TControl
The TControl is all to control piece foundation a type.Have two most important methods:
· AddParsedObject() – this method at marking a template in all module perhaps has the text of tag label originally is adjust to use.Recognize tacitly of, these modules perhaps text originally want to be added container of control the piece, freshman become of control a piece may overlay this method while handle the contents of its oneself, for example, TListControl will accept TListItem module and these modules want to be added TListControl container.
· Render() – this method is to draw interface and recognize tacitly of, it will some a control all contentses of piece present, freshman become of control piece can overlay this method to make to order a type of have the special features.
Some important attributes and method of other:
· The marking of ID – is a string which controls a piece, if there is no definition, it will be automatic and born.
· The meaning of
the UnqiueID – the top of the heel about, can pass to adjust to use TControl::findControl() position 1 to control a piece.
· The similar UniqueID of the ClientID – can appear by body in the HTML chemical element of interface..
· The Enabled –'s constitution is some to control a piece current whether enable, the son controls a piece to inherit the attribute that the father controls a piece.
· The Parent – should control the father of piece to control a piece.It will be responsible for and should control a piece whether carries on draw and decide should control a piece of draw whether result carries on deposit or not.
· The containment of Page – controls the page of piece.
· Controls – all sons control the container of piece, include a static text originally, it can be a several, and carry out Traversable to connect, controling a statures a piece to add should control in the piece, in brief of insert it to suitable position all right.
· The setViewState() – of the getViewState() and these two method is usually use to define an attribute of control the piece and they pass constitution viewstate the method of the attribute.
· The loadState() – of the saveState() and these two methods provide the spot and keep the spot, can be overlay.
2, expand TWebControl
TWebControl conduct and actions' a main foundation is use while present HTML chemical element, it provided to establish a HTML chemical element the method of the attribute, it resolved TControl:: render() for as follows and more can describe the method of HTML chemical element:
· The addAttributesToRender() – adds an attribute of HTML chemical element which wants to be describe and be the attribute which needs to describe a dissimilarity and that method usually wants to be overlay.
· The renderBeginTag() – describes the beginning label of HTML chemical element
· The renderContents() – is similar to the the above.While needing to make to order a contents , that method wants to be overlay.
· RenderEndTag()-describe the be over label of HTML chemical element
While describing HTML tag, TWebControl carried out getTagName() to obtain the name of that label, such as adjust to return with that method in TButton of be "input".Can pass to overlay that method to describe different label name.
3, establish to have control of special function a piece
If 1 controls a demand to carry to receive affairs then deliver to carry for server at the customer, for example TButton, need to carry out IPostBackEventHandler this to connect.
If 1 controls a piece and can add to carry a data, for example TTextBox, need to carry out IPostBackDataHandler this to connect.
Tally up:The havings which takes a wide view prado controls a piece, in fact the principle is through an usage to inherit TControl perhaps now TWebControl in to HTML standard controled a piece to carry on connect of a packing, these connect to mainly pass organization and describe HTML label, end present on the interface, the prado is to pass setviewstate and getviewstate to carry out while collect all attributes of HTML chemical elements.Control the affairs processing in the piece, and the customer input the check of legitimacy, is handler and validator which passes to register an affairs processing to carry out.Wills handle affairs procedure and validator judgment procedure to put in the js document when each application circulate, the customer carries direct containment to come in, so some simple of affairs processing and false check carry to carry on at the customer.