Hi,

I ran into the same problem very recently. I fixed it by using the
output_method directly:

   $m->out_method->($m->content); $m->abort();

Instead of $m->flush_buffer(); $m->abort(); when I'm within a
component and I know that I want to output my content. This should
apply only to rare cases, as it annihilates the possibility of using
your component in an scomp. But in my case, I _know_ that I want to
flush the buffer to the output, not to some internal string buffer, so
it's fine.

Cheers!

Jerome.


On 24 August 2010 11:37, Louis-David Mitterrand
<vindex+lists-mason-us...@apartia.org> wrote:
> On Mon, Apr 05, 2010 at 07:31:08PM +0200, Louis-David Mitterrand wrote:
>> Hi,
>>
>> I noticed this in "man HTML::Mason::Request":
>>
>> flush_buffer
>>          [...]
>>          Attempts to flush the buffers are ignored within the context of a
>>          call to "$m->scomp" or when output is being stored in a scalar
>>          reference, as with the " { store => \$out } " component call
>>          modifier.
>>
>> I have been searching a long time why my javascript redirect was never
>> sent and finally understood why after reading this manual section.
>>
>>       if ($r->headers_in->{'X-Requested-With'} eq 'XMLHttpRequest') { ## ajax
>>                       $r->warn("javascript redirect");
>>                       $r->content_type("application/javascript");
>>                       $m->print('window.location="/login.md";');
>>                       $m->abort(200);
>>       }
>>
>> This code is called within a component itself called with $m->scomp().
>>
>> How can I make that work while still calling the compent with
>> $m->scomp()?
>
> I found a solution: use $r->puts() instead of $r->print which is
> remapped by mason.
>
>        $m->clear_buffer();
>        $r->content_type("application/javascript");
>        $r->puts('window.location="'.$url.'";');
>        $r->rflush;
>        $m->abort(200);
>
> --
> http://www.cruisefish.net
>
> ------------------------------------------------------------------------------
> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> Be part of this innovative community and reach millions of netbook users
> worldwide. Take advantage of special opportunities to increase revenue and
> speed time-to-market. Join now, and jumpstart your future.
> http://p.sf.net/sfu/intel-atom-d2d
> _______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mason-users
>



-- 
Jerome Eteve.

http://libsquare.net

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to