You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Johnson <ch...@gmail.com> on 2005/02/22 21:50:34 UTC

Tiles - a reality check (contains many details) - Am I using this thing right?

Hi all

I'm slowly figuring out the basics of Tiles, and I feel like its a
good solution for my application. I want to make sure before I get to
far that I'm thinking about things the right way.

I have 

1. a login page with a header, body and footer

2. Application itself which will contain a Header, Navigation, Body
and Footer (same Header, and Footer as the login page).

I have created the following directory structure ans JSP layout under
my brand new shiny Struts 1.1 web application under the WebRoot
Directory

\WebRoot
\WebRoot\WEB-INF
\WebRoot\WEB-INF\tiles-defs.xml (listed below)
\WebRoot\jsp
\WebRoot\jsp\images
\WebRoot\jsp\layouts
\WebRoot\jsp\layouts\loginLayout.jsp
\WebRoot\jsp\layouts\siteLayout.jsp
\WebRoot\jsp\tiles
\WebRoot\jsp\tiles\header.jsp (not full html page)
\WebRoot\jsp\tiles\footer.jsp
\WebRoot\jsp\tiles\navigation.jsp
\WebRoot\jsp\loginBody.jsp
\WebRoot\jsp\appPageBody.jsp

Explanation:
\layouts contains my JSP Layouts for the different parts of the app
\tiles contains my reusable areas in the app (not complete html pages)
\jsp contains the different "body" jsp files

My question is : Is this a typical way to arrange a generic Tiles
application? the problem come in when I try to use definition
inheritance in the tiles-defs.xml file. See how in the tiles-defs.xml
I have page.AppStart inheriting from base.definition, but it's using a
DIFFERENT page as a template because the LOGIN page doesnt need
navigation and th application page does...

tiles-defs.xml
<tiles-definitions>
<!-- Base Tiles Definition -->
  <definition name="base.definition" path="/jsp/layouts/loginLayout.jsp">
<put name="header" value="/jsp/tiles/header.jsp" />
<put name="footer" value="/jsp/tiles/footer.jsp" />
  </definition>

<!-- Tiles Definition of login page -->
  <definition name="page.login" extends="base.definition">
<put name="title" value="Login Page" />
<put name="body" value="/jsp/loginBody.jsp" />
  </definition>

<!-- Tiles definition of mail application page-->
  <definition name="page.appStart" extends="base.definition" 
path="/jsp/layouts/siteLayout.jsp">
              <put name="title" value="Application Title" />
<put name="nav" value="/jsp/navigation.jsp" />
<put name="body" value="/jsp/appStartBody.jsp" />
  </definition>
</tiles-definitions>

-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles - a reality check (contains many details) - Am I using this thing right?

Posted by David Johnson <ch...@gmail.com>.
Hi again - a follow up question.

When using tiles this way, does this mean that any forward I define in
my struts-config.xml should be a valid Tiles Definition?

Would that then imply that every page in my application is specified
by a tiles Definition, and that's how I GET to any given page?

Further, assuming all application pages use the Header/Nav/Body/Footer
layout (called "siteLayout") would there then just be one "body" page
instead of what might be thought of as page in the application, that
then gets included into a layout?

example: I want to create a Profile Editing page, so I create
profileEditBody.jsp and a NEW definition in the tiles-defs file
specifying only the TITLE and BODY ..a la

<definition name="page.profile.edit" extends="base.definition">
     <put name="title" value="Edit Profile Page" /> 
     <put name="body" value="/jsp/profileEditBody.jsp" />
</definition>

Bue heres the question... how do I call this thing from an Action
Class?!?!?! Argh!!!!

On Tue, 22 Feb 2005 15:50:34 -0500, David Johnson <ch...@gmail.com> wrote:
> Hi all
> 
> I'm slowly figuring out the basics of Tiles, and I feel like its a
> good solution for my application. I want to make sure before I get to
> far that I'm thinking about things the right way.
> 
> I have
> 
> 1. a login page with a header, body and footer
> 
> 2. Application itself which will contain a Header, Navigation, Body
> and Footer (same Header, and Footer as the login page).
> 
> I have created the following directory structure ans JSP layout under
> my brand new shiny Struts 1.1 web application under the WebRoot
> Directory
> 
> \WebRoot
> \WebRoot\WEB-INF
> \WebRoot\WEB-INF\tiles-defs.xml (listed below)
> \WebRoot\jsp
> \WebRoot\jsp\images
> \WebRoot\jsp\layouts
> \WebRoot\jsp\layouts\loginLayout.jsp
> \WebRoot\jsp\layouts\siteLayout.jsp
> \WebRoot\jsp\tiles
> \WebRoot\jsp\tiles\header.jsp (not full html page)
> \WebRoot\jsp\tiles\footer.jsp
> \WebRoot\jsp\tiles\navigation.jsp
> \WebRoot\jsp\loginBody.jsp
> \WebRoot\jsp\appPageBody.jsp
> 
> Explanation:
> \layouts contains my JSP Layouts for the different parts of the app
> \tiles contains my reusable areas in the app (not complete html pages)
> \jsp contains the different "body" jsp files
> 
> My question is : Is this a typical way to arrange a generic Tiles
> application? the problem come in when I try to use definition
> inheritance in the tiles-defs.xml file. See how in the tiles-defs.xml
> I have page.AppStart inheriting from base.definition, but it's using a
> DIFFERENT page as a template because the LOGIN page doesnt need
> navigation and th application page does...
> 
> tiles-defs.xml
> <tiles-definitions>
> <!-- Base Tiles Definition -->
>  <definition name="base.definition" path="/jsp/layouts/loginLayout.jsp">
> <put name="header" value="/jsp/tiles/header.jsp" />
> <put name="footer" value="/jsp/tiles/footer.jsp" />
>  </definition>
> 
> <!-- Tiles Definition of login page -->
>  <definition name="page.login" extends="base.definition">
> <put name="title" value="Login Page" />
> <put name="body" value="/jsp/loginBody.jsp" />
>  </definition>
> 
> <!-- Tiles definition of mail application page-->
>  <definition name="page.appStart" extends="base.definition"
> path="/jsp/layouts/siteLayout.jsp">
>              <put name="title" value="Application Title" />
> <put name="nav" value="/jsp/navigation.jsp" />
> <put name="body" value="/jsp/appStartBody.jsp" />
>  </definition>
> </tiles-definitions>
> 
> --
> -Dave
> ChaChaNY@Gmail.com
> 


-- 
-Dave
ChaChaNY@Gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org