Dear List,

Is it possible to clear the rendered content after calling an
Action-view-helper?
I have a view-script that executes a action-view-helper.
This action-view-helper calls another action in a different controller.
Under common HTTP-requests, everything is fine. But for AJAX-requests,
I need to clear previously rendered content. How can I achieve this?

MORE INFO:
I have a module named "Contact". It has two controllers:
IndexController, and ContactFormControlller.

The Contact_IndexController::indexAction() simply renders the view-script
"index.phtml", which contains:
<h2>Contact Us</h2>
Our Address: blah blah, ... .
<?= $this->action('index', 'contact-form', 'contact') ?>
Powered by Zend Framework.

Thanks to action-view-helpers I can put the "Contact Form" in every view
script and every module!
The above Action-View-Helper calls
Contact_ContactFormController::indexAction(),
and prints the rendered form. The final result is a "Contact Us" page,
containing a
Contact form. The "Contact Form" validates its elements using processAjax()
as the user types.

Now, suppose that under an AJAX-request, the action-view-helper calls the
Contact_ContactFormController::indexAction(). This method, of course,
detects AJAX-request, disables the layout, and turns off the view-renderer
globally.
However, the previous rendered content (i.e. <h2>Contact Us</h2>...) is
present in the JSON output.
This is not surprising, but is it possible to clear the previously rendered
content since the script is still running?
When I thrown an exception in the called action, the previously content were
removed and my custom error message displayed instead. How can I have the
same functionality under AJAX
requests?

If I want to keep ContactFormController self-contained and
semi-standalone(!),
it needs to detect AJAX-requests by itself after an Action-View-Helper calls
it, and
then clear any previously rendered content. Is this possible?
I tried to clear the response in
Contact_ContactFormController::indexAction() using
$this->getResponse()->clearBody(); but it did nothing.

I appreciate your help.
Thank you very much in advance.
-abe

Reply via email to