Tim, 
I tried what suggested, but still get the "The requested resource
(/myapp/myapp.index) is not available." error. 

Somethings missing...the Factory gets initialized from file
'/WEB-INF/tiles-defs.xml' but it looks like the strut-config can't find or
map to the tiles definitions. 

Any other suggestions? Do I need to specify a controller, or am I missing
something in my config files?

Thanks,
Richard

-----Original Message-----
From: Tim Lucia [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 5:42 PM
To: 'Struts Users Mailing List'
Subject: RE: Tiles setup question


The global forwards work for struts taglib tags, generally as the value
of the name="" attribute.  They do not export to the web server (servlet
mapping, *.jsp, etc.) level.  Thus, to access the forward you defined:

   <global-forwards>
       <forward name="index" path="/myapp.index"/>
   </global-forwards>

You would say:

<html:link forward="index">[Return to main menu]</html:link>

However, the target of path cannot be a tile, it must be an action which
forwards to the tile. [Is this true?  I have never seen a tile as a
global forward target]

Here is an example:

Your.jsp:
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html:link forward="tileTest">[return to main menu]</html:link>

Your-struts-config.xml:
                <forward name="tileTest" path="/tileTest.do"/>
                
                <action path="/tileTest"
                        type="org.apache.struts.actions.ForwardAction"
                        parameter=".tileTest"/>

Your-tiles-def.xml:
  <definition name=".tileTest" extends="layout"/>


Tim Lucia

> -----Original Message-----
> From: Richard Hill [mailto:[EMAIL PROTECTED] 
> Sent: Monday, December 08, 2003 7:59 PM
> To: '[EMAIL PROTECTED]'
> Subject: Tiles setup question
> 
> 
> I'm setting up tiles with an example application and I'm 
> getting blocked when trying to use Tiles layout names instead 
> of the JSP filenames in the struts-config.xml. I'm hoping 
> that someone on this list can point out what I'm doing wrong.
> 
> I can access the application by explicitly typing in 
> "index.jsp" in the url, but when I try a page with a link 
> defined in my struts-config.xml global-forwards name="index" 
> I get an error message: The requested resource
> (/myapp/myapp.index) is not available.
> 
> My tomcat localhost.log file show that the Tiles definition 
> factory gets loaded...what am I missing?
> 
> Thanks,
> Richard
>

---------------------------
    localhost.log
---------------------------
action: Tiles definition factory loaded for processor ''.
factory loaded : {myapp.default={name=myapp.default,
path=/layouts/myappLayout.jsp, role=null, controller=null,
controllerType=null, controllerInstance=null,
attributes={header=/tiles/common/header.jsp,
footer=/tiles/common/footer.jsp}}
, myapp.index={name=myapp.index, path=/layouts/myappLayout.jsp, role=null,
controller=null, controllerType=null, controllerInstance=null,
attributes={body=/introduction.jsp, navbar=/tiles/tempNavBar.jsp,
title=Myapp > Index, footer=/tiles/common/footer.jsp,
header=/tiles/common/header.jsp}}
}
Factory initialized from file '/WEB-INF/tiles-defs.xml'.


----------------------------------
    html source with link
----------------------------------
<html:link forward="index">[Return to main menu]</html:link>


----------------------------------
  Error message when link is used
----------------------------------
type Status report

message /myapp/myapp.index

description The requested resource (/myapp/myapp.index) is not available.

----------------------------------
    index.jsp
----------------------------------
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>

<tiles:insert definition="myapp.index" flush="true" />

----------------------------------
    tiles-defs.xml
----------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>

 <!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration//EN"
       "http://jakarta.apache.org/struts/dtds/tiles-config.dtd";>

<tiles-definitions>

    <!-- ========== Master definition ============================== -->
    <definition name="myapp.default" path="/layouts/myappLayout.jsp">
        <put name="header"      value="/tiles/common/header.jsp" />
        <put name="footer"      value="/tiles/common/footer.jsp" />
    </definition>


    <!-- ========== Index page definition ============================== -->
    <definition name="myapp.index" extends="myapp.default">
        <put name="title"       value="Myapp > Index" />
        <put name="navbar"      value="/tiles/tempNavBar.jsp" />
        <put name="body"        value="/introduction.jsp" />
    </definition>

</tiles-definitions>


----------------------------------
    struts-config.xml
----------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>

<struts-config>

  <!-- ======== Form Bean Definitions ===================================
-->
    <form-beans>

    </form-beans>

  <!-- ========== Global Forward Definitions ==============================
-->
  <global-forwards>
      <forward name="index" path="/index.do"/>
  </global-forwards>

  <!-- ========== Action Mapping Definitions ==============================
-->
  <action-mappings>
        <action path="/index"
            type="org.apache.struts.actions.ForwardAction"
            parameter="myapp.index"/>

  </action-mappings>

  <!-- ========== Message Resources Definitions ===========================
-->
  <message-resources parameter="myapp.ApplicationResources"/>

  <!-- ========== Tiles Plug-in Configuration ===========================
-->
  <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
        <set-property property="definitions-debug" value="2" />
        <set-property property="definitions-parser-details" value="2" />
        <set-property property="definitions-parser-validate" value="true" />
  </plug-in>

</struts-config>


------------------------
    web.xml
------------------------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>

  <!-- The Struts Action Servlet  -->
  <servlet>
      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
      </init-param>
      <init-param>
          <param-name>definitions-config</param-name>
          <param-value>/WEB-INF/tiles-defs.xml</param-value>
      </init-param>
      <init-param>
          <param-name>debug</param-name>
          <param-value>3</param-value>
      </init-param>
      <init-param>
          <param-name>detail</param-name>
          <param-value>3</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
  </servlet>

  <!-- Action Servlet Mapping -->
  <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/WEB-INF/tlds/struts-tiles.tld</taglib-uri>
    <taglib-location>/WEB-INF/tlds/struts-tiles.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/struts</taglib-uri>
    <taglib-location>/WEB-INF/lib/struts.jar</taglib-location>
  </taglib>
</web-app>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to