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:

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

Reply via email to