You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Janice <ja...@shaw.ca> on 2003/11/21 19:19:15 UTC
(newbie asking advice) in which order do I call my .do and .jsp?
Sorry if this is too basic, I'm really green, but trying to learn the right
way to do things.
First off, I'm using tiles, and I think I was doing things backwards, and
I'd like to confirm that I've got things going the right way now. So this
is what I have:
(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>
So, like I said, I was doing it differently before, and I'm not sure why. I
was calling my .jsp page, which was calling the .do from the <tiles:put. It
worked ok, but I suspect this is the better way.
TIA,
Janice
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: (newbie asking advice) in which order do I call my .do and .jsp?
Posted by Rick Reumann <st...@reumann.net>.
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