You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Immanuel, Gidado-Yisa" <av...@cdc.gov> on 2001/06/15 15:50:34 UTC
Object Models and patterns in Struts
This is a quick note of some things I've been thinking
with regards patterns for web app development. It's
divided into four sections:
1. My understanding of Struts-MVC
2. Content Object Models
3. Patterns
4. Questions
MY UNDERSTANDING OF STRUTS-MVC
------------------------------
Just a quick review of MVC for struts, illustrating
the basic request scenario (in collaboration diagram
format):
Control Model
HTTP(1) +--------+ +--------------+
-------->| Action |------>| Object Model |
Request +--------+ +--------------+
|(2) ^
V |
HTTP (3) +--------+ |
<--------| JSP |-------------+
Resposne +--------+
View
1. Request comes in, goes through controller (ActionServlet)
and is handled by an Action.
2. Action performs (optional) business logic, and either
creates response itself, or forwards request to JSP
(or servlet) to create the response.
3. JSP (servlet) generates response, and sends it back to
the client.
CONTENT OBJECT MODELS
---------------------
What I'm seeing is that the Action is responsible for creating
some "data" that is used later in generation of the resposne.
Oleg does this with BeanFactory (if I understand it correctly).
These are the types of "data" (let's call the Object Models or
simply OM) I see:
1. JavaBeans Heirarchical, Java
2. DOM Heirarchical, platform independent
3. JDBC Flat, Java, (RowSet)
Accessing these object models from a (struts-enabled) JSP
requires the use of notation below:
object model notation navigating object models
------------ -------- -------------------------
JavaBeans "dotted" user.address[0].city
JavaBeansX "extended-dotted" user.address{billing}.city
JDBC "dotted"? ?
DOM XPath user/address/city
JDBC (RowSet) and DOM are planned for 1.1:
http://jakarta.apache.org/struts/todo-1.1.html
In my thinking, I've been calling the "object models"
Content Object Models since the OMs really represent the
"content" (which we wanted to separate from logic as well as
from presentation).
PATTERNS
--------
The pattern I'm seeing for developing web applications is this:
1. Action generates Content Object Model (COM).
2. COM is transformed to presentation
In various frameworks, we see how this is done:
Framework OM Factories Presentation
--------- -- -------- ------------
Struts JavaBeans Action JSP/other
Cocoon2 DOM Generator XSLT
With this pattern, I can envision this pattern for a whole
web application:
Control
+--------+
| Action |-----------+
+--------+ |
V
+--------+ +--------+ +------------------+
| Object |<--| client |---->| Business Logic |
| Model | +--------+ | (possibly part |
+--------+ | of some component|
^ + framework, EJB) |
View | +------------------+
+-------------+
|JSP/Servlets |
+-------------+
\_______________/ \________/ \_______________________/
Web-based UI "Glue" code UI-less application
The utility of a "UI-less" app means you can deveop
applications on top of it, such as:
- Rich application
- Web-app
- command-line app
In our case, we're concerned with a web-apps, where:
- Client: presents a Facade (GOF pattern) into the
Business Logic
- Web-app only knows about the application through the
Client
- Client generates Content Object Models (COM)
- JSP/Servlets generate presentation based on COM
My guess is that large scale applications would require
some sort of abstraction along the lines presented above,
while smaller applications will tend to not use the "client"
and "object model" abstractions (and hence the model pattern
above collapses to just 3 parts: Control, View, Model
[business logic]).
QUESTIONS
---------
Having said all that, my questions are:
1. Are there other frameworks that fit into this Content Object Model
(COM) Pattern?
2. Is this COM Pattern a pattern that struts-users are using, and if
so, is it working for you?
3. If these ideas are not new or there are similar ideas, can someone
send me references to them?
Thanks,
Gidado
Re: Object Models and patterns in Struts
Posted by Ted Husted <hu...@apache.org>.
The client sends a request which is routed to an Action. The Action
confers with the business model and internal application resources to
select a response, and to generate any resources the response may need.
The resources are forwarded to the JSP view for rendering, often with
the help of internal application resources (shared with the actions).
Application resources include the Action Mappings and things like
connection pools. These resources are usually initialized from a
configuration file or servlet.
I mostly making a disinction between internal application resources,
like Action Mapping, and other portions of the business logic, which
might be shared with other applications. In a MVC environment, the
latter should not be accessed directly by the view.
Jonathan wrote:
>
> This is interesting, but Ted, how do I read this diagram??!
>
> ----- Original Message -----
> From: "Ted Husted" <hu...@apache.org>
> To: <st...@jakarta.apache.org>
> Sent: Friday, June 15, 2001 11:05 AM
> Subject: Re: Object Models and patterns in Struts
>
> > I'd say that this is a very clear expression of where most people are
> > trying to go right now.
> >
> > For my own work, I'd diagram the scenario as:
> >
> > Controller Model
> > App Layer Business Layer
> > HTTP +--------+ +------------------+
> > -------->| Action |<---->| Object Model |
> > Request +--------+ +------------------+
> > | ^
> > (Request Obj)| | +------------------+
> > | +-------<| App/Sess Objects | Controller
> > V v | - Action Mappings| App Layer
> > HTTP +--------+ | - Conn Pool |
> > <--------| JSP | | - et cetera |
> > Response +--------+ +------------------+
> > Web Layer ^
> > View |
> > [ Configuration ]
> >
> >
> > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > -- Custom Software ~ Technical Services.
> > -- Tel 716 737-3463.
> > -- http://www.husted.com/about/struts/
> >
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
Re: Object Models and patterns in Struts
Posted by Jonathan <ja...@i-2000.com>.
This is interesting, but Ted, how do I read this diagram??!
----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: <st...@jakarta.apache.org>
Sent: Friday, June 15, 2001 11:05 AM
Subject: Re: Object Models and patterns in Struts
> I'd say that this is a very clear expression of where most people are
> trying to go right now.
>
> For my own work, I'd diagram the scenario as:
>
> Controller Model
> App Layer Business Layer
> HTTP +--------+ +------------------+
> -------->| Action |<---->| Object Model |
> Request +--------+ +------------------+
> | ^
> (Request Obj)| | +------------------+
> | +-------<| App/Sess Objects | Controller
> V v | - Action Mappings| App Layer
> HTTP +--------+ | - Conn Pool |
> <--------| JSP | | - et cetera |
> Response +--------+ +------------------+
> Web Layer ^
> View |
> [ Configuration ]
>
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/
>
Re: Object Models and patterns in Struts
Posted by Ted Husted <hu...@apache.org>.
I'd say that this is a very clear expression of where most people are
trying to go right now.
For my own work, I'd diagram the scenario as:
Controller Model
App Layer Business Layer
HTTP +--------+ +------------------+
-------->| Action |<---->| Object Model |
Request +--------+ +------------------+
| ^
(Request Obj)| | +------------------+
| +-------<| App/Sess Objects | Controller
V v | - Action Mappings| App Layer
HTTP +--------+ | - Conn Pool |
<--------| JSP | | - et cetera |
Response +--------+ +------------------+
Web Layer ^
View |
[ Configuration ]
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
Re: Object Models and patterns in Struts
Posted by Oleg V Alexeev <go...@penza.net>.
Hello Gidado-Yisa,
It is clear and interesting.
Friday, June 15, 2001, 5:50:34 PM, you wrote:
... skipped
IGY> CONTENT OBJECT MODELS
IGY> ---------------------
IGY> What I'm seeing is that the Action is responsible for creating
IGY> some "data" that is used later in generation of the resposne.
IGY> Oleg does this with BeanFactory (if I understand it correctly).
IGY> These are the types of "data" (let's call the Object Models or
IGY> simply OM) I see:
I try to separate such standart action as data extraction from
workflow logic (Actions and Forwards). All we needs in some situations
extract data from external store and pass it to the View (JSP). I
am so lazy to do it in Actins that I create BeanFactory (define
databean, link to ready to use Factory and write declarations in
struts-config to work with some new data structure).
I work with RDBMS and use JDBCFactories to extract values from
this datasource. But BeanFactory intend to be used as kernel with some
count of Factories as plugins - you can write new plugin (Factory) for
your own datasource (XML files, for example) and use it to extract and
pass to display (JSP) some data from your datasource.
P.S. Now I trying to build RowSetFactory (thanks to Ted for samples)
to generate disconnected row sets, but day is so small...
--
Best regards,
Oleg mailto:gonza@penza.net