Keith, they're not the same thing, by any means. As you said, if you use
your method:
        <template:insert template="/news.do" />
you get a "too many servlet includes `/template.jsp'" error. This is doesn't
really suprise me at all - you're basically trying to use something which
blatantly isn't a template, as a template.

However if you use the method I outlined in my examples, i.e. you "put"
content into a template, whether this content is a .jsp or an action mapping
url - it works.

Honestly, just use <template:put> as it is documented and your problems will
be solved.

Matt.

-----Original Message-----
From: Keith Chew [mailto:[EMAIL PROTECTED]]
Sent: 07 March 2002 02:18
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


Hi Matt

I will try this again tonight. But I am doing the same as you (well, just
another way):

In template.jsp, you can either go:

<template:get name="somecontent"/>

if you have passed in "somecontent" to the template, eg in thepage.jsp:

        <template:insert template="/template.jsp">
                <template:put name="somecontent" content="/news.do" />
        </template:insert>

This is what you have done. Alternatively, in template.jsp, you can go:

<template:insert template="/news.do"/>

if you don't pass "somecontent" to template.jsp. The line above is just like
a jsp:include tag.

Anyway, I will test this again tonight. I hope it's something stupid I have
done. I will also report the exact exception after the test.

Thanks again Matt.

Keith


-----Original Message-----
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 7 March 2002 1:28 p.m.
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


Yep, that's pretty much what I did. I don't really have a cut-down example
that demonstrates it working as I tried it as part of an app that I'm
building.

I'm not sure you're understanding the correct use of <template:insert> and
<template:put>. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:
        <template:put name="newspanel" content="/news/shownews.do" />
to put the Action into the template that's declared using:
        <template:insert template="/templates/myTemplate.jsp">

Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:
        <template:insert template="news.do"/>

You need to do the following:
1. Create an action mapping like this in struts-config.xml:
        <action path="/mypage"
                type="org.apache.struts.actions.ForwardAction"
                parameter="/thePage.jsp" />
2. Create your template file "/mytemplate.jsp" something like this:
        <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
        <table><tr>
                <td><template:get name="leftSide"/></td>
                <td><template:get name="rightSide"/></td>
        </tr></table>
3. Create your page "/thePage.jsp" something like this:
        <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
        <template:insert template="/WEB-INF/templates/template.jsp">
                <template:put name="leftSie" content="/path/to/some/other/action.do" />
                <template:put name="leftSie"
content="/path/to/some/other/different/action.do" />
        </template:insert>

4. Open up http://mymachine.com/mypage.do and it should show the result of
your 2 actions that you "put" in step 3.

Hope this is clear enough.

Matt.

-----Original Message-----
From: Keith Chew [mailto:[EMAIL PROTECTED]]
Sent: 07 March 2002 00:14
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...



Matt, thank you very much for trying this out. I appreciate the time you are
spending to help me track the problem.

Can you give this a go:

In the address bar, type a *.do address, eg
http://localhost:8080/test/page1.do

This will call Page1Action, which forwards to page1view.jsp

In page1view.jsp, it will have your template which inserts shownews.do.

I believe this will fail.

If you have a JSP in the address bar, it's fine. But with a .do, it's not.

I have using the 26 Feb 2002 snapshot.

Keith



-----Original Message-----
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 7 March 2002 12:54 p.m.
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


I did try it and it worked fine. I'm using the nightly build.

-----Original Message-----
From: Keith Chew [mailto:[EMAIL PROTECTED]]
Sent: 06 March 2002 23:49
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


Hi Matt

Yes, that's exactly what I want. In fact, I have the same code that you have
given below.

But Struts does not allow it. It complains that the request is already
commited and cannot forward twice.

Can someone try this out for me please? Maybe I have missed out something...

If this can be achieved, it'll be so easy to mix and match your Actions, put
them as links in a page or in the template.

Keith




-----Original Message-----
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 7 March 2002 12:12 p.m.
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


My apologies if I'm misunderstanding your point but if you're concerned that
the elements that you "put" into your template are not going through the an
xxxAction then why not put the URL for the action in instead of a .jsp? This
way your ShowNewsAction is following the same flow as any other content.
E.g.

<template:insert template="/WEB-INF/templates/myTemplate.jsp">
    <template:put name="newspanel" content="/news/shownews.do" />
    <template:put name="content">
                ... some html
    </template:put>
</template:insert>

Matt.

-----Original Message-----
From: Keith Chew [mailto:[EMAIL PROTECTED]]
Sent: 06 March 2002 23:02
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


Hi Ross

Good comments.

You see, with custom tags, there are several problems:
- For each different parts of the template, I need to create a custom tag
- This custom tag is actually what an xxxAction class is meant to do, ie
retrieve data from a database and prepare the data for view
- If I later decide not to put news in the template and put it in a separete
page, I need to port the taglib code to an xxxAction class. Not very
flexible.
- taglibs from Struts point of view, only renders data for viewing. It
should not be performing model work, which should really be in the xxxAction
class.

So, I can see that Struts was designed to handle "user invoked" actions, not
"code invoked" actions.

Any more thoughts?
Keith



-----Original Message-----
From: Ross MacCharles [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 7 March 2002 11:14 a.m.
To: 'Struts Users Mailing List'
Subject: RE: design flaw if using a template...


Consider rethinking the philosophy that all data rendered in the JSP must
come from an ActionForm.   In my mind the ActionForm generally represents
the editable data for the page displayed to the user.  There's no problem
with displaying data from other sources on the same page - especially read
only data.

For news I would simply use a custom tag to get it and display it.

Put another way, I wouldn't want to have to set up a bean with "setNews" and
"setMemberCount" when I have no intention of allowing my application to edit
those values.

/Ross


 -----Original Message-----
From:   Keith Chew [mailto:[EMAIL PROTECTED]]
Sent:   Wednesday, March 06, 2002 4:28 PM
To:     Struts Users Mailing List
Subject:        design flaw if using a template...

Hi

Struts provides us with a nice MVC architecture, where:
- a user's click maps to an Action
- based on the results, the user is forwarded to the view

Now, I have a template.jsp which all pages will use. The template will
contain some views that are common to all pages, eg:
- Latest News
- Site visits
- Member count

To retrieve these information, it gets them from the database. However,
there is no user click to invoke the action. This is where the limitation of
Struts comes in. Let me explain:

In the template.jsp, we can have:

<template:insert template="news.jsp"/>

In news.jsp we can access the database and retrieve the news for display.
This breaks the MVC pattern, since the view is accessing the model.
Alternatively, we have have this in the template.jsp:

<template:insert template="news.do"/>

This will call the NewsAction which accesses the database, and forwards the
results to the news.jsp for display.

This is a great concept, but it does not work. Struts does not allow
multiple forwards (this happens when the current page is already a .do).
Here's an example:
(1) User clicks on viewUserDetail.do
(2) ViewDetialAction forwards to user.jsp
(3) In template.jsp (used by user.jsp), news.do invokes NewsAction, and it
forwards to news.jsp

This is a double forward, which results in an exception.

Basically, I want to call

<template:insert template="news.do"/>

in the JSP. Has anyone done something like this?

Keith


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

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


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


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


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


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


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


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


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


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

Reply via email to