<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to ViewState</title><link>https://sourceforge.net/p/pexeso-php/wiki/ViewState/</link><description>Recent changes to ViewState</description><atom:link href="https://sourceforge.net/p/pexeso-php/wiki/ViewState/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 20 May 2014 18:10:40 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/pexeso-php/wiki/ViewState/feed" rel="self" type="application/rss+xml"/><item><title>ViewState modified by Jan Volf</title><link>https://sourceforge.net/p/pexeso-php/wiki/ViewState/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="views-state"&gt;View's State&lt;/h1&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;View's state is essential part of the framework concept. It contains actually a properties of the application at given moment of time between user's interaction. The state is changed usually by user interaction with the application. In Pexeso the state of the whole application is not that important as the state of the &lt;a class="alink" href="/p/pexeso-php/wiki/View/"&gt;[View]&lt;/a&gt; the user is interacting with. The state of the view then contains all the properties of the view and it's components. &lt;/p&gt;
&lt;p&gt;Developer of the desktop application usually consider application state as natural thing as the desktop application is stored in computer's memory all the time it runs. On the other hand application running on the server for performance and scalability reasons are either completely stateless or stores on server just very essential user informations but they can get eventually purged. &lt;/p&gt;
&lt;p&gt;To make development of application in Pexeso as desktop application development alike the state of the application or it's components must be kept between the user interactions. Although the PHP script processing is in it's concept stateless there are various ways how to keep informations between the script executions. The usual way is to use session feature of the PHP or PHP cache. The nature of the web application is that the user can have open different views of the application (in separate windows or tabs of the browser) or even the same view several times at once. For that reason the session nor the cache cannot be used to store application state. &lt;/p&gt;
&lt;p&gt;To achieve best possible user experience the state must be stored together with the concrete view the user have opened. For this reason the state is encoded in to the rendered HTML of the view so there is no limit for user on how he/she interacts with it. &lt;/p&gt;
&lt;h2 id="states-lifecycle"&gt;State's Lifecycle&lt;/h2&gt;
&lt;p&gt;As the view gets through it's lifecycle stages the state gets along: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;View is initialized. &lt;ol&gt;
&lt;li&gt;When view is created there is no saved state of the view so the view is in it's default state. &lt;/li&gt;
&lt;li&gt;If the view is updated the state is decoded from HTTP post informations, deserialized and applied to the view. &lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;During execution stage of the view the state of the view is usually changed. These changes are captured by state manager. &lt;/li&gt;
&lt;li&gt;Before rendering the view the state of the view is serialized and encoded in to the rendered HTML. &lt;/li&gt;
&lt;li&gt;On post-back the lifecycle goes on at 1.b. &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="state-manager"&gt;State Manager&lt;/h2&gt;
&lt;p&gt;State manager is object responsible for managing state of the view. For each view there is one instance of state manager (StateManager? class) created. &lt;/p&gt;
&lt;p&gt;When component is added to the view during it's initialization it is also registered to the state manager using &lt;code&gt;registerClient()&lt;/code&gt; method of state manager. By default state manager expects components to implement &lt;code&gt;px\events\IPropertyChangeNotifier&lt;/code&gt;interface and watches for property changes of the component. Only property changes that happens after restoring state and before saving state are recorded. The component can also implement &lt;code&gt;px\core\IStatefull&lt;/code&gt; interface where just watching for property changes is not suitable. For such components the property changes are not watched, instead just &lt;code&gt;restoreState()&lt;/code&gt; and &lt;code&gt;saveState()&lt;/code&gt; methods of the interface are called. &lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jan Volf</dc:creator><pubDate>Tue, 20 May 2014 18:10:40 -0000</pubDate><guid>https://sourceforge.neta923fa8d10857385d961beef6aa49e184c0b0547</guid></item></channel></rss>