Does the Grails undocumented method ifPageProperty actually work?

785 views Asked by At

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

<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.

2

There are 2 answers

1
rxgx On BEST ANSWER

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
1
Lari Hotari On

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>