Discussion error message help

Permalink 1 user found helpful
I am using the discussion forums add-on.
When I do app_post(), I show an error message if the subject is empty, as the following:
$this->error->add(t('Your subject cannot be empty.'));

Now, the following code should display the error message and I expect the posting process to stop and the screen to remain on the post form screen.
However, what I get is a page refresh, the post form screen gone and I see the post list.

if ($this->error->has()) {
$ci = Loader::helper('concrete/urls');
$resp['newCaptcha'] = $ci->getToolsURL('captcha') . '?nocache=' .time();
$e = $this->error->getList();
$resp['errors'] = $e;
$js = Loader::helper('json');
$this->set('json', $js->encode($resp));
}


public function on_before_render() {
$this->set('error', $this->error);
$html = Loader::helper('html');
$this->addHeaderItem($html->css('discussion.css', 'discussion'));

$json = $this->get('json');
if (isset($json)) {
print '<script type="text/javascript">parent.ccmDiscussion.response(\'' . $json . '\');</script>';
exit;
}
}

Can anyone please tell me how to get the posting process to stop and make the post form remain on the screen?
Thank for your help!