ReferenceError: YAHOO is not defined

984 views
Skip to first unread message

Patricia Motta

unread,
Oct 28, 2014, 1:50:02 PM10/28/14
to hippo-c...@googlegroups.com
Hello Hippos, I need your expertise

I created a perspective that renders a extjs grid. It is quite similar to the broken links perspective, but instead of displaying a button that must be clicked in order to load the panel, this custom perspective renders the grid directly. It works just fine, except if I make this perspective the first one - the cms home page.

In this case, I get some of java scrip errors - "ReferenceError: YAHOO is not defined" - one for each of my extjs files and a "TypeError: Hippo.Dashboard.DashboardExtPanelPlugin is not a constructor"

Of course on the top of each file I have:

Ext.ns('Hippo.Dashboard');

YAHOO.namespace('hippo');

Does anyone understand why I get this error if I make the perspective the first one? I've tried everything I could think of to work around this issue but nothing seems to make a difference...

Any help will be much appreciated,

Thanks!

Patricia

Mathijs den Burger

unread,
Oct 29, 2014, 6:24:42 AM10/29/14
to hippo-c...@googlegroups.com
Hi Patricia,

First of all: which Hippo version are you using?

You've entered the wonderful world of dependency load ordering. All
JavaScript is eventually put into the HTML head by Wicket. How that's
done, and more importantly, the order in which things are rendered,
depends on the Wicket version. How this works exactly in 7.8 and 7.9
is explained in detail in the upgrade documentation [1].

Your problem is most likely that the dashboard is rendered immediately
after login, and at that point not all JavaScript dependencies have
been loaded yet by Wicket. The ExtJS and/or YUI library does not seem
to be imported. If you are using 7.9, try to add the following
behavior in the constructor of the Wicket perspective for ensure ExtJS
is there:

add(new ExtHippoThemeBehavior()); [2]

I believe the YAHOO object comes from the YUI library, which is added
to the Wicket head whenever a AbstractYuiAjaxBehavior is added. The
CMS has plenty of those behavior in various components, but none of
these components is rendered in the dashboard. Hence you'll have to
add your own implementation of AbstractYuiAjaxBehavior in your
component to ensure that the yahoo lib is included at that point so
your component can use the YAHOO object.

hope this helps,
Mathijs

[1] http://www.onehippo.org/library/upgrade-7.8-to-7.9/upgrading-to-wicket-6.html

[2] http://svn.onehippo.org/repos/hippo/hippo-cms7/cms/branches/hippo-cms-2.26.xx/api/src/main/java/org/hippoecm/frontend/extjs/ExtHippoThemeBehavior.java

[3] http://svn.onehippo.org/repos/hippo/hippo-cms7/cms/branches/hippo-cms-2.26.xx/api/src/main/java/org/hippoecm/frontend/plugins/yui/AbstractYuiBehavior.java
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hippo-communi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.

Patricia Motta

unread,
Oct 29, 2014, 2:17:53 PM10/29/14
to hippo-c...@googlegroups.com
Hey, Mathijs, thanks a lot for the reply!

I suspected it had to be something like that...

I am on 7.9, indeed. 

Reference [1] cant be found. Maybe the url changed?!?

Regarding AbstractYuiAjaxBehavior, WireframeBehavior extends AbstractYuiAjaxBehavior and I do add a WireframeBehavior to my perspective, on the constructor, as follows:

        IPluginConfig wfConfig = config.getPluginConfig("layout.wireframe");

        if (wfConfig != null) {

            WireframeSettings wfSettings = new WireframeSettings(wfConfig);

            add(new WireframeBehavior(wfSettings));

        }


I wonder if this is enough or I am missing something... Do I need to implement anything else?

Also, I do have the "add(new ExtHippoThemeBehavior());"  line in my perspective class...

Any thoughts?

Mathijs den Burger

unread,
Oct 30, 2014, 4:54:31 AM10/30/14
to hippo-c...@googlegroups.com
On Wed, Oct 29, 2014 at 7:17 PM, Patricia Motta
<schultz....@gmail.com> wrote:
> Hey, Mathijs, thanks a lot for the reply!
>
> I suspected it had to be something like that...
>
> I am on 7.9, indeed.
>
> Reference [1] cant be found. Maybe the url changed?!?

No, you have to login with your HES credentials (top-right corner) to
be able to see that page.

> Regarding AbstractYuiAjaxBehavior, WireframeBehavior extends
> AbstractYuiAjaxBehavior and I do add a WireframeBehavior to my perspective,
> on the constructor, as follows:
>
> IPluginConfig wfConfig = config.getPluginConfig("layout.wireframe");
>
> if (wfConfig != null) {
>
> WireframeSettings wfSettings = new WireframeSettings(wfConfig);
>
> add(new WireframeBehavior(wfSettings));
>
> }
>
>
> I wonder if this is enough or I am missing something... Do I need to
> implement anything else?

Do you indeed have a childnode "layout.wireframe" in your plugin's
config? Otherwise the WireframeBehavior won't be added.

> Also, I do have the "add(new ExtHippoThemeBehavior());" line in my
> perspective class...

OK, I already thought so since you didn't have any "ReferenceError:
Ext is not defined" errors :)

> Any thoughts?

The second error is hard to judge without seeing your ExtJS code. Do
you really need to define the YAHOO namespace? Isn't your code using
ExtJS only?

best,
Mathijs

Patricia Motta

unread,
Oct 30, 2014, 3:08:44 PM10/30/14
to hippo-c...@googlegroups.com
Hey Mathijs,

I was able to fix it by deferring the execution of the script until after the page is loaded, as follows:

@Override

    public void renderHead(IHeaderResponse response) {

        super.renderHead(response);

        response.render(JavaScriptHeaderItem.forReference(PLUGINPANEL_JS, true));

    }



Thanks for pointing out the documentation on upgrading wicket, that was right on!

=)

Patricia
Reply all
Reply to author
Forward
0 new messages