Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Tiles Context is there and is not there?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.
I have a really strange problem and I guess I went blind and simply can't see what is going on.
I'm using tiles (for the first time) and getting the 2 errors below.

First I've got this one:
Error - tag.getAsString : component context is not defined. Check tag syntax

then I added SCRIPTING FOR TESTING to see what is going on and this is what I get

***Title is: Categories
***header is: /jsp/Header.jsp
***Crumbs is: /jsp/Crumbs.jsp
***Category is: /jsp/Category.jsp

Now, as you can see below, these results come from the very Context "which is not defined" ???

then I removed <tiles:getAsString name="title"/> and inserted just 'MyTitle' (hardcoded title that is)
and got this error (the if part of SCRIPTING FOR TESTING):


javax.servlet.jsp.JspException

Can not find Tile context for 'org.apache.jsp.CategoryLayout_jsp'. TilesAction subclasses must be called from a Tile
at org.apache.jsp.CategoryLayout_jsp._jspService(CategoryLayout_jsp.java:117)


and this in the page (the else part of SCRIPTING FOR TESTING):

***Title is: My app title - categories
***header is: /jsp/Header.jsp
***Crumbs is: /jsp/Crumbs.jsp
***Category is: /jsp/Category.jsp

also from the "unexisting" context.

Below the jsp and the tiles-def.xml

THE CategoryLayout.jsp:
-----------------------
<%@ page language="java" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<html:base />

<title>
<tiles:getAsString name="title"/> [later replaced by just 'MyTitle']
</title>

</head>

<BODY>

<%//SCRIPTING FOR TESTING


org.apache.struts.tiles.ComponentContext context = org.apache.struts.tiles.ComponentContext.getContext(request);

if (context == null) {

throw new ServletException("Can not find Tile context for '"

+ this.getClass().getName()

+ "'. TilesAction subclasses must be called from a Tile");

} else {

out.print("<br />");
out.print("***Title is: " + (String) context.getAttribute("title"));
out.print("<br />");
out.print("***header is: " + (String) context.getAttribute("header"));
out.print("<br />");
out.print("***Crumbs is: " + (String) context.getAttribute("crumbs"));
out.print("<br />");
out.print("***Category is: " + (String) context.getAttribute("body"));
}
%>

<tiles:insert attribute="header" />

<TABLE>
<TBODY>
<TR vAlign=top>

<TD>
<tiles:insert attribute="leftmenu" />
</TD>
<TD></TD>
<TD>
<tiles:insert attribute="crumbs" />
<tiles:insert attribute="body" />
</TD>
<TD</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</html:html>


----------------------------

<tiles-definitions>
<!-- Base Tiles Definition -->
<definition name="base.definition" path="/siteLayout.jsp">
<put name="title" value="My app title"/>
<put name="header" value="/jsp/Header.jsp" />
<put name="leftmenu" value="/jsp/LeftMenu.jsp" />
</definition>
<!-- Tiles Definition of welcome page -->
<definition name="page.welcome" extends="base.definition">
<put name="body" value="/jsp/welcome.jsp" />
</definition>
<!-- Tiles Definition of Categories -->

<definition name="page.categories" extends="base.definition" path="/CategoryLayout.jsp">
<put name="title" value="My app title - categories"/>
<put name="crumbs" value="/jsp/Crumbs.jsp" />
<put name="body" value="/jsp/Category.jsp" />
</definition>

<definition name="navigation.definition" path="/jsp/Navigate.jsp" />


</tiles-definitions>


------------------------------

The page is displayed correctly and everything works just fine, except for this exception stack on the sysout.

Any ideas?

ps. if you look carefully in the SCRIPTING FOR TESTING part you'll see that there is an if-else construction, but they seem both to be executed???

Greatings,
Milan.javascript: x()
[ March 19, 2007: Message edited by: Milan Tomc ]
 
Milan Tomc
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my Action class (within method getMainCategories() ) :


I have got this



What am I missing here?

thanks
 
Whatever. Here's a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic