Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts1 - tiles -cascading tiles:insert  RSS feed

 
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
 
Venugopalan Kokkodan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Kernan wrote: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


Tim, Were you able to solve this java.lang.NullPointerException at org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:42)   Issue?

I'm working on a GVT project and need to migrate spring,hibernate and quartz. But spring migration demands Tiles 1 to Tiles 2. But I want to stick with Struts 1.x as the volume of Struts 2 migration will be huge.

My ultimate goal is to migrate an application to spring 4.1.4, Hibernate 4.3. But this was resulting to migrate Tiles 1.x to Tiles 2.x. But this intern was creating issues with Struts 1. With the help of Tiles user community, I was able to get the struts-tiles2-1.4.0-SNAPSHOT.jar
library and I'm trying to migrate a small sample application from Struts 1/Tiles 1 to Struts 1/Tiles 2. After making changes according to the suggestions in https://feima2011.wordpress.com/2011/04/27/struts-1-and-tiles-2-integration/ , I'm getting the following error while running the application in the browser.

If you remember anything how you solved the 6 years back stuff, Please do reply?



Error 500--Internal Server Error

java.lang.NullPointerException
at org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:42)
at org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:187)
at org.apache.tiles.template.InsertAttributeModel.start(InsertAttributeModel.java:107)
at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:306)
at jsp_servlet.__index._jspService(__index.java:93)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:163)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3729)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3695)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2184)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1459)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
In the tiles-defs.xml, I made the changes as below: (PUT changed to put-attribute) (definition path TO definition template) etc
    <definition name="baseLayout" template="/baseLayout.jsp">
        <put-attribute name="title"  value="Tiles Example" />
        <put-attribute name="header" value="/header.jsp" />
        <put-attribute name="menu"   value="/menu.jsp" />
        <put-attribute name="body"   value="/body.jsp" />
        <put-attribute name="footer" value="/footer.jsp" />       
    </definition>
    <definition name="friends" extends="baseLayout">
        <put-attribute name="title" value="Friends" />
        <put-attribute name="body" value="/friends.jsp" />
    </definition>
    <definition name="office" extends="baseLayout">
        <put-attribute name="title" value="The Office" />
        <put-attribute name="body" value="/office.jsp" />
    </definition>

In Jsp's I changed the tag  <tiles:insert name="header" ignore="true" /> TO <tiles:insertAttribute name="header" ignore="true" />

Also in struts-config file,
<controller processorClass="org.apache.struts.tiles2.TilesRequestProcessor"/>
AND
<plug-in className="org.apache.struts.tiles2.TilesPlugin" >

I do have the following jar in my WEB-INF/lib and classpath
struts-core-1.4.0-SNAPSHOT.jar
struts-tiles2-1.4.0-SNAPSHOT.jar
struts-extras-1.4.0-SNAPSHOT.jar
struts-scripting-1.4.0-SNAPSHOT.jar
struts-taglib-1.4.0-SNAPSHOT.jar
struts-tiles-1.4.0-SNAPSHOT.jar
tiles-api-2.2.1.jar
tiles-jsp-2.2.1.jar
tiles-servlet-2.2.1.jar
tiles-template-2.2.0.jar
log4j-1.2.16.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.7.jar
jakarta-oro.jar

I have removed the struts.jar earlier, but with and without struts.jar, I'm getting the same error.
Can any friends be a help on this issue? I am unable to attach the ZIP of the application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!