我正在自学 Zend am,并且在使用我的会话调用 View Helper 操作时遇到问题。
我的控制器:
<?php
class SessionController extends Zend_Controller_Action
{
protected $session;
public function init() //Like a constructor
{
$this->_helper->viewRenderer->setNoRender(); // Will not automatically go to views/Session
$this->_helper->getHelper('layout')->disableLayout(); // Will not load the layout
}
public function preDispatch() //Invokes code before rendering. Good for sessions/cookies etc.
{
$this->session = new Zend_Session_Namespace(); //Create session
if(!$this->session->__isset('view'))
{
$this->session->view = $this->view; //if the session doesn't exist, make it's view default
}
}
public function printthingAction()
{
echo $this->session->view->tabbedbox($this->getRequest()->getParam('textme'));
}
}
?>
我的视图助手
<?php
class App_View_Helper_Tabbedbox extends Zend_View_Helper_Abstract
{
public $wordsauce = "";
public function tabbedbox($message = "")
{
$this->wordsauce .= $message;
return '<p>' . $this->wordsauce . "</p>";
}
}
?>
我的观点:
<p>I GOT TO THE INDEX VIEW</p>
<input id='textme' type='input'/>
<input id='theButton' type='submit'/>
<div id="putstuffin"></div>
<script type="text/javascript">
$(function()
{
$("#theButton").click(function()
{
$.post(
"session/printthing",
{'textme' : $("#textme").val()},
function(response)
{
$("#putstuffin").append(response);
});
});
});
</script>
我第一次单击按钮时,它会起作用,并按照应有的方式附加我的单词。但是,每次之后,它都会给我这个错误消息:
警告:call_user_func_array() [function.call-user-func-array]:第一个参数应该是一个有效的回调,'__PHP_Incomplete_Class::tabbedbox' 在 C:\xampp\htdocs\BC\library\Zend\View 中给出\Abstract.php 在第 341 行
我几乎一行一行地复制了 Zendcasts.com 的视频,但它仍然无法正常工作。好像我的会话被破坏了。我将永远感激任何能告诉我发生了什么的人。