2009年8月7日星期五

Re: [fw-mvc] Lost flash messages after redirect


On 7 Aug 2009, at 14:26, Abraham Block wrote:
Carlton Gibson <lists@noumenal.co.uk> wrote:
> If you perform the redirect before you retrieve your message from the FlashMessenger then this won't be a problem.

This is not true - at least not by the code in
Zend_Controller_Action_Helper_FlashMessenger.

Err, that's funny because if I set up the following controller, go to the index action and follow the links, thirdAction outputs: 

    array 0 => string 'My Test Message' (length=15)

<?php
class FlashController extends Zend_Controller_Action
{
public function preDispatch()
{
$this->_helper->ViewRenderer->setNoRender();
}
public function indexAction()
{
$this->_helper->FlashMessenger('My Test Message');
echo '<h1>First Request</h1>';
echo '<a href="./flash/second">Go to second action</a>';
}
public function secondAction()
{
echo '<a href="./third">Go to third action</a>';
}
public function thirdAction()
{
Zend_Debug::dump($this->_helper->FlashMessenger->getMessages()); 
}
}

没有评论: