susan woodbury created TILES-580:
------------------------------------
Summary: getAsString does not support expressions
Key: TILES-580
URL: https://issues.apache.org/jira/browse/TILES-580
Project: Tiles
Issue Type: Improvement
Components: tiles-extras
Affects Versions: 3.0.4
Environment: spring 3.2, tomcat 7, windows xp.
Reporter: susan woodbury
Looking through the code, I believe getAsString does not currently
support expressions. That's weird, I believe it should not be difficult
to implement. Nicolas Le Bas
getAsString works with value=
getAsString always returns null with expression=
while insertAttribute works correctly with both value= and expression=
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..
=========================================================
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)
=========================================================
with 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>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)