开发者

Does the Grails undocumented method ifPageProperty actually work?

开发者 https://www.devze.com 2023-02-09 02:22 出处:网络
I am setting a pageProperty in my view with a content tag, however, Grails 1.3.6 ifPageProperty is not detecting my sidebar pageProperty. Any thoughts?

I am setting a pageProperty in my view with a content tag, however, Grails 1.3.6 ifPageProperty is not detecting my sidebar pageProperty. Any thoughts?

layout.gsp

开发者_C百科
<g:ifPageProperty name="page.sidebar">
  <aside id="sidebar">
    <g:pageProperty name="page.sidebar" />
  </aside>
</g:ifPageProperty>

view.gsp

<html>
<head>
<title>My Account Title</title>
</head>
<body>
  <content tag="sidebar">
    <h4>Sidebar</h4>
    <p>Hola. This is a sidebar test!</p>
  </content>
  <h1>Content Heading</h1>
</body>
</html>

PS. If you're wondering where I am setting my layout, it's being set in the controller.


A coworker scoured the Grails buglist and found out that Sitemesh's preprocess must be turned off.

// enable Sitemesh preprocessing of GSP pages
grails.views.gsp.sitemesh.preprocess = false


Could you try this as a workaround for the problem:

<g:if test="${g.pageProperty(name:'page.sidebar')?.length()}">
  <aside id="sidebar">
    <g:pageProperty name="page.sidebar" />
  </aside>
</g:if>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号