Groovy加载到div中 [英] Groovy loading into divs

查看:124
本文介绍了Groovy加载到div中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以试着在groovy中创建一个相对简单的设置,并缺少一些位。

So trying to create a relatively (I thought) simple setup in groovy, and missing a couple of bits.

基本上我想创建一个网页,窗格,标题,左侧栏和主窗口。
标题保持原样,左侧疼痛具有生成报告的控制器,右侧显示输出。到目前为止这么好,但有两个或潜在的三个命令或功能,我似乎不能掌握,搜索,但我使用的搜索therms没有什么有用的。

Basically I am trying to create a webpage with three panes, a title, left side bar and a main window. The title stays as it is, the left pain has a controller for generating reports, the right side shows the output. So far so good, but there are two or potentially three commands or features I do not seem to be able to master, searched but the search therms I used comes up with little useful.

所以,首先是主要的.gsp,我怀疑加载的结构。创建了一个名为calllog的控制器和视图。控制器为空,而index.gsp包含以下内容。

So, first the main .gsp, the one that I would suspect loads the structure. Created a controller and view called calllog. The controller is empty, while the index.gsp contains the following.

  <meta name='layout' content='call-log'/>
<html>
<head>
<title>Call log</title>
</head>
<body>
    <div id="CallLogo"><H1>Call Logger</H1></div>
    <div id="controller">
    <object type="text/html" data="dbstats/index">

    <g:link controller="dbstats" action="index">This is something</g:link>
    </div>
    <div id="output">Your output here</div>
</body>
</html>

这是我的第一个问题,它似乎不是创建div部分我期待,它只是输出它。
其次,似乎没有加载,我找不到一个运算符。

Here is my first issue, it does not seem like it is creating the div sections I am expecting, it just outputs it. Secondly, the does not seem to load, and I have not been able to find a operator.

布局如下

    <!doctype html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title><g:layoutTitle default="call-log"/></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <asset:stylesheet src="calllog.css"/>
        <asset:javascript src="call-log.js"/>
        <g:layoutHead/>
    </head>
    <body>
        <div class="CallLogo" id="CallLogo" role="banner"><a href="http://www.google.co.uk"><asset:image src="call.png" alt="call.png"/></a></div>
        <g:layoutBody/>
        <div id="controller" class="controller" role="contentinfo"></div>
        <div id="output" class="output" style="display:none;"><g:message code="spinner.alt" default="Loading&hellip;"/></div>
    </body>
</html> 

我遇到的下一个问题,可能有相同的答案,回调)到动作。因此,dbstats控制器将提供一个菜单,一旦你按提交,它将调用一个存储一些数据的提交类,我想要做的是让该窗格返回索引,同时还启动一个进程以生成到主体窗格的输出。

The next problem I have, which may have the same answer is, how do I call (or do a call back) to a action. So, the dbstats controller will provide a menu, once you press submit, it will call a submit class which stores some data, what I want to be able to do is to get that pane to go back to index, while also start a process to generate output to the "body" pane.

=============更新:向前一步两步... ============ ========
因此,越来越接近,管理解决布局和div的问题,没有帮助我编辑错误的CSS文件。

=============UPDATE: One step forward Two steps ... ==================== So getting closer, managed to solve the issues with the layout and divs, did not help that I was editing the wrong CSS file as well.

网页现在看起来像这样

-------------------------------
|             Logo            |
-------------------------------
| Con |          Output       |
| tro |                       |
| lle |                       |
| r   |                       |
|     |                       |
-------------------------------   

我设法更新,以使Controller功能正确加载,并有一个列表和一个提交按钮和所有。

I managed to update so that the Controller function loads correctly, and there is a list and a submit button and all.

但是,我不能想出的是。一旦按下提交按钮,我已经读取信息我不知道(现在工作),我如何获取控制器重新加载作为controller =dbstatsaction =索引到div控制器和调用函数用另一个控制器更新输出,例如controller = generateGraph action = graph。尝试与重定向告诉我:

However, what I can't figure out is. Once the Submit button is pressed, and I have read the info I wan't (that works now), how do I either get the Controller reloaded as controller="dbstats" action="index" into the div Controller and call a function to update Output with another controller, say controller=generateGraph action=graph. Tried with redirect which told me:

submitform的代码看起来像这样

The code of submitform looks like this currently

def submitForm() {
def postIds = params.list('userform').get(0)
for ( e in session.users) {
    session[e] = "False"
}
postIds.each() { postId ->
    if ( postId.value == "1" ) {
        session[postId.key] = "True"
        //render {
            //div(id: "Output", "Will do ${postId.key}<BR>")
        //}>"
    }
    redirect(action: "CallLog")
  }

}
所有给我的是
无法发出重定向(..)已经重定向响应.. Stacktrace如下:
消息:不能在这里发出重定向(..)以前的重定向(..)调用已经重定向

} All that giver me is Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.. Stacktrace follows: Message: Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.

推荐答案

很高兴重绘整个网页ID。 >

<!doctype html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title><g:layoutTitle default="call-log"/></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <asset:stylesheet src="calllog.css"/>
        <asset:javascript src="call-log.js"/>
        <g:layoutHead/>
    </head>

    <body>
<div id="siteWrapper">
        <div class="CallLogo" id="CallLogo" role="banner"><a href="http://www.google.co.uk"><asset:image src="call.png" alt="call.png"/></a></div>
        <g:layoutBody/>
        <div id="controller" class="controller" role="contentinfo"></div>
        <div id="output" class="output" style="display:none;"><g:message code="spinner.alt" default="Loading&hellip;"/></div>
</div>
    </body>

</html> 

-

  <meta name='layout' content='call-log'/>
<html>
<head>
<title>Call log</title>
</head>
<body>
    <div id="CallLogo"><H1>Call Logger</H1></div>
    <div id="controller">
    <object type="text/html" data="dbstats/index">

    <g:link controller="dbstats" action="index">This is something</g:link>
    </div>
    <div id="output">Your output here</div>

    <a  onclick="<g:remoteFunction controller="Something"  action="SomeAction" id="${yourId }" update="siteWreapper"/>"><b>click to update entire site content within body tags</b><br/>


</body>
</html>

另一种方法是使用javascript get

Another way is to use javascript get

 $.get("/"+baseapp+"/applications/getOwner?id="+id+"&two="+two,function(data){
                            $('#appOwner').hide().html(data).fadeIn('slow');
                    });

其中appowner是div ID,结果将更新get可以是getJSON

where appowner is the div ID the result will update the get can be getJSON

remoteFunction with params:

remoteFunction with params:

<button  id=boxbtn onclick="<g:remoteFunction controller="yourcontroller"  action="br" update="siteContent"  id="${some?.id}"  params="${[s:'e',viewtype:'na']}"/>">some action</button>

这篇关于Groovy加载到div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