2009年8月7日星期五

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


On 7 Aug 2009, at 15:13, Vladas Diržys wrote:

Its necessary to call flashMessenger in the second request, otherwise messages will not be deleted.


That was exactly my point. The OP wanted to allow a redirect between setting the Flash Message and retrieving it. As long as he doesn't instantiate the FlashMessenger (by calling it prior to the redirect say) he should have no problem.

Regards,
Carlton


--
Regards,
Vladas Diržys



On Fri, Aug 7, 2009 at 16:53, Carlton Gibson <lists@noumenal.co.uk> wrote:

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()); 
}
}


没有评论: