grails - 在同一个 gsp 页面上使用 3 个布局

这是我的问题的编辑,首先是如何在同一个 gsp 页面中应用 2 个布局,但现在我遇到了 3 个布局的问题 :):

我对所有 css 和布局的东西都很陌生,我正在使用 grails 2.0 版本
我的问题中有以下模块:
1. main.gsp 布局,基本上所有页面都有一个带有公司 Logo 的漂亮标题。
2. mainTabPanle.gsp 布局,基本上包含一些所有页面都应该有的主标签
3. reportTab.gsp 布局,基本上包含漂亮的报告选项卡和简短的 javascript 代码来操作所有报告 gsp 页面应具有的所选选项卡颜色。

我要做的是在所有报告 gsp 页面中使用此 reportTab 布局。

所以这就是我到目前为止得到的:

主.gsp:

<!doctype html>  
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}"type="text/css">
<g:layoutHead/>
<r:layoutResources />
</head>
<body style="height:100%">
<div>some nice header in here </div>
<g:layoutBody/>
<r:layoutResources />
</body>
</html>

mainTabPanle.gsp(也位于布局文件夹中)
<g:applyLayout name="main">    
<!doctype html> 
<html> 
<head>
<g:layoutHead/>
<r:layoutResources />
</head>
<body>
<div>some main tabs here </div> 
<g:layoutBody/>
</body>
<script type="text/javascript">
//script to manipulate main tabs    
</script>
<r:layoutResources />
</body>
</html>
</g:applyLayout>

报告TabPanel.gsp:
<g:applyLayout name="mainTabPanel">    
<!doctype html> 
<html> 
<head>
<g:layoutHead/>
<r:layoutResources />
</head>
<body>
<div>some reports tab panel </div>  
<g:layoutBody/>
</body>
<script type="text/javascript">
//some script to manipulate report tab item
</script>
<r:layoutResources />
</body>
</html>
</g:applyLayout>

现在我在 moneyreport.gsp 标题中使用以下行:
<meta name="layout" content="reportTabPanel" />

我想看到的是漂亮的标题和 maintabsPanel 和 reportTabPanel,但我看到的只是 moneyreport.gsp 的正文

奇怪的是,如果我使用这个:
<meta name="layout" content="mainTabPanel" />

在moneyreport.gsp 中,我看到了mainTab 和moneyreport.gsp 的主体。

我究竟做错了什么?我不能在同一页面上使用 3 个布局?

谢谢你们的帮助...

最佳答案

您可以在同一页面上应用 2 个布局。为了在布局文件中应用不同的布局,您需要使用 applyLayout 标签。你的 reportTab 应该是这样的:

<g:applyLayout name="main">    
<!doctype html>  
<head>
<g:layoutHead/>
<r:layoutResources />
</head>
<body>
<div> some nice tabs here </div>
<g:layoutBody/>
</body>
<script type="text/javascript">
few line script handling chosen tab color in here
</script>
<r:layoutResources />
</body>
</html>
</g:applyLayout>

https://stackoverflow.com/questions/9629155/

相关文章:

sql - 将普通 SQL 表添加到 Grails 应用程序而不是使用 ORM?

grails - grails g:formatNumber

grails - 为用户登录插入审核日志记录条目

grails - 标准的单元测试模拟

grails - 对grails的 Ant 调用因 “[exec] Application is p

jquery - “Uncaught ReferenceError: JQueryValidator

grails - User.get()在Grails 2.0中损坏,返回null

grails - Grails url映射从sperate配置文件传递数据

grails - 从 map 的特定值的下拉列表中设置值

grails - 在运行应用程序完成后,grails应用程序会自动连续自动重新加载