[GENERIC] Zend_Translate:
[zend.git] / documentation / manual / en / module_specs / Zend_Controller-ActionHelpers-FlashMessenger.xml
blobffc9c1af4534e23909df9fb521001fe97f1fd1fb
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- Reviewed: no -->
3 <sect3 id="zend.controller.actionhelpers.flashmessenger">
4     <title>FlashMessenger</title>
6     <sect4 id="zend.controller.actionhelper.flashmessenger.introduction">
7         <title>Introduction</title>
9         <para>
10             The <emphasis>FlashMessenger</emphasis> helper allows you to pass messages
11             that the user may need to see on the next request. To accomplish
12             this, <emphasis>FlashMessenger</emphasis> uses
13             <classname>Zend_Session_Namespace</classname> to store messages for future or
14             next request retrieval. It is generally a good idea that if you
15             plan on using <classname>Zend_Session</classname> or
16             <classname>Zend_Session_Namespace</classname>, that you initialize with
17             <methodname>Zend_Session::start()</methodname> in your bootstrap file. (See the
18             <link linkend="zend.session.advanced_usage.starting_a_session">Zend_Session</link>
19             documentation for more details on its usage.)
20         </para>
21     </sect4>
23     <sect4 id="zend.controller.actionhelper.flashmessenger.basicusage">
24         <title>Basic Usage Example</title>
26         <para>
27             The usage example below shows the use of the flash messenger at its
28             most basic. When the action <filename>/some/my</filename> is called, it adds
29             the flash message "Record Saved!" A subsequent request to the action
30             <filename>/some/my-next-request</filename> will retrieve it (and thus delete
31             it as well).
32         </para>
34         <programlisting language="php"><![CDATA[
35 class SomeController extends Zend_Controller_Action
37     /**
38      * FlashMessenger
39      *
40      * @var Zend_Controller_Action_Helper_FlashMessenger
41      */
42     protected $_flashMessenger = null;
44     public function init()
45     {
46         $this->_flashMessenger =
47             $this->_helper->getHelper('FlashMessenger');
48         $this->initView();
49     }
51     public function myAction()
52     {
53         /**
54          * default method of getting
55          * Zend_Controller_Action_Helper_FlashMessenger instance
56          * on-demand
57          */
58         $this->_flashMessenger->addMessage('Record Saved!');
59     }
61     public function myNextRequestAction()
62     {
63         $this->view->messages = $this->_flashMessenger->getMessages();
64         $this->render();
65     }
67 ]]></programlisting>
68     </sect4>
69 </sect3>