RE: design flaw if using a template...

2002-03-10 Thread Matt Read

Hmm, that's fairly annoying isn't it. I only use Resin myself which is
lucky, thanks for pointing this out though, good to know that I can just
release my WAR onto tomcat and expect it to work.

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


Hi Matt

I have done more research over the weekend and this is what I have found:

The multiple *.do only works in Resin, not Tomcat. In Tomcat, this is the
exception:

"javax.servlet.jsp.JspException: Cannot forward after response has been
committed"

Further investigation shows that Tomcat is calling flushBuffer() after the
first forward. Resin handles this differently, as shown in this post I
found:



-Original Message-
From: Andreas Junghans [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 22, 2002 1:09 AM
To: Tomcat Developers List
Cc: [EMAIL PROTECTED]
Subject: Re: HttpServletResponseWrapper error.


Hi Jay,

> This works with Resin. However, in Tomcat, when I wrap the response, I
> "commit" the original response object and can not forward to a thank you
> page. I catch a "java.lang.IllegalStateException: Cannot forward after
> response has been committed". In my debug tests, the response is committed
> during the RequestDispatchers forward method.

I've had a similar case. The problem is that Tomcat calls flushBuffer() on
the response, which seems to be completely "legal" regarding the Servlet
spec. Calling flushBuffer() commits the response, and after that, no forward
is possible.

If Resin behaves differently, this is probably due to a different buffer
size or different buffer handling. Perhaps Resin doesn't call flushBuffer()
at all, which (in my understanding) is just as spec compliant as Tomcat's
behaviour.

What you have to do is override flushBuffer() in your response wrapper to
prevent HttpServletResponseWrapper from passing the flush to the original
response. In my case, I simply added an empty flushBuffer() method to the
wrapper, and it worked. However, you should note that some containers
_might_ rely on the side effects of the original flushBuffer() (e.g. that
exceptions are raised when calling methods like sendRedirect() afterwards).
Although this is highly unlikely, you have to "simulate" these effects in
your wrapper if you want to be _absolutely_ sure your application runs in
every container.

Regards

  Andreas Junghans




I have tried the latest version of Tomcat 4.0.3, but no joy.

Keith




-Original Message-
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: Friday, 8 March 2002 11:04 a.m.
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


I'm glad you've found a solution. I'd still say you're misusing
 though, because it's not really a template that you're
inserting but if it works, it works.

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


Hi Matt

I am such an idiot.

In my template.jsp, I have:



This is equivalent to a jsp include. My mistake was news.do forwards to
new.jsp after getting the data from the database.

However, news.jsp uses template.jsp too!! So it's trying to go into an
infinite loop!

I have changed new.jsp to just return the news. It's going well.

Thank you very much for all you help.

Keith



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


Keith, they're not the same thing, by any means. As you said, if you use
your method:

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  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:



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





This is what you have done. Alternativ

RE: design flaw if using a template...

2002-03-10 Thread Keith Chew

Hi Matt

I have done more research over the weekend and this is what I have found:

The multiple *.do only works in Resin, not Tomcat. In Tomcat, this is the
exception:

"javax.servlet.jsp.JspException: Cannot forward after response has been
committed"

Further investigation shows that Tomcat is calling flushBuffer() after the
first forward. Resin handles this differently, as shown in this post I
found:



-Original Message-
From: Andreas Junghans [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 22, 2002 1:09 AM
To: Tomcat Developers List
Cc: [EMAIL PROTECTED]
Subject: Re: HttpServletResponseWrapper error.


Hi Jay,

> This works with Resin. However, in Tomcat, when I wrap the response, I
> "commit" the original response object and can not forward to a thank you
> page. I catch a "java.lang.IllegalStateException: Cannot forward after
> response has been committed". In my debug tests, the response is committed
> during the RequestDispatchers forward method.

I've had a similar case. The problem is that Tomcat calls flushBuffer() on
the response, which seems to be completely "legal" regarding the Servlet
spec. Calling flushBuffer() commits the response, and after that, no forward
is possible.

If Resin behaves differently, this is probably due to a different buffer
size or different buffer handling. Perhaps Resin doesn't call flushBuffer()
at all, which (in my understanding) is just as spec compliant as Tomcat's
behaviour.

What you have to do is override flushBuffer() in your response wrapper to
prevent HttpServletResponseWrapper from passing the flush to the original
response. In my case, I simply added an empty flushBuffer() method to the
wrapper, and it worked. However, you should note that some containers
_might_ rely on the side effects of the original flushBuffer() (e.g. that
exceptions are raised when calling methods like sendRedirect() afterwards).
Although this is highly unlikely, you have to "simulate" these effects in
your wrapper if you want to be _absolutely_ sure your application runs in
every container.

Regards

  Andreas Junghans




I have tried the latest version of Tomcat 4.0.3, but no joy.

Keith




-Original Message-
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: Friday, 8 March 2002 11:04 a.m.
To: Struts Users Mailing List
Subject: RE: design flaw if using a template...


I'm glad you've found a solution. I'd still say you're misusing
 though, because it's not really a template that you're
inserting but if it works, it works.

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


Hi Matt

I am such an idiot.

In my template.jsp, I have:



This is equivalent to a jsp include. My mistake was news.do forwards to
new.jsp after getting the data from the database.

However, news.jsp uses template.jsp too!! So it's trying to go into an
infinite loop!

I have changed new.jsp to just return the news. It's going well.

Thank you very much for all you help.

Keith



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


Keith, they're not the same thing, by any means. As you said, if you use
your method:

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  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:



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





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



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]

RE: design flaw if using a template...

2002-03-07 Thread Matt Read

I'm glad you've found a solution. I'd still say you're misusing
 though, because it's not really a template that you're
inserting but if it works, it works.

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


Hi Matt

I am such an idiot.

In my template.jsp, I have:



This is equivalent to a jsp include. My mistake was news.do forwards to
new.jsp after getting the data from the database.

However, news.jsp uses template.jsp too!! So it's trying to go into an
infinite loop!

I have changed new.jsp to just return the news. It's going well.

Thank you very much for all you help.

Keith



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


Keith, they're not the same thing, by any means. As you said, if you use
your method:

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  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:



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





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



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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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

RE: design flaw if using a template...

2002-03-07 Thread Keith Chew

Hi Matt

I am such an idiot.

In my template.jsp, I have:



This is equivalent to a jsp include. My mistake was news.do forwards to
new.jsp after getting the data from the database.

However, news.jsp uses template.jsp too!! So it's trying to go into an
infinite loop!

I have changed new.jsp to just return the news. It's going well.

Thank you very much for all you help.

Keith



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


Keith, they're not the same thing, by any means. As you said, if you use
your method:

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  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:



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





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



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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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

RE: design flaw if using a template...

2002-03-07 Thread Keith Chew

Hi Ross

I understand where you are coming from. I was just trying to see if I can
reuse what Struts already have.

Last night I just discovered that it was my idiocity that caused the
problem. Matt's suggestion works, I'll explain why in the reply to his post.

Keith



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


Hi Keith.


I look at the system as having several complementary models, controllers and
event triggers.  Struts Action, ActionForm, and submit triggers are among
them but not the only ones.  In other words, I don't see Struts Actions as
being the only system entities that can respond to event triggers, and
ActionForm beans are not the only data containers.  As you have discovered,
the struts objects are really only good at responding to a subset of the
possible events, and handling a subset of the pages data.  I think that is
intentional rather than a flaw.

If you buy that, then you can use "page load" as an event trigger, and your
own home grown "NewsModel" bean.  Some other home grown controller can go
get the data and push it into the news bean.  These homegrowns cause you
trouble when you try to force them to be children of Action and ActionForm.

So I'm suggesting only that the tag load and display the data from the news
model.  However, if you wish to have the "page load event" trigger a model
update, the lines get a bit blurry because I'm using the custom tag's
execution thread to kick off the model load, and refresh the display.
Although that thread is involved with "double duty"  the object model is
still clean --- the custom tag is just rendering data, and some other
controller logic is getting the data.

You could use other events to load the news bean such as user log in,
periodic polling, etc.  Not sure what your requirements are here but I'm
guessing you want the news updated on each page load.

OK I'll shut up with the philosophical stuff and let you get back to the
real solution that Matt helped you with :)

