You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Cutler <gr...@yahoo.com> on 2002/10/09 20:20:50 UTC

Help with Dynamic Includes

Hello -

I'm new to the Struts architecture, and am writing a
small application to teach myself. I've got the basic
concepts and simple design patterns, but am having a
problem trying to structure part of my presentation
logic in a "struts-like" way. I'd like to build up
part of a page by including the results from another
action, called dynamically.

Here's what I've got:

<form-beans>
    <form-bean name="ParentForm" type="my.ParentForm"
/>
    <form-bean name="ChildForm" type="my.ChildForm" />
</form-beans>

<global-forwards>
    <forward name="showParent" path="/parent.do"
redirect="false" />
    <forward name="includeChild"
path="/child.do?action=show" redirect="false" />
</global-forwards>

<action-mappings>
    <action path="/parent" type="my.ParentAction"
name="ParentForm">
        <forward name="success" path="/parent.jsp"
redirect="false" />
    </action>

    <action path="/child" type="my.ChildAction"
name="ChildForm">
        <forward name="show" path="/child.jsp" />
    </action>
</action-mappings>

Where parent.do and it's corresponding form take some
parameters, do some logic, and forward to parent.jsp
for display. However, I would also like to include
child.do, but want to pass it some additional
parameter foo=bar when including it. I've already set
up some of that information (action=show) in the
global forward, but how do I wrap up additional
parameters for an include. I've seen how to *link* to
this with (for example):

<html:link forward="includeChild" paramId="foo"
paramName="ParentForm" paramProperty="foo" />

but am looking for the same kind of functionality to
do includes.

I can get _something_ to work with <jsp:include
page="/child.do?action=show&foo=bar" /> but this still
isn't either 1) building it dynamically or 2) very
"struts-like" since I'm not taking advantage of my
global forward configuration for the action=show.

I'm open to using jsp methods, struts, templates,
whatever. I'm just learning, but can't find this one.

If someone could point me in the right direction (or
tell me how my design is wrong anyway and it would be
better to do it like ..xyz...) it would be greatly
appreciated.

Thanks,
Greg

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Dynamic Includes

Posted by Cedric Dumoulin <ce...@apache.org>.
  Hi,

  Have you check the Tiles framework that come with Struts ?
 
     Cedric

Greg Cutler wrote:

>Hello -
>
>I'm new to the Struts architecture, and am writing a
>small application to teach myself. I've got the basic
>concepts and simple design patterns, but am having a
>problem trying to structure part of my presentation
>logic in a "struts-like" way. I'd like to build up
>part of a page by including the results from another
>action, called dynamically.
>
>Here's what I've got:
>
><form-beans>
>    <form-bean name="ParentForm" type="my.ParentForm"
>/>
>    <form-bean name="ChildForm" type="my.ChildForm" />
></form-beans>
>
><global-forwards>
>    <forward name="showParent" path="/parent.do"
>redirect="false" />
>    <forward name="includeChild"
>path="/child.do?action=show" redirect="false" />
></global-forwards>
>
><action-mappings>
>    <action path="/parent" type="my.ParentAction"
>name="ParentForm">
>        <forward name="success" path="/parent.jsp"
>redirect="false" />
>    </action>
>
>    <action path="/child" type="my.ChildAction"
>name="ChildForm">
>        <forward name="show" path="/child.jsp" />
>    </action>
></action-mappings>
>
>Where parent.do and it's corresponding form take some
>parameters, do some logic, and forward to parent.jsp
>for display. However, I would also like to include
>child.do, but want to pass it some additional
>parameter foo=bar when including it. I've already set
>up some of that information (action=show) in the
>global forward, but how do I wrap up additional
>parameters for an include. I've seen how to *link* to
>this with (for example):
>
><html:link forward="includeChild" paramId="foo"
>paramName="ParentForm" paramProperty="foo" />
>
>but am looking for the same kind of functionality to
>do includes.
>
>I can get _something_ to work with <jsp:include
>page="/child.do?action=show&foo=bar" /> but this still
>isn't either 1) building it dynamically or 2) very
>"struts-like" since I'm not taking advantage of my
>global forward configuration for the action=show.
>
>I'm open to using jsp methods, struts, templates,
>whatever. I'm just learning, but can't find this one.
>
>If someone could point me in the right direction (or
>tell me how my design is wrong anyway and it would be
>better to do it like ..xyz...) it would be greatly
>appreciated.
>
>Thanks,
>Greg
>
>__________________________________________________
>Do you Yahoo!?
>Faith Hill - Exclusive Performances, Videos & More
>http://faith.yahoo.com
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>  
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>