Skip to content

Commit

Permalink
Fixed Freemarker template issues
Browse files Browse the repository at this point in the history
Locked the template to pageTemplate.xhtml. Corrected the escaping
of #{ and ${ expressions in the facelets.
  • Loading branch information
VineetReynolds committed Nov 14, 2013
1 parent 20d1b53 commit 16c694d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ protected HashMap<Object, Object> getTemplateContext(String targetDir, final Res
context.put("template", template);
//TODO Fix ResourceUtil first
//context.put("templatePath", templateStrategy.getReferencePath(template != null ? template : templateStrategy.getDefaultTemplate()));
context.put("templatePath", "/resources/scaffold/paginator.xhtml");
context.put("templatePath", "/resources/scaffold/pageTemplate.xhtml");
context.put("templateStrategy", templateStrategy);
context.put("targetDir", targetDir);
return context;
Expand Down Expand Up @@ -595,7 +595,7 @@ public boolean accept(Resource<?> resource)
return ScaffoldUtil.createOrOverwrite((FileResource<?>) getTemplateStrategy()
.getDefaultTemplate(),
this.templateProcessor.processTemplate(context, navigationTemplate),
overwrite);
true);
}
finally
{
Expand Down
14 changes: 7 additions & 7 deletions scaffold/faces/src/main/resources/scaffold/faces/create.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
template="${templatePath}">

<f:metadata>
<f:viewParam name="id" value="#\{${beanName}.id}"/>
<f:event type="preRenderView" listener="#\{${beanName}.retrieve}"/>
<f:viewParam name="id" value='${r"#{"}${beanName}.id}'/>
<f:event type="preRenderView" listener='${r"#{"}${beanName}.retrieve}'/>
</f:metadata>

<ui:param name="pageTitle" value="Create ${entityName}"/>
Expand All @@ -20,7 +20,7 @@

<ui:define name="subheader">
<c:choose>
<c:when test="#\{!empty ${beanName}.id}">
<c:when test='${r"#{"}!empty ${beanName}.id}'>
Edit existing ${entityName}
</c:when>
<c:otherwise>
Expand All @@ -38,13 +38,13 @@
${metawidget}

<div class="buttons">
<h:commandLink value="Save" action="#\{${beanName}.update}" styleClass="btn btn-primary"/>
<h:commandLink value="Save" action='${r"#{"}${beanName}.update}' styleClass="btn btn-primary"/>
<c:choose>
<c:when test="#\{!empty ${beanName}.id}">
<c:when test='${r"#{"}!empty ${beanName}.id}'>
<h:link value="Cancel" outcome="view" styleClass="btn btn-primary">
<f:param name="id" value="#\{${beanName}.id}"/>
<f:param name="id" value='${r"#{"}${beanName}.id}'/>
</h:link>
<h:commandLink value="Delete" action="#\{${beanName}.delete}" styleClass="btn btn-primary"/>
<h:commandLink value="Delete" action='${r"#{"}${beanName}.delete}' styleClass="btn btn-primary"/>
</c:when>
<c:otherwise>
<h:link value="Cancel" outcome="search" styleClass="btn btn-primary"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
<title>#\{empty pageTitle ? '{#pageTitle}' : pageTitle}</title>
<link rel="icon" href="#\{resource\['favicon.ico']}" />
<title>${r"#{"}empty pageTitle ? '{#pageTitle}' : pageTitle}</title>
<link rel="icon" href='${r"#{"}resource["favicon.ico"]}' />
<h:outputStylesheet name="bootstrap.css" />
<h:outputStylesheet name="forge-style.css" />
</h:head>
Expand All @@ -27,7 +27,7 @@
<div class="container forgecontainer">
<div id="navigation">
<h:link id="homeLink" outcome="${targetDir}/index.xhtml">
<img src="#\{resource\['forge-logo.png']}" alt="Forge... get hammered" border="0" />
<img src='${r"#{"}resource["forge-logo.png"]}' alt="Forge... get hammered" border="0" />
</h:link>
${navigation}
</div>
Expand Down
10 changes: 5 additions & 5 deletions scaffold/faces/src/main/resources/scaffold/faces/search.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
template="${templatePath}">

<f:metadata>
<f:viewParam name="page" value="#\{${beanName}.page}"/>
<f:event type="preRenderView" listener="#\{${beanName}.paginate}"/>
<f:viewParam name="page" value='${r"#{"}${beanName}.page}'/>
<f:event type="preRenderView" listener='${r"#{"}${beanName}.paginate}'/>
</f:metadata>

<ui:param name="pageTitle" value="Search ${entityName} entities"/>
Expand All @@ -30,15 +30,15 @@

${searchMetawidget}
<h:panelGroup styleClass="buttons">
<h:commandLink value="Search" action="#\{${beanName}.search}" styleClass="btn btn-primary"/>
<h:commandLink value="Create New" action="#\{${beanName}.create}" styleClass="btn btn-primary"/>
<h:commandLink value="Search" action='${r"#{"}${beanName}.search}' styleClass="btn btn-primary"/>
<h:commandLink value="Create New" action='${r"#{"}${beanName}.create}' styleClass="btn btn-primary"/>
</h:panelGroup>
</h:panelGroup>
</f:validateBean>

${beanMetawidget}
<ui:include src="/resources/scaffold/paginator.xhtml">
<ui:param name="paginatorBean" value="#\{${beanName}}"/>
<ui:param name="paginatorBean" value='${r"#{"}${beanName}}'/>
</ui:include>
</h:form>

Expand Down
4 changes: 2 additions & 2 deletions scaffold/faces/src/main/resources/scaffold/faces/view.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
template="${templatePath}">

<f:metadata>
<f:viewParam name="id" value="#\{${beanName}.id}"/>
<f:event type="preRenderView" listener="#\{${beanName}.retrieve}"/>
<f:viewParam name="id" value='${r"#{"}${beanName}.id}'/>
<f:event type="preRenderView" listener='${r"#{"}${beanName}.retrieve}'/>
</f:metadata>

<ui:param name="pageTitle" value="View ${entityName}"/>
Expand Down

0 comments on commit 16c694d

Please sign in to comment.