Good Luck

/Ross





 -Original Message-
From:   Keith Chew [mailto:[EMAIL PROTECTED]]
Sent:   Wednesday, March 06, 2002 6:02 PM
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:



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:



This will call the NewsAction which accesses the database, and forwa

RE: design flaw if using a template...

2002-03-07 Thread Ross MacCharles

Hi Keith.


I look at the system as having several complementary models, controllers and
event triggers.  Struts Action, ActionForm, and submit triggers are among
them but not the only ones.  In other words, I don't see Struts Actions as
being the only system entities that can respond to event triggers, and
ActionForm beans are not the only data containers.  As you have discovered,
the struts objects are really only good at responding to a subset of the
possible events, and handling a subset of the pages data.  I think that is
intentional rather than a flaw.

If you buy that, then you can use "page load" as an event trigger, and your
own home grown "NewsModel" bean.  Some other home grown controller can go
get the data and push it into the news bean.  These homegrowns cause you
trouble when you try to force them to be children of Action and ActionForm.

So I'm suggesting only that the tag load and display the data from the news
model.  However, if you wish to have the "page load event" trigger a model
update, the lines get a bit blurry because I'm using the custom tag's
execution thread to kick off the model load, and refresh the display.
Although that thread is involved with "double duty"  the object model is
still clean --- the custom tag is just rendering data, and some other
controller logic is getting the data.

