Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts1 - tiles -cascading tiles:insert

 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can not determine how to use tiles to insert a page into a page which itself was the result of a tiles:insert

My main layout inserts a content page (<tiles:insert attribute="content-page-A" /> )

This page in turn inserts another page (<tiles:insert attribute="content-page-B" /> or <tiles:insert attribute="content-page-C" />) based upon users prior selection.

However, I get the message:
javax.servlet.jsp.JspException: Error - Tag Insert : No value found for attribute 'content-page-B'.
I am reasonably certain this is not the case due to the testing I did.


I beleive (from reading other web sites) that it is not possible to cascade tiles because the tiles attributes are not passed through to a subsequent layout page.

If this is the case, what recommendations do you have for alternative means of "cascading" tiles,

Thanks
Tim
 
E Robb
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you pushed the tiles variables to the second page?

In page A you might have something like:


Then in your header page you can have:
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of tiles is this? With tiles 2 you can cascade ...

 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas,
Thanks. I am using Struts 1.
-Tim

 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Tiles 2 with Struts 1
 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E Robb
Thanks for your suggestion and example. However, I am still having a problem.
1) tiles is giving me a "No tag found" error with the line <tiles:putAttribute.. />

2) Here is my tiles-defs.xml:




Here is a snippet from the main page:



Here is a snippet from the page identified by "body" (ResourceConfiguration.jsp):


I tried using the import statement as welll, but got the same error



The error I get is:
(I am using Netbeans on Linus)

Jan 7, 2011 4:14:54 PM org.apache.struts.tiles.taglib.InsertTag$InsertHandler doEndTag
SEVERE: ServletException in '/ResourceConfiguration.jsp': javax.servlet.jsp.JspException: Error - tag useAttribute : attribute 'config_page_content' not found in context. Check tag syntax
org.apache.jasper.JasperException: An exception occurred processing JSP page /ResourceConfiguration.jsp at line 87

84:
85:
86: <%-- Begin Column header layout --%>
87: <tiles:useAttribute name="config_page_content" ignore="false" />
88: <logic:notEmpty name="config_page_content">
89: <tiles:insert attribute="config_page_contentx" ignore="false" beanScope="request" />
90: </logic:notEmpty>

Thanks for your help, I really appreciate it.
Tim





 
E Robb
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using tiles 2? I think Lucas had a good idea which cascade but it sounds like we are talking about two different deployments:

Tiles 1.0 uses for example
tiles:insert attribute="body"

The example I provided is tiles 2.0.6 which uses
tiles:insertAttribute name="body"

It could be your getting the errors because you are working on an older version of tiles than the advice I provided to you.

If you are working on a version earlier than 2.0 than that is what is causing the error.

Thanks,
Earl
 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lucas and earl

Thanks. I upgraded to Tiles 2 per Struts web site migration page and get the following error:



Any clue?

Thanks agian
TIm
 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Earl and Lucas:
Update
The above error was caused because I needed to add tiles-template to the project library.

I also discovered that the following need to be added:
slf4j-api-1.5.8.jar
slf4j-jdk14-1.5.8.jar

These were not mentioned in the Struts migration page.

Thanks
Tim

 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am now getting NullPointerExceptions on every line of the jsp file where <tiles:insertAttribute name="this_content.jsp/> and all other <tiles: xxxx > usage.

Here is the section of tiles-defs-sml


MainPage2.jsp:



Error:



Thanks for you help.
Tim
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does AdminMenuBar.jsp contain ... do you have any tiles:insertAttribute in there? If you do those would require a cascade="true" in the tiles config
 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The AdminMenuBar.jsp contains only a set of drop down menus. It contains no reference to tiles.

The only tiles:inserted page which does contain another <tiles:insert ....> is, or could be based upon user option, the "body". But that should not blow up the whole page.

I am using a tiles Listener.

This message I got this morning seems to say that the attribute is not available to the page.



I must be missing something simple.

Thanks
Tim
 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am closing this because the solution to the original problem was to convert to Tiles 2.

I am having trouble getting Tiles 2 to work and will deal with that separately.

Thanks for everyones help.
Tim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic