struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <strut...@reumann.net>
Subject Re: (newbie asking advice) in which order do I call my .do and .jsp?
Date Fri, 21 Nov 2003 18:56:34 GMT
Janice wrote:

> (1) When I want to display a list of widgets, my link is to:
> 
> /projectTypes.do?action=showList
> 
> (2) My mapping looks like this (ProjectTypeCodeActions extends
> DispatchAction):
> 
>     <action    path="/projectTypes"
>                input="/projectTypeCode/project_type_code_form.jsp"
>                parameter="action"
>                scope="request"
>                type="projectTypeCode.ProjectTypeCodeActions"
>                validate="false">
>       <forward name="form"
> path="/projectTypeCode/project_type_code_form.jsp" />
>       <forward name="list"
> path="/projectTypeCode/project_type_code_list.jsp" />
>       <forward name="failure" path="/common/error.html" />
>     </action>
> 
> (3) So it goes off to the DB to get my list, and then forwards off to
> project_type_code_list.jsp, which contains:
> 
> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
> 
> <tiles:insert page="../layouts/PPELayout.jsp">
>   <tiles:put name="menuLinks" value="../common/menu.jsp" />
>   <tiles:put name="mainBody"
> value="../projectTypeCode/project_type_code_list_body.jsp" />
> </tiles:insert>


I could be misunderstanding what you are trying to accomplish, but I 
think you are not utilizing the true benefit of tiles. In the example 
above it looks like you want an action to get you a List of project type 
codes and then display them(?).  Normally using tiles, the benefit would 
be that you would only have to code the actual 
"project_type_code_list.jsp"   which would just be the simple loop of 
the list and display the output. The layout portion (which you seem to 
defining in the project_type_code_list.jsp) is set up elsewhere as a 
definition that would use a base layout that all of your pages could use...


For example you'd define a main *layout.jsp* page that might look like...
------------------------------------------------------------------------

<%@ taglib uri="tiles" prefix="tiles" %>
<!-- possibly other tag imports -->
<html>
<head><title><tiles:getAsString name='title'/></title></head>
<body>
<table>
<tr>
   <td><tiles:insert attribute='menu'/></td>
   <td><tiles:insert attribute='content'/></td>
</tr>
</table>
</body>
</html>


Then in your *tiles-def.xml* file you might have:
------------------------------------------------

<definition name="BaseDef" template="layout.jsp">
         <put name="title"               value="${title}"/>
         <put name="menu"                value="yourMenu.jsp"/>
         <put name="content"             value="${content}"/>
</definition>

<!-- your definitions can extend the one above -->
<definition name="projectCodes.page" extends ="BaseDef">
         <put name="title" value="Project Codes List"/>
         <put name="content" value="productCodes.jsp"/>
</definition>


Your productCodes.jsp:
----------------------

A JSP where you display the List you are getting in your Action



Your Action:
------------

<action  path="/projectTypes"
     input="projectForm.page"
     parameter="action"
     scope="request"
     type="projectTypeCode.ProjectTypeCodeActions"
     validate="false">
       <forward name="form" path="projectFormTile.page" />
       <forward name="failure" path="failureTile.page" />
       <!-- this is the tile just made above -->
       <forward name="list" path="projectCodes.page" />
</action>


-- 
Rick


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


Mime
View raw message