You could use other events to load the news bean such as user log in,
periodic polling, etc.  Not sure what your requirements are here but I'm
guessing you want the news updated on each page load.

OK I'll shut up with the philosophical stuff and let you get back to the
real solution that Matt helped you with :)

Good Luck

/Ross





 -Original Message-
From:   Keith Chew [mailto:[EMAIL PROTECTED]] 
Sent:   Wednesday, March 06, 2002 6:02 PM
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:



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:



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



in the JSP. 

RE: design flaw if using a template...

2002-03-06 Thread Keith Chew


Hmm, but I don't want to put anything to the template.jsp. I just want the
template to include the news.do. If what you are saying is correct, I should
really be using .

However, I'll give all 3 methods a go. I am sure you are correct.

Great stuff! Thanks Matt

Keith

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


Keith, they're not the same thing, by any means. As you said, if you use
your method:

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  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:



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





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



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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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 

RE: design flaw if using a template...

2002-03-06 Thread Matt Read

Keith, they're not the same thing, by any means. As you said, if you use
your method:

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  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:



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





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



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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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.




... some html



Matt.

-O

RE: design flaw if using a template...

2002-03-06 Thread Keith Chew

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:



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





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



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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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.



    
        ... some html



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 th

RE: design flaw if using a template...

2002-03-06 Thread Matt Read

Sorry, I hope you spotted my mistake, the lines:


Should read:



Matt.

-Original Message-
From: Matt Read [mailto:[EMAIL PROTECTED]]
Sent: 07 March 2002 00:28
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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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.




... some html
    


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

RE: design flaw if using a template...

2002-03-06 Thread Matt Read

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  and
. Make sure you use an example similar to mine rather than the
one you posted in your first message. Note the differences, mine uses:

to put the Action into the template that's declared using:


Your example seemed to be trying to use the path to the Action itself as the
template which is completely different:


You need to do the following:
1. Create an action mapping like this in struts-config.xml:

2. Create your template file "/mytemplate.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>




3. Create your page "/thePage.jsp" something like this:
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>





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.




... some html
    


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 

RE: design flaw if using a template...

2002-03-06 Thread Keith Chew


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.




... some html



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:



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:



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 templa

RE: design flaw if using a template...

2002-03-06 Thread Matt Read

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.




... some html



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:



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:



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



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:
<

RE: design flaw if using a template...

2002-03-06 Thread Keith Chew

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.




... some html



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:



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:



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



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]>




RE: design flaw if using a template...

2002-03-06 Thread Matt Read

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.




... some html



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:



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:



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



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]>




RE: design flaw if using a template...

2002-03-06 Thread Keith Chew

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:



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:



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



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]>




RE: design flaw if using a template...

2002-03-06 Thread Keith Chew


Tiles does not solve the problem. As far as I can see, Tiles makes it easy
to configure your presentation pages, and pass variables between templates.
It makes your presentation design work more OO.

However, my issue is more of an archietecture problem, not a presentation
problem.

Keith


-Original Message-
From: rajesh kalluri [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 7 March 2002 10:46 a.m.
To: Struts Users Mailing List
Subject: Re: design flaw if using a template...


Keith, check out... http://www.lifl.fr/~dumoulin/tiles/
.the new examples that come with it solve some related problem.

> 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
>
> 
>
> 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:
> 

---Every tile is associated with a controller (make sure you check out the
struts-config.xml that comes with tiles distrib)
--- Controller for each tile prepares the data required for each tile
(eliminating the need for your - news.jsp we can access the database and
retrieve the news for display)
---then in your template news.jsp you can import the data with tiles
specific tags like






> 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
>
> Basically, I want to call
>
> 
>
> 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]>




RE: design flaw if using a template...

2002-03-06 Thread Ross MacCharles

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:



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:



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



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]>




Re: design flaw if using a template...

2002-03-06 Thread rajesh kalluri

Keith, check out... http://www.lifl.fr/~dumoulin/tiles/
.the new examples that come with it solve some related problem.

> 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
>
> 
>
> 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:
> 

---Every tile is associated with a controller (make sure you check out the
struts-config.xml that comes with tiles distrib)
--- Controller for each tile prepares the data required for each tile
(eliminating the need for your - news.jsp we can access the database and
retrieve the news for display)
---then in your template news.jsp you can import the data with tiles
specific tags like






> 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
>
> Basically, I want to call
>
> 
>
> in the JSP. Has anyone done something like this?
>
> Keith
>
>
> --
> To unsubscribe, e-mail:

> For additional commands, e-mail:

>
>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




design flaw if using a template...

2002-03-06 Thread Keith Chew

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:



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:



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



in the JSP. Has anyone done something like this?

Keith


--
To unsubscribe, e-mail:   
For additional commands, e-mail: