Hi Susan,
Looking through the code, I believe getAsString does not currently
support expressions. That's weird, I believe it should not be difficult
to implement.
Can you file an improvement request on jira?
(https://issues.apache.org/jira/browse/TILES) I'll see if I can put a
patch together this week and coordinate a new release.
Thanks,
Nick.
On 14-09-07 01:28 PM, Susan Woodbury wrote:
Hi.
I'm having an issue with configuring tiles 3.0.4 with spring 3.2.10
the following layout.jsp file succeeds to get the title which is set via
value=, while the css and footer which is set via the el functionality fails
with a nullpointerexception..
but the footer only fails in getAsString, but not in insertAttribute, so i
believe it should work in getAsString as well.
Am I missing something?
==================================================================================================
the error is:
DEBUG org.apache.tiles.template.GetAsStringModel - Ignoring exception
java.lang.NullPointerException
at
org.apache.tiles.template.GetAsStringModel.renderAttribute(GetAsStringModel.java:177)
at
org.apache.tiles.template.GetAsStringModel.execute(GetAsStringModel.java:122)
at
org.apache.tiles.jsp.taglib.GetAsStringTag.doTag(GetAsStringTag.java:261)
at
org.apache.jsp.client.default_.layout.layout_jsp._jspx_meth_tiles_005fgetAsString_005f1(layout_jsp.java:258)
at
org.apache.jsp.client.default_.layout.layout_jsp._jspService(layout_jsp.java:132)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
==============================================================================
I have a tiles_en.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration
3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="nouser.default.definition"
templateExpression="/client/default/layout/layout.jsp">
<put-attribute name="client" value="${client}"/>
<put-attribute name="title" value="| Default" />
<put-attribute name="meta" expression="/client/default/layout/meta.jsp"/>
<put-attribute name="css"
expression="/client/${client}/layout/css/enerwise_v2.css"/>
<put-attribute name="css_print"
expression="/client/${client}/layout/css/em_print.css"/>
<put-attribute name="header"
expression="/client/default/layout/header.jsp"/>
<put-attribute name="head" expression="/client/default/layout/head.jsp"/>
<put-attribute name="menu" expression="/client/default/layout/menu.jsp"/>
<put-attribute name="body" expression="/client/default/layout/body.jsp"/>
<put-attribute name="footer"
expression="/client/${client}/layout/footer.jsp"/>
</definition>
<definition name="hello.page" extends="nouser.default.definition">
<put-attribute name="title" value="| Welcome" />
<put-attribute name="body" value="/jsp/helloWorld.jsp" />
</definition>
</tiles-definitions>
=================================================================================================
layout.jsp:
<%@taglib uri="http://www.springframework.org/tags" prefix="bean"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><bean:message code="label.project" /><tiles:getAsString name="title"
/></title> <!--SUCCEEDS using value=-->
<link rel=stylesheet href="<tiles:getAsString name='css' ignore='true' />"
type="text/css" /><!-- FAILS using expression = -->
<link rel=stylesheet href="<tiles:getAsString name='css_print' ignore='true' />"
type="text/css" media="print" /><!-- FAILS using expression =-->
<script src="<%=request.getContextPath()%>/js/CalendarPopup.js"
type="text/javascript"></script>
<script
type="text/javascript">document.write(getCalendarStyles());</script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/js/jquery-1.6.4.min.js"></script>
<script language="javascript1.2"
src="<%=request.getContextPath()%>/js/jquery.countdown.min.js"></script>
</head>
<body>
<a name="top"></a>
<!-- begin wrapper -->
<div id="wrapper">
<!-- begin header -->
<tiles:insertAttribute name="header" />
<!-- end header -->
<!-- begin navigation -->
<tiles:insertAttribute name='menu' />
<!-- end navigation -->
<!-- begin content -->
<div id="content">
<tiles:insertAttribute name='body' />
<br />
<!-- begin footer -->
<tiles:getAsString name="footer" ignore='true' /> <!-- FAILS using expression
=-->
<tiles:insertAttribute name="footer" ignore='true'/><!-- SUCCEEDS using expression
=-->
<!-- end footer -->
</div>
<!-- end content -->
</div>
<!-- end wrapper -->
</body>
</html>
====================================================================================
Susan M. Woodbury
_______________________________________