Grails 应用程序中的 Dojo Fisheye

Posted

技术标签:

【中文标题】Grails 应用程序中的 Dojo Fisheye【英文标题】:Dojo Fisheye in Grails app 【发布时间】:2009-09-28 00:25:30 【问题描述】:

我正在使用 Grails 构建一个 Web 应用程序。我决定使用 dojo,并在 main.gsp 中添加了一个 dojo 鱼眼菜单,这样它就可以在所有应用程序的页面上使用。 它适用于(主页)index.gsp 页面,但是一旦我选择另一个页面,鱼眼菜单就会消失。如果我回到家,它就在那里。我修改了设置,对我来说一切正常。我没有使用任何花哨的东西,只是简单的东西。我错过了一些东西,但无法弄清楚。

为了清楚起见,我简化了 main.gsp 中的代码:

<html>
<head>

    ...

    <g:layoutHead />

    <!-- use dojo library ... this has not effect at all -->
    <g:javascript library="dojotk"/>    

    <!-- Load Dojo -->
    <script type="text/javascript" src="js/dojotk/dojo/dojo.js"
    djConfig="parseOnLoad:true, isDebug:false"></script>

    <!-- need fisheye -->
    <g:javascript type="text/javascript">
        dojo.require("dojox.widget.FisheyeList");
    </g:javascript>

    <!-- required css for dojo fisheye -->
    <style type="text/css">@import "js/dojotk/dojox/widget/FisheyeList/FisheyeList.css";</style>    

</head>
<body >
       ...
     <!-- fisheye bar -->
     <div id="fisheyebar"><g:render template="/common/fisheyebar"/></div>

    <g:layoutBody /> 
</body>

这里是 _fisheyebar.gsp

<g:javascript>
  function load_app(target)
   window.location.href=target
 
</g:javascript>
    <center >
        <div class="outerbar">
            <div dojoType="dojox.widget.FisheyeList"
                    itemWidth="50" itemHeight="50"
                    itemMaxWidth="200" itemMaxHeight="200"
                    orientation="horizontal"
                    effectUnits="2"
                    itemPadding="10"
                    attachEdge="top"
                    labelEdge="bottom"

                    >
    <div dojoType="dojox.widget.FisheyeListItem" 
            onClick= "load_app('$createLinkTo(dir:'/something')');"
             iconsrc="images/icon_something.png" caption="Web Browser">
    </div>
       .....
    </div>
</div> <!-- outbar -->
</center>

包括 index.gsp 在内的所有页面都有以下内容:

   <head>
<title>some titel</title>
<meta name="layout" content="main" />
</head>

请注意不是使用模板(_fisheyebar)的原因,我把代码直接放在main中,效果是一样的。那我错过了什么?

【问题讨论】:

【参考方案1】:

它位于dojo 位置的相对URL 中。它是相对于根目录的,所以这就是索引起作用而不是其他页面的原因。

使用绝对 URL 可以解决问题。

【讨论】:

【参考方案2】:

您是否尝试将您的 dojo 声明和导入移动到您的布局模板页面,而不是将其放在您的 main.gsp 中?

【讨论】:

不,我没有。我没有那个需要。我只是放置绝对 URL 而不是相对 URL。我使用 Firebug 观察发生了什么,然后我看到了错误的 URL 调用。

以上是关于Grails 应用程序中的 Dojo Fisheye的主要内容,如果未能解决你的问题,请参考以下文章