Yii::app()->clientScript Exception :(

I've downloaded Portlet and Login portlets and put them to the extension dir.

Then in the main layout I wrote:

<?php $this->widget('application.extensions.login.XLoginPortlet',array(


     'visible'=>Yii::app()->user->isGuest,


)); ?>

It showed me CException page:

00122:     /**


00123:      * Getter magic method.


00124:      * This method is overridden to support accessing application components


00125:      * like reading application properties.


00126:      * @param string application component or property name


00127:      * @return mixed the named property value


00128:      */


00129:     public function __get($name)


00130:     {


00131:         if($this->hasComponent($name))


00132:             return $this->getComponent($name);


00133:         else


00134: return parent::__get($name);


00135:     }


00136: 


00137:     /**


00138:      * Runs the application.


00139:      * This method loads static application components. Derived classes usually overrides this


00140:      * method to do more application-specific tasks.


00141:      * Remember to call the parent implementation so that static application components are loaded.


00142:      */


00143:     public function run()


00144:     {


00145:         $this->onbeginRequest(new CEvent($this));


00146:         $this->processRequest();


Stack:

#0 /usr/home/konstantin/TVSMedia/EveryStyle/framework/base/CApplication.php(134): CComponent->__get('clientScript')


#1 /usr/home/konstantin/TVSMedia/EveryStyle/testdrive/protected/extensions/portlet/XPortlet.php(62): CApplication->__get('clientScript')


#2 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CBaseController.php(141): XPortlet->init()


#3 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CBaseController.php(152): CBaseController->createWidget('application.ext...', Array)


#4 /usr/home/konstantin/TVSMedia/EveryStyle/testdrive/protected/views/layouts/main.php(26): CBaseController->widget('application.ext...', Array)


#5 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CBaseController.php(119): require('/usr/home/konst...')


#6 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CBaseController.php(88): CBaseController->renderInternal('/usr/home/konst...', Array, true)


#7 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CController.php(420): CBaseController->renderFile('/usr/home/konst...', Array, true)


#8 /usr/home/konstantin/TVSMedia/EveryStyle/testdrive/protected/controllers/SiteController.php(27): CController->render('index')


#9 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/actions/CInlineAction.php(32): SiteController->actionIndex()


#10 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CController.php(207): CInlineAction->run()


#11 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CController.php(192): CController->runAction(Object(CInlineAction))


#12 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CController.php(167): CController->runActionWithFilters(Object(CInlineAction), Array)


#13 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CWebApplication.php(146): CController->run('index')


#14 /usr/home/konstantin/TVSMedia/EveryStyle/framework/web/CWebApplication.php(118): CWebApplication->runController('site', 'index')


#15 /usr/home/konstantin/TVSMedia/EveryStyle/framework/base/CApplication.php(146): CWebApplication->processRequest()


#16 /usr/home/konstantin/TVSMedia/EveryStyle/testdrive/index.php(11): CApplication->run()


#17 {main}

I searched the forum and found thread where there were problems with clientScript also. There Qiang recommended upgrading to the latest SVN. I configured SVN on my server and checked out latest revision, here is version of the CApplication:

@version $Id: CApplication.php 314 2008-12-01 18:32:23Z qiang.xue $

What's the problem with it? Maybe I'm missing some configs? I re-read article about extending Yii, about creation widget, but didn't see anything about extra config there.

What I'm doing wrong?

Please double-check CWebApplication.php in your Yii copy and make sure it contains a method called getClientScript.

I have the same problem.  I noticed exactly the same behaviour in r297 so I have used an older version (2008-11-22) until now. The problem is still there in r318. getClientScript() is present in CWebApplication.

/Tommy

Solution is:

  1. upgrade to latest svn

  2. in XPortlet.php on line 62 place:

$cs=Yii::app()->getController()->getClientScript();

instead of

$cs=Yii::app()->clientScript();

Maybe

$cs=Yii::app()->getController()->clientScript();
should work also, I didn't test it.

Qiang, please update the XPortlet and write a note, that it needs upgrading to the latest svn.

tri: do you mean you still have problem in using (the latest) XPortlet with r318?

Sorry, when I removed old framework and checked our from SVN, the code

$cs=Yii::app()->clientScript();

works perfect. Everything is fine with the code, /dev/hands have errors ;)

Works fine with the updated XPortlet (2008-11-25).

Thanks,

/Tommy