Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Tiles Insert Problem

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problems with seperating static contents to a different project in WSAD. The framework used in presentation layer is Struts/Tiles but I am not sure whether this is to be posted in some other sections. But I feel that its tiles issue.

I had one web project(module) called SOLWeb in an ear called SOL. This web module had every jsp as well as static contents earlier. SOLWeb has context root set as "SOLWeb"

Now, I created another ear file called SOLStatic which holds a web project(module) called SOLStaticWeb with context root set as "SOLWeb/static". All the static contents are moved to WebContent folder of this project now.

With this set up, with out having to change anything in the files, all jsps look fine. Point to be noted is that these jsps internally are refering static contents(via url rewrite) like jpg, css etc which is now in the other newly created static project. So effectively whenever we do struts forward to a jsp(which is in the same project) - it works fine where as if its a struts forward to an html(in the other new project) - it says file not found.

Please see the snippets below that works:

<---Struts Config -->
<action path="/ContactPage" name="productSuggestionFormBean" scope="request" type="com.rbsg.sol.actions.merchant.ProductSuggestionRetrievalAction">
<forward name="success" path="contactus.definition" />

<---Tiles Def ---->
<definition name="contactus.definition" extends="portal.layout">
<put name="mainTitle" value="Streamline Online" />
<put name="header" value="user.header" />
<put name="pageTitle" value="ContactUsTitle" />
<put name="MIPageTitle" value="MIContactUsTitle" />
<put name="menu" value="" />
<put name="pageInfo" value="ContactUsInfo" />
<put name="body" value="/jsp/header/ContactUs.jsp" />
<put name="selected" value="" />
<put name="validation" value="/jsp/validation/validation.jsp" />

(Here ContactUs.jsp has refernecs to static contents)

Here is the snippet that does not work:

<---Struts Config -->
<action path="/public/FAQPage" include="faq.definition"/>

<---Tiles Def ---->
<definition name="faq.definition" extends="portal.layout">
<put name="mainTitle" value="Streamline Online" />
<put name="header" value="user.header" />
<put name="pageTitle" value="FAQTitle" />
<put name="menu" value="" />
<put name="body" value="/static/faq/en/faq.htm" />
<put name="selected" value="" />

(Here /static/faq/en/faq.htm which is in new project is directly called).

Now in the browser, when I access faq. the url shown is obviously http://localhost:8080/SOLWeb/public/ which says file not found. But if I try http://localhost:8080/SOLWeb/static/faq/en/faq.htm it works fine.

This is the main layout page which inserts individual elements like body and is a tiles:insert

As you can see rewrites are working with out any problems.

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%><%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %><jsp:useBean id="pageTitle0" scope="request" class="java.lang.String" /><jsp:useBean id="pageTitle1" scope="request" class="java.lang.String" /><tiles:importAttribute /><%-- Push component attributes in page context --%>
<head><title><tiles:getAsString name="mainTitle" /></title>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<LINK href="<html:rewrite page='/static/theme/MainStyle.css'/>" rel="stylesheet" type="text/css">
<LINK href="<html:rewrite page='/static/theme/Print.css'/>" rel="stylesheet" type="text/css" media="print">
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table width="768" border="0" cellspacing="0" cellpadding="0" style="BORDER-COLLAPSE: collapse">
<logic:notEmpty name="header" scope="page">
<tr><td colspan="3" width="100%"><tiles:insert attribute="header">
<logic:notEmpty name="pageTitle" scope="page">
<tiles ut name="pageTitle" beanName="pageTitle" />
<tr><logic:notEmpty name="menu" scope="page">
<td width="170" valign="top" align="left" nowrap><tiles:insert attribute="menu"><tiles ut name="selected" beanName="selected" /></tiles:insert></td></logic:notEmpty>
<td width="10" nowrap> </td>
<td width="588" valign="top" align="left">
<table id="content" width="588" border="0" cellpadding="0" style="BORDER-COLLAPSE: collapse">
<logic:notEmpty name="pageTitle" scope="page"><tr><td width="100%" class="page-header"><h1><bean:message name="pageTitle" scope="page" arg0="<%=pageTitle0%>" arg1="<%=pageTitle1%>"/></h1></td></tr></logic:notEmpty>
<logic:notEmpty name="validation" scope="page"><tr><td width="100%"><logic:messagesPresent><tiles:insert attribute="validation"/></logic:messagesPresent></td></tr></logic:notEmpty>
<logic:notEmpty name="pageInfo" scope="page"><tr><td width="100%" colspan="2" class="toptext"><DIV id="PageInfo"><br><bean:message name="pageInfo" scope="page" arg0="<BR>" /></div></td></tr></logic:notEmpty>
<logic:notEmpty name="body" scope="page"><tr><td width="100%" colspan="2"><tiles:insert attribute='body'/></td></tr></logic:notEmpty>

The bizarre thing is that
<LINK href="<html:rewrite page='/static/theme/MainStyle.css'/>"
works even if css is in the newaly created project.

where as
tiles:insert attribute='body'/>
does not work since body refers to
<put name="body" value="/static/faq/en/faq.htm" />

This is the reason I could conclude that its some thing to do with the tiles. If any one knows why its happening and a solution for this - I would give a bunch of thanks.
Your mother was a hamster and your father was a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!