on 11-30-2006 1:03 PM
Hi Folks,
okay, here we go with the problem, in my j2ee struts project i got a little problem:
tiles-definitions made in my <b>tiles-defs.xml</b> are not read / mentioned in sub-pages.
here is my code (in short form):
<b>struts-config.xml</b>
-
....
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-parser-validate" value="true" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
</plug-in>
....
<b>tiles-defs.xml</b>
-
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name="base.definition" path="/jsp/layout.jsp">
<put name="title" value="testtitle" />
</definition>
<definition name="page.login" extends="base.definition">
<put name="test" value="test" />
<put name="body" value="/jsp/login.jsp" />
</definition>
</tiles-definitions>
<b>layout.jsp</b>
-
<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title><tiles:getAsString name="title" /></title>
<div class="content">
<tiles:insert attribute="body" />
</div>
</body>
</html:html>
<b>login.jsp</b>
-
<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
prefix="tiles"%>
<div class="introtext">
<h4>
<tiles:getAsString name="test" />
</h4>
</div>
<b>My problem:</b>
-
Tags in layout.jsp are used correctly, but tags in login.jsp result in the failure-message:
<i>ServletException in:/jsp/login.jsp] Error - tag.getAsString : attribute 'test' not found in context. Check tag syntax'</i>
What am i doing wrong that the tags are not interpreted in the pages which inherit from the base definition?
Hi,
I wonder if maybe the error occurs because "test" in the page.login definition is parsed as a tile because page.login extends base.definition.
Title in base.definition does not because base.definition does not extend, so that's why getAsString works there.
If this is the case, moving
<put name="test" value="test" />
to your base.definition section should solve the problem.
But it's just a thought.
Good luck, Roelof
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for your answer, no even if i define elements in the parental structure, i can't even display them on the *.jsp pages which are included via tiles themselves.
i think the problem just is that tiles-elements on those jsp pages, which are used in a layout themselves can't interpret the tiles-defitions.
it's just the question if i've got to modify the controler somehow or if it possible just not work
User | Count |
---|---|
85 | |
10 | |
9 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.