2009-06-01 6 views
1

저는 젠드를 가르치고 있으며 내 세션을 사용하여 뷰 헬퍼 액션을 호출하는 데 문제가 있습니다.젠드 세션 문제 (초보자)

내 컨트롤러 :

<?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>"; 
    } 
} 
?> 

내보기 : 나는 theButton 클릭

<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 사용자 - FUNC - 배열] : 첫 번째 인수가 유효한 콜백 될 것으로 예상된다, '__PHP_Incomplete_Class :: 후 모든 시간 동안,하지만, 그것은 나에게이 오류 메시지를 제공합니다 tabbedbox '는 341 행의 C : \ xampp \ htdocs \ BC \ library \ Zend \ View \ Abstract.php에 제공되었습니다.

Zendcasts.com 비디오를 거의 라인으로 복사했고 여전히 작동하지 않습니다. 내 회의가 파괴되는 것 같아. 나는 무슨 일이 일어나고 있는지 말해 줄 수있는 누군가에게 영원히 감사 할 것이다.

답변

2

세션에 개체를 저장하면 실제로 이라는 일련의 표현이 저장됩니다. __PHP_Incomplete_Class :: tabbedbox는 후속 요청에서 PHP가 App_View_Helper_Tabbedbox가 무엇인지 잊어 버렸기 때문에 발생합니다.

해결책 : Zend_Session :: start()가 호출되기 전에 App_View_Helper_Tabbedbox 클래스 파일을 포함시켜야합니다.

그리고는, 그렇게 할 수있는 가장 좋은 방법은 응용 프로그램의 오프닝에이를 배치하는 것입니다 : 그것은

require_once 'Zend/Loader.php'; 
Zend_Loader::registerAutoload(); 
+0

의 그! 고맙습니다. – Ethan