From 1db22ed3a9bb223a4bb83b46537b03b8866e3650 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 27 Dec 2005 01:20:17 +0000 Subject: --- .../protected/pages/Fundamentals/Controls.page | 38 +++++++++++++++++++-- .../protected/pages/Fundamentals/Pages.page | 17 ++++++++- .../protected/pages/Fundamentals/lifecycles.gif | Bin 0 -> 60897 bytes .../protected/pages/Fundamentals/lifecycles.vsd | Bin 0 -> 225280 bytes 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 demos/quickstart/protected/pages/Fundamentals/lifecycles.gif create mode 100644 demos/quickstart/protected/pages/Fundamentals/lifecycles.vsd (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/Fundamentals/Controls.page b/demos/quickstart/protected/pages/Fundamentals/Controls.page index 7703003d..6c45acf1 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Controls.page +++ b/demos/quickstart/protected/pages/Fundamentals/Controls.page @@ -4,16 +4,48 @@ A control is an instance of class TControl or its subclass. A control is a component defined in addition with user interface. The base class TControl defines the parent-child relationship among controls which reflects the containment relationship among user interface elements.

-

Parent-Child Relationship

+

Control Tree

-A parent control is in charge of the state transition of its child controls. The rendering result of the child controls are usually used to compose the parent control's presentation. +Controls are related to each other via parent-child relationship. Each parent control can have one or several child controls. A parent control is in charge of the state transition of its child controls. The rendering result of the child controls are usually used to compose the parent control's presentation. The parent-child relationship brings together controls into a control tree. A page is at the root of the tree, whose presentation is returned to the end-users.

-The parent-child relationship is usually established by the framework via templates. In code, you may explicitly specify a control as a child of another using the following method, +The parent-child relationship is usually established by the framework via templates. In code, you may explicitly specify a control as a child of another using one of the following methods,

 $parent->Controls->add($child);
+$parent->Controls[]=$child;
 
where the property Controls refers to the child control collection of the parent.

+

Control Identification

+

+Each control has an ID property that can be uniquely identify itself among its sibling controls. In addition, each control has a UniqueID and a ClientID which can be used to globally identify the control in the tree that the control resides in. UniqueID and ClientID are very similar. The former is used by the framework to determine the location of the corresponding control in the tree, while the latter is mainly used on the client side as HTML tag IDs. In general, you should not rely on the explicit format of UniqueID or ClientID. +

+ +

Naming Containers

+

+Each control has a naming container which is a control creating a unique namespace for differentiating between controls with the same ID. For example, a TRepeater control creates multiple items each having child controls with the same IDs. To differentiate these child controls, each item serves as a naming container. Therefore, a child control may be uniquely identified using its naming container's ID together with its own ID. As you may already have understood, UniqueID and ClientID rely on the naming containers. +

+

+A control can serve as a naming container if it implements the INamingContainer interface. +

+ +

ViewState and ControlState

+

+HTTP is a stateless protocol, meaning it does not provide functionality to support continuing interaction between a user and a server. Each request is considered as discrete and independent of each other. A Web application, however, often needs to know what a user has done in previous requests. People thus introduce sessions to help remember such state information. +

+

+PRADO borrows the viewstate and controlstate concept from Microsoft ASP.NET to provides additional stateful programming mechanism. A value storing in viewstate or controlstate may be available to the next requests if the new requests are form submissions (called postback) to the same page by the same user. The difference between viewstate and controlstate is that the former can be disabled while the latter cannot. +

+

+Viewstate and controlstate are implemented in TControl. They are commonly used to define various properties of controls. To save and retrieve values from viewstate or controlstate, use following methods, +

+$this->getViewState('Name',$defaultValue);
+$this->setViewState('Name',$value,$defaultValue);
+$this->getControlState('Name',$defaultValue);
+$this->setControlState('Name',$value,$defaultValue);
+
+where $this refers to the control instance, Name refers to a key identifying the persistent value, $defaultValue is optional. When retrieving values from viewstate or controlstate, if the corresponding key does not exist, the default value will be returned. +

+ \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/Pages.page b/demos/quickstart/protected/pages/Fundamentals/Pages.page index 71434ae1..02662558 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Pages.page +++ b/demos/quickstart/protected/pages/Fundamentals/Pages.page @@ -2,7 +2,22 @@

Pages

-Pages are top-most controls that have no parent (you may consider application as their container though). The presentation of pages are directly displayed to end-users. +Pages are top-most controls that have no parent. The presentation of pages are directly displayed to end-users. Users access pages by sending page service requests. +

+

+Each page must have a template file. The file name suffix must be .page. The file name (without suffix) is the page name. PRADO will try to locate a page class file under the directory containing the page template file. Such a page class file must have the same file name (suffixed with .php) as the template file. If the class file is not found, the page will take class TPage. +

+ +

PostBack

+

+A form submission is called postback if the submission is made to the page containing the form. Postback can be considered an event happened on the client side, raised by the user. PRADO will try to identify which control on the server side is responsible for a postback event. If one is determined, for example, a TButton, we call it the postback event sender which will translate the postback event into some specific server-side event (e.g. Click and Command events for TButton). + +

+ +

Page Lifecycles

+

+Understanding the page lifecycles is crucial to grasp PRADO programming. Page lifecycles refer to the state transitions of a page when serving this page to end-users. They can be depicted in the following statechart, +

\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/lifecycles.gif b/demos/quickstart/protected/pages/Fundamentals/lifecycles.gif new file mode 100644 index 00000000..5edaff5f Binary files /dev/null and b/demos/quickstart/protected/pages/Fundamentals/lifecycles.gif differ diff --git a/demos/quickstart/protected/pages/Fundamentals/lifecycles.vsd b/demos/quickstart/protected/pages/Fundamentals/lifecycles.vsd new file mode 100644 index 00000000..368d0ba7 Binary files /dev/null and b/demos/quickstart/protected/pages/Fundamentals/lifecycles.vsd differ -- cgit v1.2.3