Re: General design question

2002-01-05 Thread Ted Husted

Assuming you mean "page" where the message says "site", you might want
to take a look at this:

http://husted.com/struts/resources/struts-simple.zip


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


"Kuntz Peter, NY" wrote:
> 
> Hi,
> 
> I have a general design question. Assume a web application that represents a
> use case over several sites. Each of these sites have form fields. Each site
> has a "Next" and "Previous" button except the last an the first which only
> have either a "Next" or a "Previous" button. Additionally there is a
> navigation bar where you can navigate to each site directly.
> 
> In general I would appreciate design recommendations for this kind of
> application. More specifically I have the following questions.
> 
> - Do I need to have an extention of the org.apache.struts.action.Action
> class for each site.
> - If so, how do I manage the handling of the different button events that
> are coming from a specific site.
> 
> Peter

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




General design question

2002-01-03 Thread Kuntz Peter, NY

Hi,

I have a general design question. Assume a web application that represents a
use case over several sites. Each of these sites have form fields. Each site
has a "Next" and "Previous" button except the last an the first which only
have either a "Next" or a "Previous" button. Additionally there is a
navigation bar where you can navigate to each site directly. 

In general I would appreciate design recommendations for this kind of
application. More specifically I have the following questions.

- Do I need to have an extention of the org.apache.struts.action.Action
class for each site.
- If so, how do I manage the handling of the different button events that
are coming from a specific site.

Peter
DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorised.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you

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




RE: PLEASE COMMENTS! Design question on very long lists... (a little bit OT)

2001-12-19 Thread Jon.Ridgway

Hi Thomas,

Try looking at the Sun Patterns. I believe there is a pattern known as a
Page by Page iterator
(http://java.sun.com/blueprints/patterns/j2ee_patterns/page_by_page_iterator
/index.html) that may help here. 


Jon.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: 18 December 2001 11:07
To: struts users mailing list
Subject: PLEASE COMMENTS! Design question on very long lists... (a little
bit OT)

Hi to all!

I strongly appreciate struts - it a very valuable tool to work with. So I
started to build a EIS-similar application with much DB-Access, business
code and so on... (try to work with Jonas EJB Server). But there arer some
design question and I do appreciate comments on these.
I have plenty of masks with DB-Access and CRUD-Operations. You can make a
choice based on the Primary Key (or something else). E.g. Articels have a
primary key, let's say WCF1001, REI1002, VAT-Code can be choosed, Zip-Code,
Customer Name and so on. On behalf of articels: I am using html:select and
build a selection list, but there are thousands of Primary Keys and you have
to send MANY bytes through the net building the mask (think of many
selection list in one mask!!).
What is in your opinion the "best" method the keep the selection lists
short? Can I resend/request the selection list, building new ones with the
next key? Is it possible to simulate the behavior of - let's say - of the
help index of Microsoft? Or is it convenient to build short lists with
beginning letters, then "climb down" to a next short list a.s.o??
Have I to switch to applets (with all its disadvantages...)? 

I am very eager to hear the opinion of you!

Thanks
Thomas 

>:-) As sceptical as one can be! (-:<



--
Get a free, personalised email address at http://another.com
TXT ALRT! Stop wasting money now. Send FREE, personalised txt
msgs to UK mobile phones from http://another.com

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




RE: PLEASE COMMENTS! Design question on very long lists... (a little bit OT)

2001-12-18 Thread Adriano Labate

Hi Thomas,

One suggestion for long lists is to display them in a popup window, say the
first twenties. Then you can paginate through the list items with the pager
taglib.

Adriano Labate


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 18, 2001 12:07 PM
To: struts users mailing list
Subject: PLEASE COMMENTS! Design question on very long lists... (a
little bit OT)


Hi to all!

I strongly appreciate struts - it a very valuable tool to work with. So I
started to build a EIS-similar application with much DB-Access, business
code and so on... (try to work with Jonas EJB Server). But there arer some
design question and I do appreciate comments on these.
I have plenty of masks with DB-Access and CRUD-Operations. You can make a
choice based on the Primary Key (or something else). E.g. Articels have a
primary key, let's say WCF1001, REI1002, VAT-Code can be choosed, Zip-Code,
Customer Name and so on. On behalf of articels: I am using html:select and
build a selection list, but there are thousands of Primary Keys and you have
to send MANY bytes through the net building the mask (think of many
selection list in one mask!!).
What is in your opinion the "best" method the keep the selection lists
short? Can I resend/request the selection list, building new ones with the
next key? Is it possible to simulate the behavior of - let's say - of the
help index of Microsoft? Or is it convenient to build short lists with
beginning letters, then "climb down" to a next short list a.s.o??
Have I to switch to applets (with all its disadvantages...)? 

I am very eager to hear the opinion of you!

Thanks
Thomas 

>:-) As sceptical as one can be! (-:<



--
Get a free, personalised email address at http://another.com
TXT ALRT! Stop wasting money now. Send FREE, personalised txt
msgs to UK mobile phones from http://another.com

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




Re: PLEASE COMMENTS! Design question on very long lists... (a little bit OT)

2001-12-18 Thread Rakesh

Why dont you try out expresso always helps when you have lots of
database stuff.

   --Rakesh
---

- Original Message -
From: <[EMAIL PROTECTED]>
To: "struts users mailing list" < [EMAIL PROTECTED] >
Sent: Tuesday, December 18, 2001 4:36 PM
Subject: PLEASE COMMENTS! Design question on very long lists... (a little
bit OT)


> Hi to all!
>
> I strongly appreciate struts - it a very valuable tool to work with. So I
started to build a EIS-similar application with much DB-Access, business
code and so on... (try to work with Jonas EJB Server). But there arer some
design question and I do appreciate comments on these.
> I have plenty of masks with DB-Access and CRUD-Operations. You can make a
choice based on the Primary Key (or something else). E.g. Articels have a
primary key, let's say WCF1001, REI1002, VAT-Code can be choosed, Zip-Code,
Customer Name and so on. On behalf of articels: I am using html:select and
build a selection list, but there are thousands of Primary Keys and you have
to send MANY bytes through the net building the mask (think of many
selection list in one mask!!).
> What is in your opinion the "best" method the keep the selection lists
short? Can I resend/request the selection list, building new ones with the
next key? Is it possible to simulate the behavior of - let's say - of the
help index of Microsoft? Or is it convenient to build short lists with
beginning letters, then "climb down" to a next short list a.s.o??
> Have I to switch to applets (with all its disadvantages...)?
>
> I am very eager to hear the opinion of you!
>
> Thanks
> Thomas
>
> >:-) As sceptical as one can be! (-:<
>
>
>
> --
> Get a free, personalised email address at http://another.com
> TXT ALRT! Stop wasting money now. Send FREE, personalised txt
> msgs to UK mobile phones from http://another.com
>






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




PLEASE COMMENTS! Design question on very long lists... (a little bit OT)

2001-12-18 Thread tw . richter

Hi to all!

I strongly appreciate struts - it a very valuable tool to work with. So I started to 
build a EIS-similar application with much DB-Access, business code and so on... (try 
to work with Jonas EJB Server). But there arer some design question and I do 
appreciate comments on these.
I have plenty of masks with DB-Access and CRUD-Operations. You can make a choice based 
on the Primary Key (or something else). E.g. Articels have a primary key, let's say 
WCF1001, REI1002, VAT-Code can be choosed, Zip-Code, Customer Name and so on. On 
behalf of articels: I am using html:select and build a selection list, but there are 
thousands of Primary Keys and you have to send MANY bytes through the net building the 
mask (think of many selection list in one mask!!).
What is in your opinion the "best" method the keep the selection lists short? Can I 
resend/request the selection list, building new ones with the next key? Is it possible 
to simulate the behavior of - let's say - of the help index of Microsoft? Or is it 
convenient to build short lists with  beginning letters, then "climb down" to a next 
short list a.s.o??
Have I to switch to applets (with all its disadvantages...)? 

I am very eager to hear the opinion of you!

Thanks
Thomas 

>:-) As sceptical as one can be! (-:<



--
Get a free, personalised email address at http://another.com
TXT ALRT! Stop wasting money now. Send FREE, personalised txt
msgs to UK mobile phones from http://another.com


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


RE: Struts Design question

2001-12-13 Thread Frank Lawlor

> > But my beans already contain the validation! Besides, performing the
> validation in the ActionForm is effectively tying business logic (data
> validation) to the web framework dontya think?
> 
> Well, I put data type and required field validation only in the bean.
> Validation that is more advanced than that, or based on business rules
> should be in your app server (if you have one), or in the 
> action object.
> 

While the response might be OK in a specific solution,
I think it is, in general, the wrong partitioning
of the validation issue.  The questioner was more on
the correct track.

To understand the more general case, consider the
case where a company has a database(s) and is
developing multiple applications, some may even
be developed by 3rd parties.

How do they look at the data validation issue?
Any DB administrator will tell you HE/SHE is 
responsible for the DB integrity, not the 
(irresponsible :-) app developers:

  - The data integrity issues need to be defined
by those who really understand and are 
responsible for them.  This includes business
data rules.

  - You don't want to replicate the validation in
multiple applications.

  - You don't want to have to change multiple 
applications and the database simultaneously
if there are changes.

  - etc., etc., etc.

Note that this doesn't mean ALL validation is 
associated with the database, just that which 
relates to the data model and the business integrity of
the data base.  If one app requires certain data,
another app different data, and the database doesn't
care, then it is the application responsibility.

To address this we defined a set of objects which
front the database.  They worry not only about
validation, but also things specific to the database
(e.g. query language), connection pooling, etc.

To work well with web applications these objects 
need to have a validation interface that lets you
provide the total set of new (string?) data and allows 
the object to return field-specific and object-general
error information.

This is also a good place to place the common
"business data rules" (not "application rules") so
that all applications use one common set, maintenance
is consistent, etc.

In VERY simple cases you could merge this with Action
classes, but generally there are significant differences,
no 1-1 relationship, etc.

Frank Lawlor
Athens Group, Inc.
(512) 345-0600 x151
Athens Group, an employee-owned consulting firm integrating technology
strategy and software solutions.


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




RE: Design question - option lists populated from db

2001-12-11 Thread Rob Parker

That is exactly what I needed! Thanks,

Rob

-Original Message-
From: Will Jaynes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 11, 2001 9:28 AM
To: Struts Users Mailing List
Subject: Re: Design question - option lists populated from db


Or, don't do the automatic validation.  Set validate='false' in the struts
config and then call the validate method explicitly from your action. If it
fails you still have the opportunity to fill the dropdown box and forward
back
to the jsp.

Will

- Original Message -
From: "Keith Bacon" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, December 11, 2001 11:32 AM
Subject: RE: Design question - option lists populated from db


> Hi Rob,
> Ah yes - my system is very simple. I'm not an advanced
> user - as a 'simpleton' I like to have all the
> validation in my business logic & never replicated
> elsewhere (but I can see the case for javascript
> validation in the browser, especially if genrated
> automatically).
>
> Putting stuff in the session keeps it but I hate that.
> Otherwise your form validate method has to add the
> collection to the request if it returns a validation
> error (yuk, yuk!).
>
> Or can you use  collection directly from your data supplying classes?
> Keith.
>
>
> --- Rob Parker <[EMAIL PROTECTED]> wrote:
> > Thanks - I am doing almost exactly the same thing,
> > but I am running into a
> > problem. If form level validation fails, the action
> > is not called and the
> > lists go out of scope in the jsp page. Are you
> > performing validation in the
> > form? How do you get around this problem? Thanks for
> > taking the time to put
> > this together,
> >
> > Rob
> >
> > -Original Message-
> > From: Keith Bacon
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, December 11, 2001 7:34 AM
> > To: Struts Users Mailing List
> > Subject: Re: Design question - option lists
> > populated from db
> >
> >
> > Rob,
> > Hope this helps - it's from a 'working' system. Ask
> > for more explanations - or better still beat your
> > way
> > thru the struts docs. No escaping it takes time to
> > get
> > your head around this stuff - but it's brill once
> > you
> > get the hang of it!
> > Keith.
> > PS - My code hasnon-standard msg logging & the text
> > in
> > the select ox isn't internationalised (yet!).
> > ==
> > 1 - In the JSP.
> > =
> >  > property="selectedReviewDisplayTypeOption" >
> >  > collection="reviewDisplayTypeOptions"
> > property="option"
> > labelProperty="label" />
> >  
> > ===
> > 2 - In your action class. Do this every time you
> > forward to the jsp taht displays the select/options.
> > In your case you need to pass parms to this method,
> > my
> > example displays the same list for all users.
> > ===
> > request.setAttribute("reviewDisplayTypeOptions",
> > ReviewDisplayTypeOption.getDisplayTypeOptions());
> > }
> > 
> > 3 - Instance of this class gets added to the
> > request.
> > This class also has the utility method called in 2)
> > above. In your case that method should be in a class
> > representing the data - or left here & changed to
> > get
> > the data from the database (my example has the data
> > hard coded).
> > =
> > package biff1;
> >
> > import java.util.ArrayList;
> >
> >   /**
> >   * The option object
> >   * plus static methods to return the array
> > list of the real data.
> >   * dodgy having list underneath the single
> > list item object -qq?
> >   */
> > public final class ReviewDisplayTypeOption  extends
> > Object {
> > private final static String THIS_NAME =
> > "ReviewDisplayTypeOption";
> >
> > private String dtOption = null;
> > private String dtLabel  = null;
> >
> > ReviewDisplayTypeOption(String  dtOption, String
> > dtLabel) {
> > this.dtOption = dtOption;
> > this.dtLabel  = dtLabel;
> > }
> >
> > public String getOption() {
> > return dtOption;
> > }
> > // needed qq?
> > public void setOption(String dtOpt

Re: Design question - option lists populated from db

2001-12-11 Thread Will Jaynes

Or, don't do the automatic validation.  Set validate='false' in the struts
config and then call the validate method explicitly from your action. If it
fails you still have the opportunity to fill the dropdown box and forward back
to the jsp.

Will

- Original Message -
From: "Keith Bacon" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, December 11, 2001 11:32 AM
Subject: RE: Design question - option lists populated from db


> Hi Rob,
> Ah yes - my system is very simple. I'm not an advanced
> user - as a 'simpleton' I like to have all the
> validation in my business logic & never replicated
> elsewhere (but I can see the case for javascript
> validation in the browser, especially if genrated
> automatically).
>
> Putting stuff in the session keeps it but I hate that.
> Otherwise your form validate method has to add the
> collection to the request if it returns a validation
> error (yuk, yuk!).
>
> Or can you use  collection directly from your data supplying classes?
> Keith.
>
>
> --- Rob Parker <[EMAIL PROTECTED]> wrote:
> > Thanks - I am doing almost exactly the same thing,
> > but I am running into a
> > problem. If form level validation fails, the action
> > is not called and the
> > lists go out of scope in the jsp page. Are you
> > performing validation in the
> > form? How do you get around this problem? Thanks for
> > taking the time to put
> > this together,
> >
> > Rob
> >
> > -Original Message-
> > From: Keith Bacon
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, December 11, 2001 7:34 AM
> > To: Struts Users Mailing List
> > Subject: Re: Design question - option lists
> > populated from db
> >
> >
> > Rob,
> > Hope this helps - it's from a 'working' system. Ask
> > for more explanations - or better still beat your
> > way
> > thru the struts docs. No escaping it takes time to
> > get
> > your head around this stuff - but it's brill once
> > you
> > get the hang of it!
> > Keith.
> > PS - My code hasnon-standard msg logging & the text
> > in
> > the select ox isn't internationalised (yet!).
> > ==
> > 1 - In the JSP.
> > =
> >  > property="selectedReviewDisplayTypeOption" >
> >  > collection="reviewDisplayTypeOptions"
> > property="option"
> > labelProperty="label" />
> >  
> > ===
> > 2 - In your action class. Do this every time you
> > forward to the jsp taht displays the select/options.
> > In your case you need to pass parms to this method,
> > my
> > example displays the same list for all users.
> > ===
> > request.setAttribute("reviewDisplayTypeOptions",
> > ReviewDisplayTypeOption.getDisplayTypeOptions());
> > }
> > 
> > 3 - Instance of this class gets added to the
> > request.
> > This class also has the utility method called in 2)
> > above. In your case that method should be in a class
> > representing the data - or left here & changed to
> > get
> > the data from the database (my example has the data
> > hard coded).
> > =
> > package biff1;
> >
> > import java.util.ArrayList;
> >
> >   /**
> >   * The option object
> >   * plus static methods to return the array
> > list of the real data.
> >   * dodgy having list underneath the single
> > list item object -qq?
> >   */
> > public final class ReviewDisplayTypeOption  extends
> > Object {
> > private final static String THIS_NAME =
> > "ReviewDisplayTypeOption";
> >
> > private String dtOption = null;
> > private String dtLabel  = null;
> >
> > ReviewDisplayTypeOption(String  dtOption, String
> > dtLabel) {
> > this.dtOption = dtOption;
> > this.dtLabel  = dtLabel;
> > }
> >
> > public String getOption() {
> > return dtOption;
> > }
> > // needed qq?
> > public void setOption(String dtOption) {
> > this.dtOption = dtOption;
> > }
> > public String getLabel() {
> > return dtLabel;
> > }
> > // needed qq?
> > public void setLabel(String dtLabel) {
> > this.dtLabel = dtLabel;
> > }
>

Re: Design question - option lists populated from db

2001-12-11 Thread Andy Noble

Rob,

When I looked into this, I realised that the problem you describe would
occur. Given that it occurs, and the list goes out of scope, you've got to
either requery the database or store the initial results in the session. I
decided to store user specific results in the session - but I'm building a
request-based app and hate putting data in the session.

I was considering giving session scoped attributes a limited lifetime (don't
know how yet exactly), where any session scoped attribute over 5 mins old
gets cleared out. I guess I may need to write a thread that scans session
scoped attributes and dereferences them, in a similar way to garbage
collection.

I've written a little LookupManager which stores application wide lists in
application scope and only retrieves the data from the database if its not
been previously retrieved, so I guess this could be extended to somehow
manage session scoped lists also.

I'll be watching responses to your question for more ideas.

Andy


- Original Message -
From: Rob Parker <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Sent: Tuesday, December 11, 2001 3:44 PM
Subject: RE: Design question - option lists populated from db


> Thanks - I am doing almost exactly the same thing, but I am running into a
> problem. If form level validation fails, the action is not called and the
> lists go out of scope in the jsp page. Are you performing validation in
the
> form? How do you get around this problem? Thanks for taking the time to
put
> this together,
>
> Rob
>
> -Original Message-
> From: Keith Bacon [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 11, 2001 7:34 AM
> To: Struts Users Mailing List
> Subject: Re: Design question - option lists populated from db
>
>
> Rob,
> Hope this helps - it's from a 'working' system. Ask
> for more explanations - or better still beat your way
> thru the struts docs. No escaping it takes time to get
> your head around this stuff - but it's brill once you
> get the hang of it!
> Keith.
> PS - My code hasnon-standard msg logging & the text in
> the select ox isn't internationalised (yet!).
> ==
> 1 - In the JSP.
> =
>  property="selectedReviewDisplayTypeOption" >
>  collection="reviewDisplayTypeOptions"
> property="option"
> labelProperty="label" />
>  
> ===
> 2 - In your action class. Do this every time you
> forward to the jsp taht displays the select/options.
> In your case you need to pass parms to this method, my
> example displays the same list for all users.
> ===
> request.setAttribute("reviewDisplayTypeOptions",
> ReviewDisplayTypeOption.getDisplayTypeOptions());
> }
> 
> 3 - Instance of this class gets added to the request.
> This class also has the utility method called in 2)
> above. In your case that method should be in a class
> representing the data - or left here & changed to get
> the data from the database (my example has the data
> hard coded).
> =
> package biff1;
>
> import java.util.ArrayList;
>
>   /**
>   * The option object
>   * plus static methods to return the array
> list of the real data.
>   * dodgy having list underneath the single
> list item object -qq?
>   */
> public final class ReviewDisplayTypeOption  extends
> Object {
> private final static String THIS_NAME =
> "ReviewDisplayTypeOption";
>
> private String dtOption = null;
> private String dtLabel  = null;
>
> ReviewDisplayTypeOption(String  dtOption, String
> dtLabel) {
> this.dtOption = dtOption;
> this.dtLabel  = dtLabel;
> }
>
> public String getOption() {
> return dtOption;
> }
> // needed qq?
> public void setOption(String dtOption) {
> this.dtOption = dtOption;
> }
> public String getLabel() {
> return dtLabel;
> }
> // needed qq?
> public void setLabel(String dtLabel) {
> this.dtLabel = dtLabel;
> }
>
> static private void dbmi(String message) {
> ZUtils.writeLog(THIS_NAME, ZUtils.INFO_LEVEL,
> message);
> }
> static private void dbmd(String message) {
> ZUtils.writeLog(THIS_NAME, ZUtils.DEBUG_LEVEL,
> message);
> }
> static private void dbmw(String message) {
> ZUtils.writeLog(THIS_NAME, ZUtils.WARNING_LEVEL,
> message);
> }
>
> static private ArrayList ReviewDisplayTypeOptions =
> null;
> static public ArrayList getReviewDisplayTypeOptions()
> {
> if (ReviewDisplayTypeOptions ==

RE: Design question - option lists populated from db

2001-12-11 Thread Keith Bacon

Hi Rob,
Ah yes - my system is very simple. I'm not an advanced
user - as a 'simpleton' I like to have all the
validation in my business logic & never replicated
elsewhere (but I can see the case for javascript
validation in the browser, especially if genrated
automatically).

Putting stuff in the session keeps it but I hate that.
Otherwise your form validate method has to add the
collection to the request if it returns a validation
error (yuk, yuk!).

Or can you use  wrote:
> Thanks - I am doing almost exactly the same thing,
> but I am running into a
> problem. If form level validation fails, the action
> is not called and the
> lists go out of scope in the jsp page. Are you
> performing validation in the
> form? How do you get around this problem? Thanks for
> taking the time to put
> this together,
> 
> Rob
> 
> -Original Message-
> From: Keith Bacon
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 11, 2001 7:34 AM
> To: Struts Users Mailing List
> Subject: Re: Design question - option lists
> populated from db
> 
> 
> Rob,
> Hope this helps - it's from a 'working' system. Ask
> for more explanations - or better still beat your
> way
> thru the struts docs. No escaping it takes time to
> get
> your head around this stuff - but it's brill once
> you
> get the hang of it!
> Keith.
> PS - My code hasnon-standard msg logging & the text
> in
> the select ox isn't internationalised (yet!).
> ==
> 1 - In the JSP.
> =
>  property="selectedReviewDisplayTypeOption" >
>collection="reviewDisplayTypeOptions"
>   property="option"
>   labelProperty="label" />
>    
> ===
> 2 - In your action class. Do this every time you
> forward to the jsp taht displays the select/options.
> In your case you need to pass parms to this method,
> my
> example displays the same list for all users.
> ===
> request.setAttribute("reviewDisplayTypeOptions",
> ReviewDisplayTypeOption.getDisplayTypeOptions());
>   }
> 
> 3 - Instance of this class gets added to the
> request.
> This class also has the utility method called in 2)
> above. In your case that method should be in a class
> representing the data - or left here & changed to
> get
> the data from the database (my example has the data
> hard coded).
> =
> package biff1;
> 
>   import java.util.ArrayList;
> 
>   /**
>   * The option object
>   * plus static methods to return the array
> list of the real data.
>   * dodgy having list underneath the single
> list item object -qq?
>   */
> public final class ReviewDisplayTypeOption  extends
> Object {
>   private final static String THIS_NAME =
> "ReviewDisplayTypeOption";
> 
>   private String dtOption = null;
>   private String dtLabel  = null;
> 
>   ReviewDisplayTypeOption(String  dtOption, String
> dtLabel) {
>   this.dtOption = dtOption;
>   this.dtLabel  = dtLabel;
>   }
> 
>   public String getOption() {
>   return dtOption;
>   }
>   // needed qq?
>   public void setOption(String dtOption) {
>   this.dtOption = dtOption;
>   }
>   public String getLabel() {
>   return dtLabel;
>   }
>   // needed qq?
>   public void setLabel(String dtLabel) {
>   this.dtLabel = dtLabel;
>   }
> 
>   static private void dbmi(String message) {
>   ZUtils.writeLog(THIS_NAME, ZUtils.INFO_LEVEL,
> message);
>   }
>   static private void dbmd(String message) {
>   ZUtils.writeLog(THIS_NAME, ZUtils.DEBUG_LEVEL,
> message);
>   }
>   static private void dbmw(String message) {
>   ZUtils.writeLog(THIS_NAME, ZUtils.WARNING_LEVEL,
> message);
>   }
> 
>   static private ArrayList ReviewDisplayTypeOptions =
> null;
>   static public ArrayList
> getReviewDisplayTypeOptions()
> {
>   if (ReviewDisplayTypeOptions == null) {
>   ReviewDisplayTypeOptions = new ArrayList(12);
>   ReviewDisplayTypeOptions.add(new
> ReviewDisplayTypeOption("excludeReviews", "Exclude
> Reviews"));
> 

RE: Design question - option lists populated from db

2001-12-11 Thread Rob Parker

Thanks - I am doing almost exactly the same thing, but I am running into a
problem. If form level validation fails, the action is not called and the
lists go out of scope in the jsp page. Are you performing validation in the
form? How do you get around this problem? Thanks for taking the time to put
this together,

Rob

-Original Message-
From: Keith Bacon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 11, 2001 7:34 AM
To: Struts Users Mailing List
Subject: Re: Design question - option lists populated from db


Rob,
Hope this helps - it's from a 'working' system. Ask
for more explanations - or better still beat your way
thru the struts docs. No escaping it takes time to get
your head around this stuff - but it's brill once you
get the hang of it!
Keith.
PS - My code hasnon-standard msg logging & the text in
the select ox isn't internationalised (yet!).
==
1 - In the JSP.
=


 
===
2 - In your action class. Do this every time you
forward to the jsp taht displays the select/options.
In your case you need to pass parms to this method, my
example displays the same list for all users.
===
request.setAttribute("reviewDisplayTypeOptions",
ReviewDisplayTypeOption.getDisplayTypeOptions());
}

3 - Instance of this class gets added to the request.
This class also has the utility method called in 2)
above. In your case that method should be in a class
representing the data - or left here & changed to get
the data from the database (my example has the data
hard coded).
=
package biff1;

import java.util.ArrayList;

  /**
  * The option object
  * plus static methods to return the array
list of the real data.
  * dodgy having list underneath the single
list item object -qq?
  */
public final class ReviewDisplayTypeOption  extends
Object {
private final static String THIS_NAME =
"ReviewDisplayTypeOption";

private String dtOption = null;
private String dtLabel  = null;

ReviewDisplayTypeOption(String  dtOption, String
dtLabel) {
this.dtOption = dtOption;
this.dtLabel  = dtLabel;
}

public String getOption() {
return dtOption;
}
// needed qq?
public void setOption(String dtOption) {
this.dtOption = dtOption;
}
public String getLabel() {
return dtLabel;
}
// needed qq?
public void setLabel(String dtLabel) {
this.dtLabel = dtLabel;
}

static private void dbmi(String message) {
ZUtils.writeLog(THIS_NAME, ZUtils.INFO_LEVEL,
message);
}
static private void dbmd(String message) {
ZUtils.writeLog(THIS_NAME, ZUtils.DEBUG_LEVEL,
message);
}
static private void dbmw(String message) {
ZUtils.writeLog(THIS_NAME, ZUtils.WARNING_LEVEL,
message);
}

static private ArrayList ReviewDisplayTypeOptions =
null;
static public ArrayList getReviewDisplayTypeOptions()
{
if (ReviewDisplayTypeOptions == null) {
ReviewDisplayTypeOptions = new ArrayList(12);
ReviewDisplayTypeOptions.add(new
ReviewDisplayTypeOption("excludeReviews", "Exclude
Reviews"));
ReviewDisplayTypeOptions.add(new
ReviewDisplayTypeOption("shortReviews"  , "Short
Reviews"));
ReviewDisplayTypeOptions.add(new
ReviewDisplayTypeOption("fullReviews"   , "Full
Reviews"));
}
return ReviewDisplayTypeOptions;
}
static public String getDefaultOption() {
String sss =
((ReviewDisplayTypeOption)getReviewDisplayTypeOptions().get(0)).getOption();
dbmd("getDefaultOption: returning:"+ sss);
return sss;
}
} // end Class ReviewDisplayTypeOption
=


--- Rob Parker <[EMAIL PROTECTED]> wrote:
> I need to create some  option lists that are
> populated from a
> database. The call to the database will pass in the
> current user's id to
> create customized option lists. Where is the best
> place to create these
> option lists? If I create the lists in the user
> form, how can I pass in the
> user id? How would I handle SQLExceptions in the
> user form? If I create the
> lists in the action, how can I avoid having them go
> out of scope when user
> form validation fails? (I do not want to add them to
> the session) Thanks in
&

Re: Design question - option lists populated from db

2001-12-11 Thread Keith Bacon

Rob,
Hope this helps - it's from a 'working' system. Ask
for more explanations - or better still beat your way
thru the struts docs. No escaping it takes time to get
your head around this stuff - but it's brill once you
get the hang of it!
Keith.
PS - My code hasnon-standard msg logging & the text in
the select ox isn't internationalised (yet!).
==
1 - In the JSP.
=


 
===
2 - In your action class. Do this every time you
forward to the jsp taht displays the select/options.
In your case you need to pass parms to this method, my
example displays the same list for all users. 
=== 
request.setAttribute("reviewDisplayTypeOptions",
ReviewDisplayTypeOption.getDisplayTypeOptions());
}

3 - Instance of this class gets added to the request.
This class also has the utility method called in 2)
above. In your case that method should be in a class
representing the data - or left here & changed to get
the data from the database (my example has the data
hard coded). 
=
package biff1;

import java.util.ArrayList;

  /**
  * The option object
  * plus static methods to return the array
list of the real data.
  * dodgy having list underneath the single
list item object -qq?
  */
public final class ReviewDisplayTypeOption  extends
Object {
private final static String THIS_NAME =
"ReviewDisplayTypeOption";

private String dtOption = null;
private String dtLabel  = null;

ReviewDisplayTypeOption(String  dtOption, String
dtLabel) {
this.dtOption = dtOption;
this.dtLabel  = dtLabel;
}

public String getOption() {
return dtOption;
}
// needed qq?
public void setOption(String dtOption) {
this.dtOption = dtOption;
}
public String getLabel() {
return dtLabel;
}
// needed qq?
public void setLabel(String dtLabel) {
this.dtLabel = dtLabel;
}

static private void dbmi(String message) {
ZUtils.writeLog(THIS_NAME, ZUtils.INFO_LEVEL, 
message);
}
static private void dbmd(String message) {
ZUtils.writeLog(THIS_NAME, ZUtils.DEBUG_LEVEL, 
message);
}
static private void dbmw(String message) {
ZUtils.writeLog(THIS_NAME, ZUtils.WARNING_LEVEL, 
message);
}

static private ArrayList ReviewDisplayTypeOptions =
null;
static public ArrayList getReviewDisplayTypeOptions()
{
if (ReviewDisplayTypeOptions == null) {
ReviewDisplayTypeOptions = new ArrayList(12);
ReviewDisplayTypeOptions.add(new
ReviewDisplayTypeOption("excludeReviews", "Exclude
Reviews"));
ReviewDisplayTypeOptions.add(new
ReviewDisplayTypeOption("shortReviews"  , "Short
Reviews"));
ReviewDisplayTypeOptions.add(new
ReviewDisplayTypeOption("fullReviews"   , "Full
Reviews"));
}
return ReviewDisplayTypeOptions;
}
static public String getDefaultOption() {
String sss =
((ReviewDisplayTypeOption)getReviewDisplayTypeOptions().get(0)).getOption();
dbmd("getDefaultOption: returning:"+ sss);
return sss;
}
} // end Class ReviewDisplayTypeOption
=


--- Rob Parker <[EMAIL PROTECTED]> wrote:
> I need to create some  option lists that are
> populated from a
> database. The call to the database will pass in the
> current user's id to
> create customized option lists. Where is the best
> place to create these
> option lists? If I create the lists in the user
> form, how can I pass in the
> user id? How would I handle SQLExceptions in the
> user form? If I create the
> lists in the action, how can I avoid having them go
> out of scope when user
> form validation fails? (I do not want to add them to
> the session) Thanks in
> advance for any help - I am really stuck with this.
> 
> Rob
> 
> 
> --
> To unsubscribe, e-mail:  
> 
> For additional commands, e-mail:
> 
> 


__
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

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




Design question - option lists populated from db

2001-12-11 Thread Rob Parker

I need to create some  option lists that are populated from a
database. The call to the database will pass in the current user's id to
create customized option lists. Where is the best place to create these
option lists? If I create the lists in the user form, how can I pass in the
user id? How would I handle SQLExceptions in the user form? If I create the
lists in the action, how can I avoid having them go out of scope when user
form validation fails? (I do not want to add them to the session) Thanks in
advance for any help - I am really stuck with this.

Rob


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




Re: Struts Design question

2001-12-10 Thread Jeff_Mychasiw



If I could jump in and ask a question,

I have searched this list for a best practice regarding the relationship between
  formbeans, value objects, and formatting/cleaning data.

I found the discussion between Jon and Ted interesting.

I am gearing up to try and use struts in my current project so I would like to
  clear on thing up.

We use value objects (with int's,floats, ect)  from Session EJB's.

In addition to this, we populate the editable text boxes with formatted values
  such as currency (with comma's), phone number with brackets , dates ,and
  so on.

So the data going into the page get's formatted and upon submit must get cleaned
  and then validated.

 I was under the impression that  this would be done in the FormBean in a couple
  of different ways.

One is to store the  property as it native type (int), and do the formatting in
  the standard  String getXXX() and clean the data in the standard
  setXXX(String xxx).

The second is to create a standard form bean but supply an extra set of methods
  to deal with the special cases, such as: int getIntXXX() ect.

Am I off base with this line of thinking?





Jon Wall wrote:
>  I'm
> assuming, then, that the ActionForm performs another
> function that I hadn't thought about - converting the
> String and boolean props that you're bringing in on
> the web to the navtive structure used by the backend.
> Is this true?  So what you're telling me is...I not
> only need to create an ActionForm class for each of my
> many components (100+) that actually implements each
> of the public methods, but for each of the non
> String/boolean properties I need to make a sort of
> formatter method.

The ActionForm is really about buffering. It gives the HTML controls
persistance, until the data can be validated and/of converted to your
native structures. What happens when someone tries to toss "47a" at an
Integer property? HTTP is a hostile, uncontrolled environment, and the
ActionForms are designed to compensate for that.

But keep in mind that ActionForms are just for HTML Form input. They are
not expected to be used as anything but buffers for the html form tags.
You do not have to use them to retrieve widgets, just to send widgets
data they need to store.

Once the ActionForm is validated, the BeanUtils can be a very handy way
to copy the data over to your native beans. Usually, you just need to
define your ActionForm properties to match your native bean property
names. The problem is, you need a place to stand if the data fails
validation, and can't be transferred to your native beans. There lies
the rub.












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




Re: Struts Design question

2001-12-10 Thread Ted Husted

Ted Husted wrote:
> If you find something that works better for you, be sure to report back.
> We aren't jealous ;-) Adopt and adapt.

Or, if you find one I haven't listed here, be sure to let me know. 

http://husted.com/struts/links.htm#mvc/frameworks


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

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




Re: Struts Design question

2001-12-10 Thread Ted Husted

Jon Wall wrote:
> 1.  The String/boolean requirement.  Everything I'd
> tested happened to be String or boolean, but Ted
> pointed out this wouldn't work for nested tags.  I'm
> assuming, then, that the ActionForm performs another
> function that I hadn't thought about - converting the
> String and boolean props that you're bringing in on
> the web to the navtive structure used by the backend.
> Is this true?  So what you're telling me is...I not
> only need to create an ActionForm class for each of my
> many components (100+) that actually implements each
> of the public methods, but for each of the non
> String/boolean properties I need to make a sort of
> formatter method.  

The ActionForm is really about buffering. It gives the HTML controls
persistance, until the data can be validated and/of converted to your
native structures. What happens when someone tries to toss "47a" at an
Integer property? HTTP is a hostile, uncontrolled environment, and the
ActionForms are designed to compensate for that. 

But keep in mind that ActionForms are just for HTML Form input. They are
not expected to be used as anything but buffers for the html form tags.
You do not have to use them to retrieve widgets, just to send widgets
data they need to store.

Once the ActionForm is validated, the BeanUtils can be a very handy way
to copy the data over to your native beans. Usually, you just need to
define your ActionForm properties to match your native bean property
names. The problem is, you need a place to stand if the data fails
validation, and can't be transferred to your native beans. There lies
the rub.


> And keep up with this process with
> every new component, and more difficult yet keep up
> with every new method on existing components.  Eeek.
> I know that I can automate this kind of thing...but it
> might be enough to keep me from using this framework.
> I understand the ROI theory and all that, but the
> unfortunate reality is that my development schedule is
> way too tight to take time out to work on something
> like this.  Am I grasping if I ask if there's any
> generic tools out there to do something like this?

If you find something that works better for you, be sure to report back.
We aren't jealous ;-) Adopt and adapt.



> 2.  This also explains my original troubles with my
> Save action I think, because I was trying to nest my
> components.  The real issue is that i need to call
> WidgetForm.setWidget() to initialize my widget's
> properties to what is already in the database before
> Struts autopopulates the widget properties using
> values from the form.  My new understanding of the
> Struts paradigm (please correct me if I'm wrong) is
> that the ActionForm shouldn't nest the components, but
> rather should mirror it and not contain the widget at
> all.  Let Struts autopopulate the ActionForm, and then
> use BeanUtils.populate() to copy the info over.

In practice, most pre-existing components are not suited for use as a
buffer for HTML controls, which is what the ActionForms do. If a
component is suited as a buffer for a HTML control, then there is no
reason not to nest it.

A good candidate for a HTML buffer uses a String or boolean for storage,
and can store invalid input before committing it to your model.
Generally, most components are designed to do exactly the opposite --
accept or reject input, period.


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

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




Re: Struts Design question

2001-12-10 Thread Jon Wall

Hi Ted -

Thanks for the input.  A light went on when I read
this...I'd initially wanted to just include my
existing components in a thin "composition" ActionForm
class - in other words, if I had a "Widget" component,
I'd create a WidgetForm class with getWidget() and
setWidget(), then my form would use the nested syntax,
ie "widget.prop1", "widget.prop2".  This was working
great for the Edit and Add actions, but was probably
the cause for my problems with the Save action.  I'm
realizing a couple of problems with this method...

1.  The String/boolean requirement.  Everything I'd
tested happened to be String or boolean, but Ted
pointed out this wouldn't work for nested tags.  I'm
assuming, then, that the ActionForm performs another
function that I hadn't thought about - converting the
String and boolean props that you're bringing in on
the web to the navtive structure used by the backend. 
Is this true?  So what you're telling me is...I not
only need to create an ActionForm class for each of my
many components (100+) that actually implements each
of the public methods, but for each of the non
String/boolean properties I need to make a sort of
formatter method.  And keep up with this process with
every new component, and more difficult yet keep up
with every new method on existing components.  Eeek. 
I know that I can automate this kind of thing...but it
might be enough to keep me from using this framework. 
I understand the ROI theory and all that, but the
unfortunate reality is that my development schedule is
way too tight to take time out to work on something
like this.  Am I grasping if I ask if there's any
generic tools out there to do something like this?  

2.  This also explains my original troubles with my
Save action I think, because I was trying to nest my
components.  The real issue is that i need to call
WidgetForm.setWidget() to initialize my widget's
properties to what is already in the database before
Struts autopopulates the widget properties using
values from the form.  My new understanding of the
Struts paradigm (please correct me if I'm wrong) is
that the ActionForm shouldn't nest the components, but
rather should mirror it and not contain the widget at
all.  Let Struts autopopulate the ActionForm, and then
use BeanUtils.populate() to copy the info over.  



thanks again for any help...
-jon



--- Ted Husted <[EMAIL PROTECTED]> wrote:
> Jon Wall wrote:
> > 
> > I've been lurking on this list for a while, and I
> > finally have time to look hard at Struts for a web
> > application that I'm working on. I have a coupla
> > questions.. 1. This first question I found
> reference
> > to in the archives
> >
>
(http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18281.html)
> > but couldn't find an answer.
> 
> We tried making the ActionForm an interface in the
> first place, but, in
> practice, there were simply too many side effects. 
> 
>
http://www.mail-archive.com/struts-dev%40jakarta.apache.org/msg03590.html
> 
>
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg08070.html
> 
> If your JavaBean only uses String and boolean
> properties, and doesn't
> make immediate state changes to your model, you can
> nest it and use the
> dotted syntax. Otherwise, it's a wild goose chase.
> 
> 
> > In the application I'm
> > working on the business logic is already written
> and
> > is being added to by another team (it's supporting
> > other applications besides the web). So I've got a
> > whole slew of JavaBeans (100+) already written for
> me,
> > but now I'm facing the task of wrapping them in
> > ActionForm subclasses, cursing under my breath
> that it
> > isn't an interface. I understand that the purpose
> of
> > the ActionForm is as a buffer..perform validation
> and
> > all that. But my beans already contain the
> validation!
> > Besides, performing the validation in the
> ActionForm
> > is effectively tying business logic (data
> validation)
> > to the web framework dontya think?
> 
> It's really more about correction than validation.
> The validate method
> can wrap methods from the business layer, or the
> Action can do that
> instead and then return the ActionForm itself. But
> the main thing is
> that most existing beans expect native types that
> can't be properly
> represented by a HTML control.
> 
> Your beans may contain validation, but can they
> return the invalid input
> to the user for correction? That's what ActionForms
> are for. To buffer
> data so it ~can be~ validated, and returned for
> correction if it is not.
> 
> So, you take the data from the ActionForm, and
> present it to your bean.
> If your bean rejects it, you use the ActionForm to
> ferry the whole
> she-bang back to the user, so they can fix it and
> try again.
> 
> The ActionForm also serves as firewall, since the
> autopopulation
> mechanism can be used to affect any public method on
> your JavaBean, not
> just the ones you put on the form. This is
> exploitable by a hostile
> user.
> 
> 

Re: Struts Design question

2001-12-10 Thread Edward Q. Bridges

i believe that you could subclass ActionServlet and implement the
processPreprocess method.  this is called before processActionForm and
processPopulate.


On Fri, 7 Dec 2001 13:08:10 -0800 (PST), Jon Wall wrote:

.
.
.
>having a problem with the Save action. The issue is
>that I need to retrieve the object from the datastore
>(using the id) *before* the ActionForm is populated
>with the request parameters. What I'd like is to have



 ed.q.bridges
 tel. 089-368179.552
 fax 089-368179.79
 osterwaldstraße 10
 (haus F eingang 21)
 80805 münchen





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




Re: Struts Design question - followup

2001-12-07 Thread Matt Goodall

On Fri, 2001-12-07 at 22:37, Jon Wall wrote:
> Hi Brian - 
> 
> Thanks for the responses.  Some more information and
> clarification...
> 
> > Well, I put data type and required field validation
> > only in the bean.
> 
> I'm doing this type of validation on the client-side
> in JavaScript already.  I prefer to keep it here as
> it's not too much work and it's much faster than doing
> it server side.  

And what happens when the user has JavaScript turned off?

You need to perform the validation server-side too. Client-side
validation should only really be used to improve usability by avoiding a
trip to the server (as you point out).

Cheers, Matt


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




Re: Struts Design question

2001-12-07 Thread Ted Husted

Jon Wall wrote:
> 
> I've been lurking on this list for a while, and I
> finally have time to look hard at Struts for a web
> application that I'm working on. I have a coupla
> questions.. 1. This first question I found reference
> to in the archives
> (http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18281.html)
> but couldn't find an answer.

We tried making the ActionForm an interface in the first place, but, in
practice, there were simply too many side effects. 

http://www.mail-archive.com/struts-dev%40jakarta.apache.org/msg03590.html

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg08070.html

If your JavaBean only uses String and boolean properties, and doesn't
make immediate state changes to your model, you can nest it and use the
dotted syntax. Otherwise, it's a wild goose chase.


> In the application I'm
> working on the business logic is already written and
> is being added to by another team (it's supporting
> other applications besides the web). So I've got a
> whole slew of JavaBeans (100+) already written for me,
> but now I'm facing the task of wrapping them in
> ActionForm subclasses, cursing under my breath that it
> isn't an interface. I understand that the purpose of
> the ActionForm is as a buffer..perform validation and
> all that. But my beans already contain the validation!
> Besides, performing the validation in the ActionForm
> is effectively tying business logic (data validation)
> to the web framework dontya think?

It's really more about correction than validation. The validate method
can wrap methods from the business layer, or the Action can do that
instead and then return the ActionForm itself. But the main thing is
that most existing beans expect native types that can't be properly
represented by a HTML control.

Your beans may contain validation, but can they return the invalid input
to the user for correction? That's what ActionForms are for. To buffer
data so it ~can be~ validated, and returned for correction if it is not.

So, you take the data from the ActionForm, and present it to your bean.
If your bean rejects it, you use the ActionForm to ferry the whole
she-bang back to the user, so they can fix it and try again.

The ActionForm also serves as firewall, since the autopopulation
mechanism can be used to affect any public method on your JavaBean, not
just the ones you put on the form. This is exploitable by a hostile
user.


> Rules such as no
> invoice numbers under 1000 (Ted's example) should be
> handled by the business logic, and given my situation
> (probably a common one), this logic needs to be shared
> between applications. I can't go into the server
> system and fit ActionForm into the class heirarchy,
> but I sure could have thrown an interface in there.

It should not be in your heirarchy, but used to transfer data *to* your
heirarchy. One good way to do this is to match the ActionForm properties
to the properties on your JavaBeans, and use the reflection methods in
BeanUtils to punch it over. If you put describe and populate together,
you can populate just about anything from just about anything.



> Input on this is appreciated. 2. This has to have come
> up before, but I couldn't find any references. All of
> my JavaBeans map to persistent components, all of
> which have id's. I've written some actions to display
> lists of these components and the like and everything
> works great. I also started to try the Add/Edit/Save
> pattern, which occurs everywhere in the app, and I'm
> having a problem with the Save action. The issue is
> that I need to retrieve the object from the datastore
> (using the id) *before* the ActionForm is populated
> with the request parameters.
> What I'd like is to have
> the bean populated from the database, and then any
> parameters that are present on the request object set
> on the bean, then persist. I can't figure out how to
> initialize the bean to the datastore before it gets to
> me in the Action. 

Go to the Action first, populate the ActionForm and then forward to the
JSP. The form tags will see the ActionForm, and use it to populate
themselves. Then when the form is submitted, it is populated from the
request parameters "again", closing the loop.


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

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




Re: Struts Design question - followup

2001-12-07 Thread Jon Wall

Hi Brian - 

Thanks for the responses.  Some more information and
clarification...

> Well, I put data type and required field validation
> only in the bean.

I'm doing this type of validation on the client-side
in JavaScript already.  I prefer to keep it here as
it's not too much work and it's much faster than doing
it server side.  

> You can populate your databean in your action object
> based on DB data since
> the action object is called before the JSP page is
> generated.

I know, but then I have to populate the bean with the
request parameters myself, right?  Struts does the
auto populating before it hands off to me...only it's
not working because the bean hasn't been
"initialized".


thanks..
-jon


--- [EMAIL PROTECTED] wrote:
> 
> Let me try to venture a few responses...
> 
> > But my beans already contain the validation!
> Besides, performing the
> validation in the ActionForm is effectively tying
> business logic (data
> validation) to the web framework dontya think?
> 
> Well, I put data type and required field validation
> only in the bean.
> Validation that is more advanced than that, or based
> on business rules
> should be in your app server (if you have one), or
> in the action object.
> 
> >I need to retrieve the object from the datastore
> (using the id) *before*
> the ActionForm is populated with the request
> parameters.
> 
> You can populate your databean in your action object
> based on DB data since
> the action object is called before the JSP page is
> generated.
> 
> >  the user never submits the form and goes to a
> different section of the
> site. How would I get the bean out of the session?
> 
> All active databeans for a session are stored under
> the key:
> org.apache.struts.action.FORM_BEANS.  You can get
> ahold of this collection
> and clear it out (save the current bean for the page
> you are on).  This is
> sort of a hack, so maybe there is another better way
> to do it..
> 
> Brian
> 
> 
> 
> 
> 
> 
>  
> Jon Wall
> 
>  
>  Struts Users Mailing List
> <[EMAIL PROTECTED]>
> o.com>   cc:
> 
>  
>  Subject:   
>  Struts Design question 
>  
> 12/07/2001  
> 
>  
> 03:08 PM
> 
>  
> Please respond  
> 
>  
> to "Struts  
> 
>  
> Users Mailing   
> 
>  
> List"   
> 
>  
> 
> 
>  
> 
> 
>  
> 
> 
> 
> 
> I've been lurking on this list for a while, and I
> finally have time to look hard at Struts for a web
> application that I'm working on. I have a coupla
> questions.. 1. This first question I found reference
> to in the archives
>
(http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18281.html)
> but couldn't find an answer. In the application I'm
> working on the business logic is already written and
> is being added to by another team (it's supporting
> other applications besides the web). So I've got a
> whole slew of JavaBeans (100+) already written for
> me,
> but now I'm facing the task of wrapping them in
> ActionForm subclasses, cursing under my breath that
> it
> isn't an interface. I understand that the purpose of
> the ActionForm is as a buffer..perform validation
> and
> all that. But my beans already contain the
> validation!
> Besides, performing the validation in the ActionForm
> is effectively tying business logic (data
> validation)
> to the web framework dontya think? Rules su

Re: Struts Design question

2001-12-07 Thread Brian . Duchouquette


Let me try to venture a few responses...

> But my beans already contain the validation! Besides, performing the
validation in the ActionForm is effectively tying business logic (data
validation) to the web framework dontya think?

Well, I put data type and required field validation only in the bean.
Validation that is more advanced than that, or based on business rules
should be in your app server (if you have one), or in the action object.

>I need to retrieve the object from the datastore (using the id) *before*
the ActionForm is populated with the request parameters.

You can populate your databean in your action object based on DB data since
the action object is called before the JSP page is generated.

>  the user never submits the form and goes to a different section of the
site. How would I get the bean out of the session?

All active databeans for a session are stored under the key:
org.apache.struts.action.FORM_BEANS.  You can get ahold of this collection
and clear it out (save the current bean for the page you are on).  This is
sort of a hack, so maybe there is another better way to do it..

Brian




   

Jon Wall   


o.com>   cc:   

 Subject: Struts Design question   

12/07/2001 

03:08 PM   

Please respond 

to "Struts 

Users Mailing  

List"  

   

   





I've been lurking on this list for a while, and I
finally have time to look hard at Struts for a web
application that I'm working on. I have a coupla
questions.. 1. This first question I found reference
to in the archives
(http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18281.html)
but couldn't find an answer. In the application I'm
working on the business logic is already written and
is being added to by another team (it's supporting
other applications besides the web). So I've got a
whole slew of JavaBeans (100+) already written for me,
but now I'm facing the task of wrapping them in
ActionForm subclasses, cursing under my breath that it
isn't an interface. I understand that the purpose of
the ActionForm is as a buffer..perform validation and
all that. But my beans already contain the validation!
Besides, performing the validation in the ActionForm
is effectively tying business logic (data validation)
to the web framework dontya think? Rules such as no
invoice numbers under 1000 (Ted's example) should be
handled by the business logic, and given my situation
(probably a common one), this logic needs to be shared
between applications. I can't go into the server
system and fit ActionForm into the class heirarchy,
but I sure could have thrown an interface in there.
Input on this is appreciated. 2. This has to have come
up before, but I couldn't find any references. All of
my JavaBeans map to persistent components, all of
which have id's. I've written some actions to display
lists of these components and the like and everything
works great. I also started to try the Add/Edit/Save
pattern, which occurs everywhere in the app, and I'm
having a problem with the Save action. The issue is
that I need to retrieve the object from the datastore
(using the id) *before* the ActionForm is populated
with the request parameters. What I'd like is to have
the bean populated from the database, and then any
parameters that are present on the request object set
on the bean, then persist. I can't figure out how to
initialize the bean to the datastore before it gets to
me in the Action. If I make the ActionForm session
scoped, it works great...is this the common practice?
If so, how is cleanup performed? IE, user clicks to
Edit Widget 137, my EditWidgetAction class populates
WidgetForm and stic

Struts Design question

2001-12-07 Thread Jon Wall

I've been lurking on this list for a while, and I
finally have time to look hard at Struts for a web
application that I'm working on. I have a coupla
questions.. 1. This first question I found reference
to in the archives
(http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18281.html)
but couldn't find an answer. In the application I'm
working on the business logic is already written and
is being added to by another team (it's supporting
other applications besides the web). So I've got a
whole slew of JavaBeans (100+) already written for me,
but now I'm facing the task of wrapping them in
ActionForm subclasses, cursing under my breath that it
isn't an interface. I understand that the purpose of
the ActionForm is as a buffer..perform validation and
all that. But my beans already contain the validation!
Besides, performing the validation in the ActionForm
is effectively tying business logic (data validation)
to the web framework dontya think? Rules such as no
invoice numbers under 1000 (Ted's example) should be
handled by the business logic, and given my situation
(probably a common one), this logic needs to be shared
between applications. I can't go into the server
system and fit ActionForm into the class heirarchy,
but I sure could have thrown an interface in there.
Input on this is appreciated. 2. This has to have come
up before, but I couldn't find any references. All of
my JavaBeans map to persistent components, all of
which have id's. I've written some actions to display
lists of these components and the like and everything
works great. I also started to try the Add/Edit/Save
pattern, which occurs everywhere in the app, and I'm
having a problem with the Save action. The issue is
that I need to retrieve the object from the datastore
(using the id) *before* the ActionForm is populated
with the request parameters. What I'd like is to have
the bean populated from the database, and then any
parameters that are present on the request object set
on the bean, then persist. I can't figure out how to
initialize the bean to the datastore before it gets to
me in the Action. If I make the ActionForm session
scoped, it works great...is this the common practice?
If so, how is cleanup performed? IE, user clicks to
Edit Widget 137, my EditWidgetAction class populates
WidgetForm and sticks it in the session, the user
never submits the form and goes to a different section
of the site. How would I get the bean out of the
session? Any help is appreciated. -jon

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Re: Iterate Design Question

2001-11-30 Thread Renaud Waldura

Use a cursor. MySQL does it with:
SELECT name FROM customers LIMIT 5, 10

Yes, it's optimized.
http://www.mysql.com/doc/L/I/LIMIT_optimisation.html

All databases can do that, maybe differently.

--Renaud




- Original Message -
From: "John M. Corro" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 30, 2001 8:43 AM
Subject: Iterate Design Question


Consider a situation where you want to display a straght listing of items
from a database.  Something like where you would display a listing of 1-20
products on page 1, 21-40 on page 2, etc.  There seem to be two ways this
gets implemented.

1. Pull the entire table contents, store them into a container of sorts,
refer to the container's listing from page to page (instead of hitting the
database again.

2. Query the DB for only the contents you need on each request.  So user
request page 1, backend queries the the DB for products 1 - 20, returns it.
If the user requests for page 2, the backend does the same process over
again for products 21-40 and so on.

My specific situation prevents me from doing the first approach because the
result set is so large (takes too long to make that initial DB call)  and
the listing changes so often that it's possible a user may be view an
inaccurate listing.

In going forward w/ approach 2, I've been having some issues I'd like to
bounce off anyone w/ experience in the matter.
- Thought about using the PreparedStatement.setMaxRows() method, but if I do
something like "SELECT ... FROM Products WHERE...", I don't know if the
statement is smart enough to optimize itself to only retrieve 20 products.
The docs say that "the excess rows are silently dropped", but I don't know
if "silently" means it pulls all the records and only returns 20.  If that
is the case that would seem like I wouldn't get any performance gains (the
DB still has to go through the process of retrieving all the records).  I
imagine that what "silently" means would be dictated by the driver.

- I also thought about using database specific SQL statements to cap the
size of the result set (ie the 'Limit' keyword in MySQL).  This would be my
least desired step as I don't want to get tied to a specific database.  I'm
not aware of any ANSI SQL commands that will do this.

Anyone have any thoughts?





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




Iterate Design Question

2001-11-30 Thread John M. Corro

Consider a situation where you want to display a straght listing of items from a 
database.  Something like where you would display a listing of 1-20 products on page 
1, 21-40 on page 2, etc.  There seem to be two ways this gets implemented.

1. Pull the entire table contents, store them into a container of sorts, refer to the 
container's listing from page to page (instead of hitting the database again.

2. Query the DB for only the contents you need on each request.  So user request page 
1, backend queries the the DB for products 1 - 20, returns it.  If the user requests 
for page 2, the backend does the same process over again for products 21-40 and so on.

My specific situation prevents me from doing the first approach because the result set 
is so large (takes too long to make that initial DB call)  and the listing changes so 
often that it's possible a user may be view an inaccurate listing.

In going forward w/ approach 2, I've been having some issues I'd like to bounce off 
anyone w/ experience in the matter.
- Thought about using the PreparedStatement.setMaxRows() method, but if I do something 
like "SELECT ... FROM Products WHERE...", I don't know if the statement is smart 
enough to optimize itself to only retrieve 20 products.  The docs say that "the excess 
rows are silently dropped", but I don't know if "silently" means it pulls all the 
records and only returns 20.  If that is the case that would seem like I wouldn't get 
any performance gains (the DB still has to go through the process of retrieving all 
the records).  I imagine that what "silently" means would be dictated by the driver.

- I also thought about using database specific SQL statements to cap the size of the 
result set (ie the 'Limit' keyword in MySQL).  This would be my least desired step as 
I don't want to get tied to a specific database.  I'm not aware of any ANSI SQL 
commands that will do this.

Anyone have any thoughts?





Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-26 Thread Ted Husted

I don't see where this part of the thread began, but reset() is always
called before the bean is autopopulated from the request, regardless of
scope. If your reset is setting fields you want to retain to null, you
should have it stop. This is really only necessary when checkboxes are
expected.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


"Hoang, Hai" wrote:
> 
> I used session scope because I want the form to remember or correctly
> selected my value dropdown list.  But I don't know why all of the values
> that I did not display as hidden field or text field are lost.
> 
> Thanks,
> Hai
> 
> -Original Message-
> From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 26, 2001 9:29 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Design question - Action Form vs Business Delegates/Value
> Obj ects
> 
> Is your form bean in session or request scope?
> I always use session scope to ensure that existing data in vo's are not
> lost.
> 
> HTH,
> Michelle
> 
> >From: "Hoang, Hai" <[EMAIL PROTECTED]>
> >To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> >CC: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> >Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
> 
> >ects
> >Date: Mon, 26 Nov 2001 10:26:38 -0500
> >
> >Michelle,
> >
> >You wrote
> >
> > >> You're probably right. So far I have only used it for Strings and
> >numbers
> >for which no special mapping was required. In this case it was simple to
> >implement.
> >I've tred and it works for Long datatype.  Have you try for int or long?
> >What about editing a record? if you don't specify a hidden field for the
> >primary key such as  the pk
> >value in the value object resets to null.  Do you experience this problem?
> >Thank you for your help
> >Hai
> >
> 
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> 
> --
> 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 question - Action Form vs Business Delegates/Value Obj ects

2001-11-26 Thread Hoang, Hai

I used session scope because I want the form to remember or correctly
selected my value dropdown list.  But I don't know why all of the values
that I did not display as hidden field or text field are lost.

Thanks,
Hai

-Original Message-
From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 26, 2001 9:29 AM
To: [EMAIL PROTECTED]
Subject: RE: Design question - Action Form vs Business Delegates/Value
Obj ects


Is your form bean in session or request scope?
I always use session scope to ensure that existing data in vo's are not 
lost.

HTH,
Michelle


>From: "Hoang, Hai" <[EMAIL PROTECTED]>
>To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>CC: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>Subject: RE: Design question - Action Form vs Business Delegates/Value Obj

>ects
>Date: Mon, 26 Nov 2001 10:26:38 -0500
>
>Michelle,
>
>You wrote
>
> >> You're probably right. So far I have only used it for Strings and 
>numbers
>for which no special mapping was required. In this case it was simple to
>implement.
>I've tred and it works for Long datatype.  Have you try for int or long?
>What about editing a record? if you don't specify a hidden field for the
>primary key such as  the pk
>value in the value object resets to null.  Do you experience this problem?
>Thank you for your help
>Hai
>


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

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




RE: Design question - Action Form vs Business Delegates/Value Obj ects

2001-11-26 Thread Hoang, Hai

Michelle,

You wrote

>> You're probably right. So far I have only used it for Strings and numbers
for which no special mapping was required. In this case it was simple to
implement. 
I've tred and it works for Long datatype.  Have you try for int or long?
What about editing a record? if you don't specify a hidden field for the
primary key such as  the pk
value in the value object resets to null.  Do you experience this problem?
Thank you for your help
Hai


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




Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-26 Thread Paul Devine

Hi Ted

yes, you are right. The adapters don't have any fields, just getters and
setters essentially telling the business objects what to do.  One thing I'm
not too pleased with is that some of the methods in my adapter end up being
more complex than I'd like. For example a method like setFeature( int
featureId ) will do a lookup to get the feature business object associated
with the featureId and then traverse the business objects starting from the
root business object and fugure out what it needs to do. But I'll live with
that for now.

To be honest regarding your question about conversions/transformations I
have not needed to do that in my application (no dates involved). I think
the adapter could be used to do the transformation but i'm not sure I'd put
it there. If I thought the conversion/transformation was specific to the
presentation layer requirements I would probably try to either (a) somehow
put the conversion/transformation in a reusable tag (probably only works in
displaying info); or (b) write dedicated and reusable helper objects, e.g.
DateTransformer, which can be parameterized (e.g. at the time of
construction), and are capable of producing a Date from a String and vice
versa, based on the date formatting parameters. Then using those helper
objects in the forms so that when setDateString(...) gets called it asks the
transformer for a Date (the form would need to expose the Date via getDate;
the adapter would then only support Date getDate() and void setDate( Date)
whereas the forms support get/setDateString(), get/setDate.  The forms could
even use these transformer helpers as private static objects to avoid
recreating a new object each time.

Does this sound reasonable ?  I am very interested in other people's ideas
and experiences.   I think Struts is a great framework and based on this
mailing list there are a lot of people using it in smart ways. I'm sure
there are a lot of best practices evolving out there which we can all learn
from.

- Paul


- Original Message -
From: "Ted Husted" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, November 23, 2001 1:30 PM
Subject: Re: Design question - Action Form vs Business Delegates/Value
Objects


> That sounds quite clever.
>
> So the adapter class itself has no fields, only getters and setters?
>
> Do the adapters need to perform any conversions or transformations, like
> creating a date field from a String, or stripping the non-numeric
> formatting out of a telephone number?
>
> Paul Devine wrote:
> >
> > I have used an approach similar to that which Ted is outlining.
Basically
> > I keep my Form's UI specific, I want ro write as little code as possible
in
> > the "Strus specific" classes (ActionForm's and Action's).  The interface
on
> > a form class is naturally different to that on the business objects (in
our
> > system these are actually closer to the value objects that you are
working
> > with)I ended up writing what "Adapter" class(es) between the form(s)
and
> > the business objects.  An Adapter and a Form share one or more methods
with
> > the same signature.   In order to populate a form for display, I
instantiate
> > my "root level" business object of relevance, wrap it an adapter, and
then
> > call PropertyUtils.copyProperties (the exact method name escapes me for
> > now).  This automatically populates the form by calling it's "set"
methods
> > for those methods with a matching "get" method on the adapter.  When
the
> > form is submitted and I need to update the state of the business
objects, I
> > do the opposite, copy from the form to the adapter.   Internally the
adapter
> > does all the detailed work of setting the information on the right
business
> > objects, shielding the action of form objects from the complexity of the
> > business object model.  An added bonus for us that is since our business
> > objects have quite a complex model (X has multiple Y, Y in turn has
multiple
> > Z, etc.) the adapter provides a simplified method of access into the
> > business object model.
> >
> > For example (Action class)...
> > Employee employee = new Employee();
> > // ... do what it takes to load the employee with data
> > EmployeeAdapter adapter = new EmployeeAdapter( employee );
> > PropertyUtils.copyProperties( employeeForm, adapter ) ; // can't
> > remember the order of these for now bnut the intent is from employee to
the
> > form
> >
> > The Adapter implementations may or may not be reusable across projects.
> > Since they are tailored to adapting the business objects to an interface
> > which

RE: =?ISO-8859-2?Q?Newbie design question - How to use properly use a connection pool in the b=

2001-11-26 Thread Markus Massak

if you have a central dbmanager bean (handling the connpool)
which each object can "see" because it is a singleton, the
db beans can access it. this has nothing to do with servletcontext
and even less with view. it's communication between model (db beans)
and controller (dbmanager). you also can see dbmanager as model.

greetings


-Original Message-
From: Nobody [mailto:[EMAIL PROTECTED]]
Sent: Montag, 26. November 2001 05:30
To: Struts Users Mailing List
Subject: =?ISO-8859-2?Q?Newbie design question - How to use properly use
a connection pool in the b=


usiness logic beans?=
X-Mailer: Sysdump.com
X-Originating-IP: 12.83.106.244
Content-Type: text/plain; charset=iso-8859-1
From: <[EMAIL PROTECTED]>

I am trying to stick with the MVC paradigm and keep separate the model from
the view.  As the Struts User Manual suggests, I am writing the business
logic as Javabeans (not EJB), these beans are used by the JSP pages.  I
would like to have all of the data
base work done within one bean and have other beans closer to the view use
that bean to do the actual selects and updates/inserts.  This would be easy
if the db bean opened a db connection each time it was instantiated, but to
be able to effectively use a
 connection pool, it would need to persist (like a servlet).

The problem I am having is how would I give the other beans access to this
db bean that has the connection pool?  I was thinking I could maybe put the
db bean into the ServletContext to give it 'app scope', but then those other
beans would still be unable
 to access it since they don't have access to anything that has to do with
the view.  What I am considering is having the beans used by the JSPs store
the connection pool and then when they need to access the database they
could create the db bean object
and pass it a free Connection to do its work...

Any suggestions?

Thanks,
Kenny

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




=?ISO-8859-2?Q?Newbie design question - How to use properly use a connection pool in the b=

2001-11-26 Thread Nobody

usiness logic beans?=
X-Mailer: Sysdump.com
X-Originating-IP: 12.83.106.244
Content-Type: text/plain; charset=iso-8859-1
From: <[EMAIL PROTECTED]>

I am trying to stick with the MVC paradigm and keep separate the model from the view.  
As the Struts User Manual suggests, I am writing the business logic as Javabeans (not 
EJB), these beans are used by the JSP pages.  I would like to have all of the database 
work done within one bean and have other beans closer to the view use that bean to do 
the actual selects and updates/inserts.  This would be easy if the db bean opened a db 
connection each time it was instantiated, but to be able to effectively use a 
connection pool, it would need to persist (like a servlet).

The problem I am having is how would I give the other beans access to this db bean 
that has the connection pool?  I was thinking I could maybe put the db bean into the 
ServletContext to give it 'app scope', but then those other beans would still be 
unable to access it since they don't have access to anything that has to do with the 
view.  What I am considering is having the beans used by the JSPs store the connection 
pool and then when they need to access the database they could create the db bean 
object and pass it a free Connection to do its work...

Any suggestions?

Thanks,
Kenny

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




Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-23 Thread Ted Husted

John Yu wrote:
> Struts is clever enough to call myEmployeeBean.getEmployeeVO().getName().

Something to watch is that Struts is also clever enough to populate any
String or boolean public property property on employeeVO from a query
string. So if employeeVO had another property, like role, someone might
be able to set that from a query string like 

/do/employeeSubmit?role=MANAGER

and have the employee's role set to MANAGER -- even if that property
were not exposed on the ActionForm. Of course, this wouldn't actually
work in most use cases, but it is something to keep in mind.

It's important to recognize that ActionForms are firewalls between the
rest HTTP and the rest of your application. Once the (untrusted)
ActionForm properties are validated, the data can be moved to another
(trusted) class, and handled optimistically. 

Personally, I recommend keeping the ActionForms as throw-away UI
artifacts. An environment like Swing does the same thing, an internal
buffer captures input as a String, and then converts or passes the
validated result back, but without exposing the buffer property to the
developer. The same strategy is at work here, but since we can't extend
the browser controls, we have to provide our own ActionForm instead. 

If the value objects are also transient, and the fields are Strings or
booleans, then it can be reasonable to to populate the String properties
directly from the ActionForm. Though, many forms have to deal with more
than Strings. Where do you store an invalid date or integer so the user
can correct it? This is why ActionForms usually need to be separate
objects -- for non-String fields that can't be passed back and forth via
HTTP ~in an invalid state~. 

If a user enters $1.00 where they were suppose to enter 1.00 and
returning a blank instead of what they entered is acceptable, then you
can wrap a double currency field in an ActionForm. Otherwise, there will
not be a way to return the original input, since "$" can't be stored in
a numeric field. Of course, Javascript validations can address this, but
the framework cannot be premised on Javascript being available.

The next best thing would be to give the binary fields on the value
object String buffers, which is how conventional UI components work. But
then you really should build a validation state into the value object
too, which can lead to buffering all the fields, including the String
fields. At this point, the value object is more complicated that having
a separation ActionForm, and requires no less typing.

Personally, I recommend using the BeanUtils methods to populate value
objects from validated ActionForms. Since these use reflection, they
tend to the fastest, easiest, and cheapest way to get the job done. You
can even build this into your Action subclass, so custom methods are not
continually loaded through the application. 

It's also important to note that there doesn't not have to be 1:1
relationship between ActionForms and the value objects. The ActionForms
represent input required from the user. This may map to several value
objects, and the value objects may carry other fields. Each to its own.

Representing dates and other formatted data can still be a problem.
Here, I tend to add ${property}Text fields to the value objects, that
accept and return String representations of dates, telephone numbers,
and other formatted strings, that may have to be transformed before
being stored or accessed. These are still not bound to the ActionForm in
any way, except by name. So instead of having a "date" property, an
ActionForm might have a dateText property. On the value object, the
setDateText method sets the actual date property on a pass/fail basis,
so it's important that the ActionForm validate the date String first. 

ActionForm
- dateText: String
+ setDateText:String
+ getDataeText:String

ValueObject
- date:Timestamp
+ setDate:Timestamp
+ getDate:Timestamp
+ setDateText:String
+ getDateText:String

Of course the simple native types, found in java.lang, once validated,
can usually pass right through, without intervention. But in practice,
many fields need to be formatted before being presented to the user, and
the formatting removed before the value is updated. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

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




RE: design question

2001-11-23 Thread Alexander Jesse

Hi,

encapsulating client info into a system-state-bean call ClientInfo will
make it easier to pass it eventually to a business-logic-class that needs 
access to the info. So I would recommend that.

If the size is big, make it "persistant" and store just a key in the 
http-session, else store it in the http-session.

hope this helps
Alexander

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 23, 2001 11:18 AM
To: [EMAIL PROTECTED]
Subject: RE: design question




>It is quite tricky to answer your question as you did not mention
additional
>info i.e best practices is also depend on the  application size ( how
much
>client it will cater and for what purpose )
>anyway this is what I hope you'll get something from my assumption :-
>1) if the number of client is not too many i.e only have 100 + but no
more
>than or never goes beyond 100 000 ( the number is abitrary , just to
show
>you how big is big )
>then session will be the choice since it is faster  to retrieve the
data ,
>but if you 're going to have many clients then state bean will be more
>efficient since the session will used up your memory while the state
bean (
>session bean) will passivate if it is not used ( and save the memory ) 

+++  Its not an efficiency issue. The number of clients will not be too
many. 

>2) Please refer to the www.javasoft.com website and find the EJB
tutorial
>from there 

+++ I didnt mean session bean from EJB   :-).

"system state bean" is mentioned in Struts User Guide.   As I
undwerstood I can use it instead of session variables.
I dont like session variables because I have to define names of session
variables somewhere (like in class Constants)
otherwise its easy to mix up them  or to forget their names.


>3) That depend on your architecture.basically the bean should stick to
the
>javabeans specification design and should not have any jdbc calls ( but
>there is an exceptio for that . i.e if you create a bean for your
taglibs
>you'll need to embed the jdbc to it )


> -Original Message-
> From: Màris Orbidàns [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, November 22, 2001 4:54 PM
> To:   Struts-list (E-mail)
> Subject:  design question
> 
> Hello
> 
> I have several questions about design, "best practises":
> 
> 1)  Where to store client's profile information (like login name) ?
> session  or system state bean ?
> 
> 2)  How to create and use a system state bean ?
> 
> System state bean should be in scope "session", shouldnt it ?
> 
> 3) Where to put business logic (where I invoke JDBC) ?  
>   Should business logic class be a bean ?
> 
> thanx in advance
> Maris Orbidans
>   
> 
> 
> --
> 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 question - Action Form vs Business Delegates/Value Obj ects

2001-11-23 Thread Michelle Popovits

You're probably right.
So far I have only used it for Strings and numbers for which
no special mapping was required.  In this case it was simple to implement.

Michelle

>From: "Sobkowski, Andrej" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "Jakarta Struts (User) (E-mail)" <[EMAIL PROTECTED]>
>CC: "'Michelle Popovits'" <[EMAIL PROTECTED]>
>Subject: RE: Design question - Action Form vs Business Delegates/Value Obj  
>ects
>Date: Fri, 23 Nov 2001 09:18:18 -0500
>
>Michelle,
>
>thanks, now I got it.
>
>The problem I see with the approach you describe is that it forces all the
>data conversions inside the ActionForm
>
>EmployeeVO
>// the following must be "Date" to make the VO a "business object"
>+getDateOfBirth:Date
>+setDateOfBirth(Date in):void
>
>EmployeeForm
>public void setDateOfBirth(String in) {
>   // CONVERT THE IN STRING TO A DATE
>   String convertedDate = ...
>   getVO().setDate(convertedDate)
>}
>
>public String getDateOfBirth() {
>   // CONVERT THE OUT DATE TO A STRING
>   Date outDate = getVO().getDate();
>   return (convertDateToString(outDate));
>}
>
>Furthermore, the "less typing" advantage is relatively small. You still 
>have
>to code all your get/set and still need both Form and VO. And you need to
>add the conversion code. Or not?
>
>I guess that keeping the two totally separate and dealing with the mapping
>via a separate entity is another possible approach. I have written two
>"PropertyMappers" that do the following automatically for all matching
>get/set:
>FORM -> VO
>vo.setProperty(convertFormProperty(form.getProperty()))
>
>VO -> FORM
>form.setProperty(convertVOProperty(vo.getProperty()))
>
>It doesn't deal with validations nor anything else. It just maps forms and
>VOs. I'll be ready to share it with anybody interested as soon as I have
>properly tested it and added more javadoc.
>
>Thanks to everybody, this is a great list!
>
>Andrej
>
>
>-Original Message-
>From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, November 22, 2001 7:21 PM
>To: Dmitri Colebatch
>Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>Subject: Re: Design question - Action Form vs Business Delegates/Value
>Obj ects
>
>
>Hi Dim,
>
>Your example is similar to my approach with the exception that you are 
>still
>duplicating
>methods of the value object inside of the action form.  Instead of 
>including
>the individual accessors in the form, just include
>the accessor for the value object (see my original example)...much less
>unnecessary typing this way.
>When you need to access the value object properties in java you just cal 
>the
>employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
>want to bind the value object property to a text field you refer to the
>property as "employeeVo.name".
>
>HTH,
>Michelle
>
>- Original Message -
>From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
>To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>
>Sent: Thursday, November 22, 2001 5:34 PM
>Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
>ects
>
>
> > Hi,
> >
> > I also agree with Michelle...
> >
> > I think what you are thinking is maybe you could use the struts form 
>_as_
> > the value object?  imho this would be bad design, as the whole idea of
> > putting the logic in a separate tier is to have it not bound to any one
> > form of presentation.  What Michelle is suggesting though, is something
> > like:
> >
> > public class EmployeeForm extends ActionForm
> > {
> >   private EmployeeVO vo = new EmployeeVO();
> >
> >   public String getName()
> >   {
> > return vo.getName();
> >   }
> >
> >   public void setName(String name)
> >   {
> > vo.setName(name);
> >   }
> >
> >   // and so on
> >
> >   // get the vo
> >   public EmployeeVO getEmployeeVO()
> >   {
> > return vo;
> >   }
> > }
> >
> > so say you have an action class:
> >
> > public class AddEmployeeAction()
> > {
> >   public void perform( ... )
> >   {
> > EmployeeForm eform = (EmployeeForm) form;
> > employeeManager.add(eform.getEmployeeVO());
> >   }
> > }
> >
> > etc... very simplified example, but hopefully this is a bit clearer... I
> > use this all the time, and would be 

RE: Design question - Action Form vs Business Delegates/Value Obj ects

2001-11-23 Thread Sobkowski, Andrej

Dimitri,

Struts can handle automatic population via "nested" (a.property) and
"indexed" (a[0].property) properties, you will not have to do it manually.

With the example below (EmployeeForm and EmployeeVO), you can use your
Struts Taglibs  to point "directly" to the employeeVO variables (this will
automatically set the value as well)



This will ALSO work with straight HTML (but no automatic set of the value
attribute)



Both will automagically call employeeForm.getEmployeeVO().setName(...) for
you.

The ActionServlet delegates the population of the ActionForm to
org.apache.struts.util.RequestUtils and org.apache.commons.BeanUtils. The
initial call is peformed in ActionServlet's processPopulate(...)

HTH

Andrej

PS. If you're interested in nested tags, you may also find the following
interesting http://husted.com/struts/resources/MonkeyStruts.htm

-Original Message-
From: Dmitri Colebatch [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 10:36 PM
To: Struts Users Mailing List
Subject: Re: Design question - Action Form vs Business Delegates/Value
Obj ects


yes, thats fine _in the jsp_ my question is at the other end... for
instance:

  1. user completes form values and submits
  2. struts actionservlet receives post and extracts parameters out of it
  3. struts actionservlet maps the request to an action and instantiates
the form for the action
  4. struts actionservlet copies parameters from http post to the form

this is where I am unsure of why your approach is able to work.  I can see
if you populate the form yourself then you will be able to call those
methods yourself but how does step 4 take place if you dont tell
struts that it needs to call form.getEmployeeVo()?  The only place you
have talked about doing that is in JSPs... for this to work, I would
expect some configuration directive...?

cheers
dim

On Thu, 22 Nov 2001, Michelle Popovits wrote:

> Hi Dim,
> 
> Your example is similar to my approach with the exception that you are
still
> duplicating
> methods of the value object inside of the action form.  Instead of
including
> the individual accessors in the form, just include
> the accessor for the value object (see my original example)...much less
> unnecessary typing this way.
> When you need to access the value object properties in java you just cal
the
> employeeForm.getEmployeeVo().getName() method and when you are in a jsp
and
> want to bind the value object property to a text field you refer to the
> property as "employeeVo.name".
> 
> HTH,
> Michelle
> 
> - Original Message -
> From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, November 22, 2001 5:34 PM
> Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
> ects
> 
> 
> > Hi,
> >
> > I also agree with Michelle...
> >
> > I think what you are thinking is maybe you could use the struts form
_as_
> > the value object?  imho this would be bad design, as the whole idea of
> > putting the logic in a separate tier is to have it not bound to any one
> > form of presentation.  What Michelle is suggesting though, is something
> > like:
> >
> > public class EmployeeForm extends ActionForm
> > {
> >   private EmployeeVO vo = new EmployeeVO();
> >
> >   public String getName()
> >   {
> > return vo.getName();
> >   }
> >
> >   public void setName(String name)
> >   {
> > vo.setName(name);
> >   }
> >
> >   // and so on
> >
> >   // get the vo
> >   public EmployeeVO getEmployeeVO()
> >   {
> > return vo;
> >   }
> > }
> >
> > so say you have an action class:
> >
> > public class AddEmployeeAction()
> > {
> >   public void perform( ... )
> >   {
> > EmployeeForm eform = (EmployeeForm) form;
> > employeeManager.add(eform.getEmployeeVO());
> >   }
> > }
> >
> > etc... very simplified example, but hopefully this is a bit clearer... I
> > use this all the time, and would be interested to hear what other ppl
> > think as well...
> >
> > cheers
> > dim
> >
> > On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
> >
> > > Michelle,
> > >
> > > thanks for your reply... but I'm not sure I understand your answer.
> Probably
> > > my message wasn't clear.
> > >
> > > To use an example, I have:
> > >
> > > EmployeeForm extends ActionForm
> > > +getName():String
> > > +getAge():String
> > > +getDateOfBirth(

RE: Design question - Action Form vs Business Delegates/Value Obj ects

2001-11-23 Thread Sobkowski, Andrej

Michelle,

thanks, now I got it.

The problem I see with the approach you describe is that it forces all the
data conversions inside the ActionForm

EmployeeVO
// the following must be "Date" to make the VO a "business object"
+getDateOfBirth:Date
+setDateOfBirth(Date in):void

EmployeeForm
public void setDateOfBirth(String in) {
  // CONVERT THE IN STRING TO A DATE
  String convertedDate = ...
  getVO().setDate(convertedDate)
}

public String getDateOfBirth() {
  // CONVERT THE OUT DATE TO A STRING
  Date outDate = getVO().getDate();
  return (convertDateToString(outDate));
}

Furthermore, the "less typing" advantage is relatively small. You still have
to code all your get/set and still need both Form and VO. And you need to
add the conversion code. Or not?

I guess that keeping the two totally separate and dealing with the mapping
via a separate entity is another possible approach. I have written two
"PropertyMappers" that do the following automatically for all matching
get/set:
FORM -> VO
vo.setProperty(convertFormProperty(form.getProperty()))

VO -> FORM
form.setProperty(convertVOProperty(vo.getProperty()))

It doesn't deal with validations nor anything else. It just maps forms and
VOs. I'll be ready to share it with anybody interested as soon as I have
properly tested it and added more javadoc. 

Thanks to everybody, this is a great list!

Andrej


-Original Message-
From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 7:21 PM
To: Dmitri Colebatch
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Design question - Action Form vs Business Delegates/Value
Obj ects


Hi Dim,

Your example is similar to my approach with the exception that you are still
duplicating
methods of the value object inside of the action form.  Instead of including
the individual accessors in the form, just include
the accessor for the value object (see my original example)...much less
unnecessary typing this way.
When you need to access the value object properties in java you just cal the
employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
want to bind the value object property to a text field you refer to the
property as "employeeVo.name".

HTH,
Michelle

- Original Message -
From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, November 22, 2001 5:34 PM
Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
ects


> Hi,
>
> I also agree with Michelle...
>
> I think what you are thinking is maybe you could use the struts form _as_
> the value object?  imho this would be bad design, as the whole idea of
> putting the logic in a separate tier is to have it not bound to any one
> form of presentation.  What Michelle is suggesting though, is something
> like:
>
> public class EmployeeForm extends ActionForm
> {
>   private EmployeeVO vo = new EmployeeVO();
>
>   public String getName()
>   {
> return vo.getName();
>   }
>
>   public void setName(String name)
>   {
> vo.setName(name);
>   }
>
>   // and so on
>
>   // get the vo
>   public EmployeeVO getEmployeeVO()
>   {
> return vo;
>   }
> }
>
> so say you have an action class:
>
> public class AddEmployeeAction()
> {
>   public void perform( ... )
>   {
> EmployeeForm eform = (EmployeeForm) form;
> employeeManager.add(eform.getEmployeeVO());
>   }
> }
>
> etc... very simplified example, but hopefully this is a bit clearer... I
> use this all the time, and would be interested to hear what other ppl
> think as well...
>
> cheers
> dim
>
> On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
>
> > Michelle,
> >
> > thanks for your reply... but I'm not sure I understand your answer.
Probably
> > my message wasn't clear.
> >
> > To use an example, I have:
> >
> > EmployeeForm extends ActionForm
> > +getName():String
> > +getAge():String
> > +getDateOfBirth():String
> >
> > EmployeeVO
> > +getName():String
> > +getAge():Integer
> > +getDateOfBirth():Date
> >
> > EmployeeForm is a simple Struts mapping of the data displayed on the
HTML
> > page. EmployeeVO is the intermediate value/business object where the
fields
> > have a "real" meaning (a Date is a Date).
> >
> > I don't see the reasons of making EmployeeVO an instance variable of
> > EmployeeForm. And EmployeeVO can not be used directly inside Struts to
map
> > data from an HttpRequest because (I think) that only Strings (and int?)
can
> > be handled in ActionForms.
> >
> > My question was 

RE: design question

2001-11-23 Thread Maris Orbidans



>It is quite tricky to answer your question as you did not mention
additional
>info i.e best practices is also depend on the  application size ( how
much
>client it will cater and for what purpose )
>anyway this is what I hope you'll get something from my assumption :-
>1) if the number of client is not too many i.e only have 100 + but no
more
>than or never goes beyond 100 000 ( the number is abitrary , just to
show
>you how big is big )
>then session will be the choice since it is faster  to retrieve the
data ,
>but if you 're going to have many clients then state bean will be more
>efficient since the session will used up your memory while the state
bean (
>session bean) will passivate if it is not used ( and save the memory ) 

+++  Its not an efficiency issue. The number of clients will not be too
many. 

>2) Please refer to the www.javasoft.com website and find the EJB
tutorial
>from there 

+++ I didnt mean session bean from EJB   :-).

"system state bean" is mentioned in Struts User Guide.   As I
undwerstood I can use it instead of session variables.
I dont like session variables because I have to define names of session
variables somewhere (like in class Constants)
otherwise its easy to mix up them  or to forget their names.


>3) That depend on your architecture.basically the bean should stick to
the
>javabeans specification design and should not have any jdbc calls ( but
>there is an exceptio for that . i.e if you create a bean for your
taglibs
>you'll need to embed the jdbc to it )


> -Original Message-
> From: Màris Orbidàns [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, November 22, 2001 4:54 PM
> To:   Struts-list (E-mail)
> Subject:  design question
> 
> Hello
> 
> I have several questions about design, "best practises":
> 
> 1)  Where to store client's profile information (like login name) ?
> session  or system state bean ?
> 
> 2)  How to create and use a system state bean ?
> 
> System state bean should be in scope "session", shouldnt it ?
> 
> 3) Where to put business logic (where I invoke JDBC) ?  
>   Should business logic class be a bean ?
> 
> thanx in advance
> Maris Orbidans
>   
> 
> 
> --
> 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 question - Action Form vs Business Delegates/Value Objects

2001-11-23 Thread Rey Francois


There is no plan to have it within the Jakarta commons, although it wouldn't
be a bad thing. The mapper framework offers the same functionality as
David's validation framework, except for the javascript generation. Having
them work in parallel is definitely possible, however you'll have two
separate XML configuration files: one for the validation based on David's
framework, and one mapper configuration for the conversion/transfer between
forms and value objects.

Fr.

-Original Message-
From: Roland Berger [mailto:[EMAIL PROTECTED]]
Sent: 23 November 2001 10:31
To: Struts Users Mailing List
Subject: AW: Design question - Action Form vs Business Delegates/Value
Objects


Hi Francois

Will yor mapper framework become a part of jakarta commons? What are the
plans?
When should I use David Winterfeld's validation framework and when yours?
Can they work in parallel?
TIA
Roland

-Ursprüngliche Nachricht-
Von: Rey Francois [mailto:[EMAIL PROTECTED]]
Gesendet: Freitag, 23. November 2001 09:17
An: 'Struts Users Mailing List'
Betreff: RE: Design question - Action Form vs Business Delegates/Value
Objects


I've had the same problem as you describe and like yourself have created a
mapper framework, see http://husted.com/struts/resources/mapper.zip. It can
handle validation, conversion and transfer of data, all this based on XML
configuration. The framework is not dependent on Struts, but can easily
integrate with it.

For an overview of the motivations behind this framework, read this earlier
posting
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02058.html.

Fr.

-Original Message-
From: Sobkowski, Andrej [mailto:[EMAIL PROTECTED]]
Sent: 22 November 2001 19:28
To: 'Struts Users Mailing List'
Subject: Design question - Action Form vs Business Delegates/Value
Objects


Hello,

we're working on a quite large project with J2EE (including EJBs) and we're
using Struts (we're still in the early phases). To design a "clean"
application, I've defined different "object conversions":
* Request phase
- the ActionForm is converted to a Value Object
- the Value Object is passed to the EJBs
* Response phase
- the EJBs return one ore more Value Objects
- the Value Object(s) is (are) converted back to ActionForms.

I think it's a good approach, but:
- my ActionForm and Value Objects have an almost identical interface. The
main difference is that the ActionForm instance variables are always of type
String while for the Value Object  have "final types" information (Date,
Integer, whatever)
- the conversion "ActionForm to VO" and back is slowing down the performance
as my EJBs often return hundreds of VOs (each one to be converted to an
ActionForm).
I know this can be improved by using paging (Page-by-Page iterator) on both
the back-end and the front-end; furthermore, I've written a small "mapper"
that uses extensively the Reflection API to automatically perform the
mapping and this probably has an impact on the overall performance.

My question is: what are the best practices for this type of issues? Does
anybody have the same problems? Should I reduce the level of abstraction
between the layers?

Thank you!

Andrej

PS. if you're interested, I can share the simple mapper. It's a very small
mapper (less than 15k) that works fine with my app. It's waaay less
complete than the mapper on Ted Husted's site but...

-Original Message-
From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 12:10 PM
To: 'Struts Users Mailing List'
Subject: RE: design question




-Original Message-
From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]]
Sent: 22 November 2001 16:54
To: Struts-list (E-mail)
Subject: design question

Hello

I have several questions about design, "best practises":

1)  Where to store client's profile information (like login name) ?
session  or system state bean ?

Use the HttpSession. But be aware that you should put as little as possible
into the session. Large sessions do not work well in a cluster.

2)  How to create and use a system state bean ?

System state bean should be in scope "session", shouldnt it ?

Again put as little as possible in the session and avoid statefull session
beans. If you must put a bean in the session, make it as small as possible,
ideally it would just hold key info that can be used to request beans at
request level when needed. This is a trade off between performance and
scalability.

3) Where to put business logic (where I invoke JDBC) ?
Should business logic class be a bean ?

If you have an app server business logic should go into a stateless session
bean (BusinessService), which is invoked (via a BusinessDelegate) from a
struts Action class. If you are not using EJBs then the Action class should
still invoke a business delegat

AW: Design question - Action Form vs Business Delegates/Value Objects

2001-11-23 Thread Roland Berger

Hi Francois

Will yor mapper framework become a part of jakarta commons? What are the
plans?
When should I use David Winterfeld's validation framework and when yours?
Can they work in parallel?
TIA
Roland

-Ursprüngliche Nachricht-
Von: Rey Francois [mailto:[EMAIL PROTECTED]]
Gesendet: Freitag, 23. November 2001 09:17
An: 'Struts Users Mailing List'
Betreff: RE: Design question - Action Form vs Business Delegates/Value
Objects


I've had the same problem as you describe and like yourself have created a
mapper framework, see http://husted.com/struts/resources/mapper.zip. It can
handle validation, conversion and transfer of data, all this based on XML
configuration. The framework is not dependent on Struts, but can easily
integrate with it.

For an overview of the motivations behind this framework, read this earlier
posting
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02058.html.

Fr.

-Original Message-
From: Sobkowski, Andrej [mailto:[EMAIL PROTECTED]]
Sent: 22 November 2001 19:28
To: 'Struts Users Mailing List'
Subject: Design question - Action Form vs Business Delegates/Value
Objects


Hello,

we're working on a quite large project with J2EE (including EJBs) and we're
using Struts (we're still in the early phases). To design a "clean"
application, I've defined different "object conversions":
* Request phase
- the ActionForm is converted to a Value Object
- the Value Object is passed to the EJBs
* Response phase
- the EJBs return one ore more Value Objects
- the Value Object(s) is (are) converted back to ActionForms.

I think it's a good approach, but:
- my ActionForm and Value Objects have an almost identical interface. The
main difference is that the ActionForm instance variables are always of type
String while for the Value Object  have "final types" information (Date,
Integer, whatever)
- the conversion "ActionForm to VO" and back is slowing down the performance
as my EJBs often return hundreds of VOs (each one to be converted to an
ActionForm).
I know this can be improved by using paging (Page-by-Page iterator) on both
the back-end and the front-end; furthermore, I've written a small "mapper"
that uses extensively the Reflection API to automatically perform the
mapping and this probably has an impact on the overall performance.

My question is: what are the best practices for this type of issues? Does
anybody have the same problems? Should I reduce the level of abstraction
between the layers?

Thank you!

Andrej

PS. if you're interested, I can share the simple mapper. It's a very small
mapper (less than 15k) that works fine with my app. It's waaay less
complete than the mapper on Ted Husted's site but...

-Original Message-
From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 12:10 PM
To: 'Struts Users Mailing List'
Subject: RE: design question




-Original Message-
From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]]
Sent: 22 November 2001 16:54
To: Struts-list (E-mail)
Subject: design question

Hello

I have several questions about design, "best practises":

1)  Where to store client's profile information (like login name) ?
session  or system state bean ?

Use the HttpSession. But be aware that you should put as little as possible
into the session. Large sessions do not work well in a cluster.

2)  How to create and use a system state bean ?

System state bean should be in scope "session", shouldnt it ?

Again put as little as possible in the session and avoid statefull session
beans. If you must put a bean in the session, make it as small as possible,
ideally it would just hold key info that can be used to request beans at
request level when needed. This is a trade off between performance and
scalability.

3) Where to put business logic (where I invoke JDBC) ?
Should business logic class be a bean ?

If you have an app server business logic should go into a stateless session
bean (BusinessService), which is invoked (via a BusinessDelegate) from a
struts Action class. If you are not using EJBs then the Action class should
still invoke a business delegate, but the delegate would simply create a
normal Java bean to act as the Business Service. The business service
(Stateless EJB or Java Bean) should delegate to another class to access a
datasource. If your are using EJBs this should be a CMP or BMP+DAO depending
on your app server (EJB 2 compliant consider CMP, else try CMP if supported
but be prepared to subclass to a BMP+DAO at a later date).

thanx in advance
Maris Orbidans


Jon Ridgway.

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

The information in this email is confidential and is intended solel

RE: Design question - Action Form vs Business Delegates/Value Objects

2001-11-23 Thread Rey Francois

I've had the same problem as you describe and like yourself have created a
mapper framework, see http://husted.com/struts/resources/mapper.zip. It can
handle validation, conversion and transfer of data, all this based on XML
configuration. The framework is not dependent on Struts, but can easily
integrate with it.

For an overview of the motivations behind this framework, read this earlier
posting
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02058.html.

Fr.

-Original Message-
From: Sobkowski, Andrej [mailto:[EMAIL PROTECTED]]
Sent: 22 November 2001 19:28
To: 'Struts Users Mailing List'
Subject: Design question - Action Form vs Business Delegates/Value
Objects


Hello,

we're working on a quite large project with J2EE (including EJBs) and we're
using Struts (we're still in the early phases). To design a "clean"
application, I've defined different "object conversions":
* Request phase
- the ActionForm is converted to a Value Object
- the Value Object is passed to the EJBs
* Response phase
- the EJBs return one ore more Value Objects
- the Value Object(s) is (are) converted back to ActionForms.

I think it's a good approach, but:
- my ActionForm and Value Objects have an almost identical interface. The
main difference is that the ActionForm instance variables are always of type
String while for the Value Object  have "final types" information (Date,
Integer, whatever)
- the conversion "ActionForm to VO" and back is slowing down the performance
as my EJBs often return hundreds of VOs (each one to be converted to an
ActionForm).
I know this can be improved by using paging (Page-by-Page iterator) on both
the back-end and the front-end; furthermore, I've written a small "mapper"
that uses extensively the Reflection API to automatically perform the
mapping and this probably has an impact on the overall performance.

My question is: what are the best practices for this type of issues? Does
anybody have the same problems? Should I reduce the level of abstraction
between the layers?

Thank you!

Andrej

PS. if you're interested, I can share the simple mapper. It's a very small
mapper (less than 15k) that works fine with my app. It's waaay less
complete than the mapper on Ted Husted's site but...

-Original Message-
From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 12:10 PM
To: 'Struts Users Mailing List'
Subject: RE: design question




-Original Message-
From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]] 
Sent: 22 November 2001 16:54
To: Struts-list (E-mail)
Subject: design question

Hello

I have several questions about design, "best practises":

1)  Where to store client's profile information (like login name) ?
session  or system state bean ?

Use the HttpSession. But be aware that you should put as little as possible
into the session. Large sessions do not work well in a cluster.

2)  How to create and use a system state bean ?

System state bean should be in scope "session", shouldnt it ?

Again put as little as possible in the session and avoid statefull session
beans. If you must put a bean in the session, make it as small as possible,
ideally it would just hold key info that can be used to request beans at
request level when needed. This is a trade off between performance and
scalability.

3) Where to put business logic (where I invoke JDBC) ?  
Should business logic class be a bean ?

If you have an app server business logic should go into a stateless session
bean (BusinessService), which is invoked (via a BusinessDelegate) from a
struts Action class. If you are not using EJBs then the Action class should
still invoke a business delegate, but the delegate would simply create a
normal Java bean to act as the Business Service. The business service
(Stateless EJB or Java Bean) should delegate to another class to access a
datasource. If your are using EJBs this should be a CMP or BMP+DAO depending
on your app server (EJB 2 compliant consider CMP, else try CMP if supported
but be prepared to subclass to a BMP+DAO at a later date).

thanx in advance
Maris Orbidans


Jon Ridgway.

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

The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, please notify the sender of this email 
immediately. You should not copy, use or disseminate the 
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com
***


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




AW: Design question - Action Form vs Business Delegates/Value Obj ects

2001-11-23 Thread Roland Berger

Hi all

If I'm right the initial question of Andrej was also how to do type
conversion between Value Objects and Action Forms (i.e property type in VO
is Date but in AF it is of type String). I don't have an elegant answer to
this but would also be interested to get this question answered. Not only
how to do it but also where to do type conversion (i.e. in the Action Form
Bean??)
Thanks
Roland


-Ursprungliche Nachricht-
Von: Dmitri Colebatch [mailto:[EMAIL PROTECTED]]
Gesendet: Freitag, 23. November 2001 04:37
An: Struts Users Mailing List
Betreff: Re: Design question - Action Form vs Business Delegates/Value
Obj ects


see my other email.  I understand the jsp side of it, I want to know how
the actionservlet deals with it.

cheesr
dim

On Fri, 23 Nov 2001, John Yu wrote:

> Struts supports nested and indexed properties. Doing this,
>
>
>
> Struts is clever enough to call myEmployeeBean.getEmployeeVO().getName().
>
> See
>
http://jakarta.apache.org/struts/api-1.0/org/apache/struts/taglib/bean/packa
ge-summary.html#doc.Properties
> and
>
http://jakarta.apache.org/struts/api-1.0/org/apache/struts/util/PropertyUtil
s.html.
>
>
> At 11:25 am 23-11-2001 +1100, you wrote:
> >but doesn't struts require the setName()/getName() to be JavaBean
> >compliant for populating the form with data before passing it to the
> >action?  or is there a way to tell struts to do differently?
> >
> >I agree the my way is much more typing :(
> >
> >cheers
> >dim
> >
> >On Thu, 22 Nov 2001, Michelle Popovits wrote:
> >
> > > Hi Dim,
> > >
> > > Your example is similar to my approach with the exception that you are
> > still
> > > duplicating
> > > methods of the value object inside of the action form.  Instead of
> > including
> > > the individual accessors in the form, just include
> > > the accessor for the value object (see my original example)...much
less
> > > unnecessary typing this way.
> > > When you need to access the value object properties in java you just
> > cal the
> > > employeeForm.getEmployeeVo().getName() method and when you are in a
jsp and
> > > want to bind the value object property to a text field you refer to
the
> > > property as "employeeVo.name".
> > >
> > > HTH,
> > > Michelle
> > >
> > > - Original Message -
> > > From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > Cc: <[EMAIL PROTECTED]>
> > > Sent: Thursday, November 22, 2001 5:34 PM
> > > Subject: RE: Design question - Action Form vs Business Delegates/Value
Obj
> > > ects
> > >
> > >
> > > > Hi,
> > > >
> > > > I also agree with Michelle...
> > > >
> > > > I think what you are thinking is maybe you could use the struts form
_as_
> > > > the value object?  imho this would be bad design, as the whole idea
of
> > > > putting the logic in a separate tier is to have it not bound to any
one
> > > > form of presentation.  What Michelle is suggesting though, is
something
> > > > like:
> > > >
> > > > public class EmployeeForm extends ActionForm
> > > > {
> > > >   private EmployeeVO vo = new EmployeeVO();
> > > >
> > > >   public String getName()
> > > >   {
> > > > return vo.getName();
> > > >   }
> > > >
> > > >   public void setName(String name)
> > > >   {
> > > > vo.setName(name);
> > > >   }
> > > >
> > > >   // and so on
> > > >
> > > >   // get the vo
> > > >   public EmployeeVO getEmployeeVO()
> > > >   {
> > > > return vo;
> > > >   }
> > > > }
> > > >
> > > > so say you have an action class:
> > > >
> > > > public class AddEmployeeAction()
> > > > {
> > > >   public void perform( ... )
> > > >   {
> > > > EmployeeForm eform = (EmployeeForm) form;
> > > > employeeManager.add(eform.getEmployeeVO());
> > > >   }
> > > > }
> > > >
> > > > etc... very simplified example, but hopefully this is a bit
clearer... I
> > > > use this all the time, and would be interested to hear what other
ppl
> > > > think as well...
> > > >
> > > > cheers
> > > > dim
> > &g

Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Dmitri Colebatch

see my other email.  I understand the jsp side of it, I want to know how
the actionservlet deals with it.

cheesr
dim

On Fri, 23 Nov 2001, John Yu wrote:

> Struts supports nested and indexed properties. Doing this,
> 
>
> 
> Struts is clever enough to call myEmployeeBean.getEmployeeVO().getName().
> 
> See 
> 
>http://jakarta.apache.org/struts/api-1.0/org/apache/struts/taglib/bean/package-summary.html#doc.Properties
> 
> and 
> http://jakarta.apache.org/struts/api-1.0/org/apache/struts/util/PropertyUtils.html.
> 
> 
> At 11:25 am 23-11-2001 +1100, you wrote:
> >but doesn't struts require the setName()/getName() to be JavaBean
> >compliant for populating the form with data before passing it to the
> >action?  or is there a way to tell struts to do differently?
> >
> >I agree the my way is much more typing :(
> >
> >cheers
> >dim
> >
> >On Thu, 22 Nov 2001, Michelle Popovits wrote:
> >
> > > Hi Dim,
> > >
> > > Your example is similar to my approach with the exception that you are 
> > still
> > > duplicating
> > > methods of the value object inside of the action form.  Instead of 
> > including
> > > the individual accessors in the form, just include
> > > the accessor for the value object (see my original example)...much less
> > > unnecessary typing this way.
> > > When you need to access the value object properties in java you just 
> > cal the
> > > employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
> > > want to bind the value object property to a text field you refer to the
> > > property as "employeeVo.name".
> > >
> > > HTH,
> > > Michelle
> > >
> > > - Original Message -
> > > From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > Cc: <[EMAIL PROTECTED]>
> > > Sent: Thursday, November 22, 2001 5:34 PM
> > > Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
> > > ects
> > >
> > >
> > > > Hi,
> > > >
> > > > I also agree with Michelle...
> > > >
> > > > I think what you are thinking is maybe you could use the struts form _as_
> > > > the value object?  imho this would be bad design, as the whole idea of
> > > > putting the logic in a separate tier is to have it not bound to any one
> > > > form of presentation.  What Michelle is suggesting though, is something
> > > > like:
> > > >
> > > > public class EmployeeForm extends ActionForm
> > > > {
> > > >   private EmployeeVO vo = new EmployeeVO();
> > > >
> > > >   public String getName()
> > > >   {
> > > > return vo.getName();
> > > >   }
> > > >
> > > >   public void setName(String name)
> > > >   {
> > > > vo.setName(name);
> > > >   }
> > > >
> > > >   // and so on
> > > >
> > > >   // get the vo
> > > >   public EmployeeVO getEmployeeVO()
> > > >   {
> > > > return vo;
> > > >   }
> > > > }
> > > >
> > > > so say you have an action class:
> > > >
> > > > public class AddEmployeeAction()
> > > > {
> > > >   public void perform( ... )
> > > >   {
> > > > EmployeeForm eform = (EmployeeForm) form;
> > > > employeeManager.add(eform.getEmployeeVO());
> > > >   }
> > > > }
> > > >
> > > > etc... very simplified example, but hopefully this is a bit clearer... I
> > > > use this all the time, and would be interested to hear what other ppl
> > > > think as well...
> > > >
> > > > cheers
> > > > dim
> > > >
> > > > On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
> > > >
> > > > > Michelle,
> > > > >
> > > > > thanks for your reply... but I'm not sure I understand your answer.
> > > Probably
> > > > > my message wasn't clear.
> > > > >
> > > > > To use an example, I have:
> > > > >
> > > > > EmployeeForm extends ActionForm
> > > > > +getName():String
> > > > > +getAge():String
> > > > > +getDateOfBirth():String

Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Dmitri Colebatch

yes, thats fine _in the jsp_ my question is at the other end... for
instance:

  1. user completes form values and submits
  2. struts actionservlet receives post and extracts parameters out of it
  3. struts actionservlet maps the request to an action and instantiates
the form for the action
  4. struts actionservlet copies parameters from http post to the form

this is where I am unsure of why your approach is able to work.  I can see
if you populate the form yourself then you will be able to call those
methods yourself but how does step 4 take place if you dont tell
struts that it needs to call form.getEmployeeVo()?  The only place you
have talked about doing that is in JSPs... for this to work, I would
expect some configuration directive...?

cheers
dim

On Thu, 22 Nov 2001, Michelle Popovits wrote:

> Hi Dim,
> 
> Your example is similar to my approach with the exception that you are still
> duplicating
> methods of the value object inside of the action form.  Instead of including
> the individual accessors in the form, just include
> the accessor for the value object (see my original example)...much less
> unnecessary typing this way.
> When you need to access the value object properties in java you just cal the
> employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
> want to bind the value object property to a text field you refer to the
> property as "employeeVo.name".
> 
> HTH,
> Michelle
> 
> - Original Message -
> From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, November 22, 2001 5:34 PM
> Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
> ects
> 
> 
> > Hi,
> >
> > I also agree with Michelle...
> >
> > I think what you are thinking is maybe you could use the struts form _as_
> > the value object?  imho this would be bad design, as the whole idea of
> > putting the logic in a separate tier is to have it not bound to any one
> > form of presentation.  What Michelle is suggesting though, is something
> > like:
> >
> > public class EmployeeForm extends ActionForm
> > {
> >   private EmployeeVO vo = new EmployeeVO();
> >
> >   public String getName()
> >   {
> > return vo.getName();
> >   }
> >
> >   public void setName(String name)
> >   {
> > vo.setName(name);
> >   }
> >
> >   // and so on
> >
> >   // get the vo
> >   public EmployeeVO getEmployeeVO()
> >   {
> > return vo;
> >   }
> > }
> >
> > so say you have an action class:
> >
> > public class AddEmployeeAction()
> > {
> >   public void perform( ... )
> >   {
> > EmployeeForm eform = (EmployeeForm) form;
> > employeeManager.add(eform.getEmployeeVO());
> >   }
> > }
> >
> > etc... very simplified example, but hopefully this is a bit clearer... I
> > use this all the time, and would be interested to hear what other ppl
> > think as well...
> >
> > cheers
> > dim
> >
> > On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
> >
> > > Michelle,
> > >
> > > thanks for your reply... but I'm not sure I understand your answer.
> Probably
> > > my message wasn't clear.
> > >
> > > To use an example, I have:
> > >
> > > EmployeeForm extends ActionForm
> > > +getName():String
> > > +getAge():String
> > > +getDateOfBirth():String
> > >
> > > EmployeeVO
> > > +getName():String
> > > +getAge():Integer
> > > +getDateOfBirth():Date
> > >
> > > EmployeeForm is a simple Struts mapping of the data displayed on the
> HTML
> > > page. EmployeeVO is the intermediate value/business object where the
> fields
> > > have a "real" meaning (a Date is a Date).
> > >
> > > I don't see the reasons of making EmployeeVO an instance variable of
> > > EmployeeForm. And EmployeeVO can not be used directly inside Struts to
> map
> > > data from an HttpRequest because (I think) that only Strings (and int?)
> can
> > > be handled in ActionForms.
> > >
> > > My question was somehow: should I get rid of EmployeeVO? It certainly
> makes
> > > the application cleaner but it may just be a "picky thing" that will
> simply
> > > waste resources.
> > >
> > > Thanks.
> > >
> > > Andrej
> > > -Original Message-

Re: Design question - Action Form vs Business Delegates/Value Obj ects

2001-11-22 Thread John Yu

Struts supports nested and indexed properties. Doing this,

   

Struts is clever enough to call myEmployeeBean.getEmployeeVO().getName().

See 
http://jakarta.apache.org/struts/api-1.0/org/apache/struts/taglib/bean/package-summary.html#doc.Properties
 
and 
http://jakarta.apache.org/struts/api-1.0/org/apache/struts/util/PropertyUtils.html.


At 11:25 am 23-11-2001 +1100, you wrote:
>but doesn't struts require the setName()/getName() to be JavaBean
>compliant for populating the form with data before passing it to the
>action?  or is there a way to tell struts to do differently?
>
>I agree the my way is much more typing :(
>
>cheers
>dim
>
>On Thu, 22 Nov 2001, Michelle Popovits wrote:
>
> > Hi Dim,
> >
> > Your example is similar to my approach with the exception that you are 
> still
> > duplicating
> > methods of the value object inside of the action form.  Instead of 
> including
> > the individual accessors in the form, just include
> > the accessor for the value object (see my original example)...much less
> > unnecessary typing this way.
> > When you need to access the value object properties in java you just 
> cal the
> > employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
> > want to bind the value object property to a text field you refer to the
> > property as "employeeVo.name".
> >
> > HTH,
> > Michelle
> >
> > - Original Message -
> > From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Thursday, November 22, 2001 5:34 PM
> > Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
> > ects
> >
> >
> > > Hi,
> > >
> > > I also agree with Michelle...
> > >
> > > I think what you are thinking is maybe you could use the struts form _as_
> > > the value object?  imho this would be bad design, as the whole idea of
> > > putting the logic in a separate tier is to have it not bound to any one
> > > form of presentation.  What Michelle is suggesting though, is something
> > > like:
> > >
> > > public class EmployeeForm extends ActionForm
> > > {
> > >   private EmployeeVO vo = new EmployeeVO();
> > >
> > >   public String getName()
> > >   {
> > > return vo.getName();
> > >   }
> > >
> > >   public void setName(String name)
> > >   {
> > > vo.setName(name);
> > >   }
> > >
> > >   // and so on
> > >
> > >   // get the vo
> > >   public EmployeeVO getEmployeeVO()
> > >   {
> > > return vo;
> > >   }
> > > }
> > >
> > > so say you have an action class:
> > >
> > > public class AddEmployeeAction()
> > > {
> > >   public void perform( ... )
> > >   {
> > > EmployeeForm eform = (EmployeeForm) form;
> > > employeeManager.add(eform.getEmployeeVO());
> > >   }
> > > }
> > >
> > > etc... very simplified example, but hopefully this is a bit clearer... I
> > > use this all the time, and would be interested to hear what other ppl
> > > think as well...
> > >
> > > cheers
> > > dim
> > >
> > > On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
> > >
> > > > Michelle,
> > > >
> > > > thanks for your reply... but I'm not sure I understand your answer.
> > Probably
> > > > my message wasn't clear.
> > > >
> > > > To use an example, I have:
> > > >
> > > > EmployeeForm extends ActionForm
> > > > +getName():String
> > > > +getAge():String
> > > > +getDateOfBirth():String
> > > >
> > > > EmployeeVO
> > > > +getName():String
> > > > +getAge():Integer
> > > > +getDateOfBirth():Date
> > > >
> > > > EmployeeForm is a simple Struts mapping of the data displayed on the
> > HTML
> > > > page. EmployeeVO is the intermediate value/business object where the
> > fields
> > > > have a "real" meaning (a Date is a Date).
> > > >
> > > > I don't see the reasons of making EmployeeVO an instance variable of
> > > > EmployeeForm. And EmployeeVO can not be used directly inside Struts to
> > map
> > > > data fro

Re: Design question - Action Form vs Business Delegates/Value Obj ects

2001-11-22 Thread Michelle Popovits

Hi Dim,

Your example is similar to my approach with the exception that you are still
duplicating
methods of the value object inside of the action form.  Instead of including
the individual accessors in the form, just include
the accessor for the value object (see my original example)...much less
unnecessary typing this way.
When you need to access the value object properties in java you just cal the
employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
want to bind the value object property to a text field you refer to the
property as "employeeVo.name".

HTH,
Michelle

- Original Message -
From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, November 22, 2001 5:34 PM
Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
ects


> Hi,
>
> I also agree with Michelle...
>
> I think what you are thinking is maybe you could use the struts form _as_
> the value object?  imho this would be bad design, as the whole idea of
> putting the logic in a separate tier is to have it not bound to any one
> form of presentation.  What Michelle is suggesting though, is something
> like:
>
> public class EmployeeForm extends ActionForm
> {
>   private EmployeeVO vo = new EmployeeVO();
>
>   public String getName()
>   {
> return vo.getName();
>   }
>
>   public void setName(String name)
>   {
> vo.setName(name);
>   }
>
>   // and so on
>
>   // get the vo
>   public EmployeeVO getEmployeeVO()
>   {
> return vo;
>   }
> }
>
> so say you have an action class:
>
> public class AddEmployeeAction()
> {
>   public void perform( ... )
>   {
> EmployeeForm eform = (EmployeeForm) form;
> employeeManager.add(eform.getEmployeeVO());
>   }
> }
>
> etc... very simplified example, but hopefully this is a bit clearer... I
> use this all the time, and would be interested to hear what other ppl
> think as well...
>
> cheers
> dim
>
> On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
>
> > Michelle,
> >
> > thanks for your reply... but I'm not sure I understand your answer.
Probably
> > my message wasn't clear.
> >
> > To use an example, I have:
> >
> > EmployeeForm extends ActionForm
> > +getName():String
> > +getAge():String
> > +getDateOfBirth():String
> >
> > EmployeeVO
> > +getName():String
> > +getAge():Integer
> > +getDateOfBirth():Date
> >
> > EmployeeForm is a simple Struts mapping of the data displayed on the
HTML
> > page. EmployeeVO is the intermediate value/business object where the
fields
> > have a "real" meaning (a Date is a Date).
> >
> > I don't see the reasons of making EmployeeVO an instance variable of
> > EmployeeForm. And EmployeeVO can not be used directly inside Struts to
map
> > data from an HttpRequest because (I think) that only Strings (and int?)
can
> > be handled in ActionForms.
> >
> > My question was somehow: should I get rid of EmployeeVO? It certainly
makes
> > the application cleaner but it may just be a "picky thing" that will
simply
> > waste resources.
> >
> > Thanks.
> >
> > Andrej
> > -Original Message-
> > From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, November 22, 2001 4:13 PM
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: Design question - Action Form vs Business Delegates/Value
> > Objects
> >
> >
> > Hi,
> >
> > I suggest to not duplicate variables that are in your Value Objects in
your
> > form object.  Instead include the value object as a member of the the
form
> > object.
> >
> > ie.
> >
> > Form class - below the AccountVo is a value object within the form bean
> >
> > public class AddAccountForm extends ActionForm {
> > 
> >
> >   public AccountVo getAccount() {
> >   return account;
> >   }
> >
> >   public void setAccount(AccountVo aAccount) {
> >   account = aAccount;
> >   }
> >
> > 
> > }
> >
> > Then, in your jsp you reference the accountvo members like so using the
dot
> > notation -- the property "account.password" gets converted to
> > getAccount().getPassword() or getAccount().setPassword(value).
> >
> > 
> >  > maxlength="100" />
> >
> >
> > This feature of struts/javabeans is a real time saver in terms of
> > development.  Once something is in a value obj

RE: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Matthew O'Haire

Hello everyone,

I also agree...

We also use struts in J2EE apps with and make use of the Value Object
pattern. (http://www.tstrata.trysoft.com)

We assign the VO as a member of the ActionForm.  If we want to abstract the
VO, we add accessor methods to the Form as Dmitri has explained...  these
are all fairly well recognised design patterns.

You definately DON'T want to pass struts concepts into your business layer
(EJB's)!

Maybe it's time for a sample application using struts and EJB's... based on
JBoss perhaps... something that showcases EJB/Struts design patterns.  Is
there one already?

Matt O'Haire
Trysoft Corporation Ltd.
http://www.trysoft.com


-Original Message-
From: Dmitri Colebatch [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 23, 2001 08:35
To: Struts Users Mailing List
Cc: '[EMAIL PROTECTED]'
Subject: RE: Design question - Action Form vs Business Delegates/Value
Objects


Hi,

I also agree with Michelle...

I think what you are thinking is maybe you could use the struts form _as_
the value object?  imho this would be bad design, as the whole idea of
putting the logic in a separate tier is to have it not bound to any one
form of presentation.  What Michelle is suggesting though, is something
like:

public class EmployeeForm extends ActionForm
{
  private EmployeeVO vo = new EmployeeVO();

  public String getName()
  {
return vo.getName();
  }

  public void setName(String name)
  { 
vo.setName(name);
  }

  // and so on

  // get the vo
  public EmployeeVO getEmployeeVO()
  { 
return vo;
  }
}

so say you have an action class:

public class AddEmployeeAction()
{
  public void perform( ... )
  { 
EmployeeForm eform = (EmployeeForm) form;
employeeManager.add(eform.getEmployeeVO());
  }
}

etc... very simplified example, but hopefully this is a bit clearer... I
use this all the time, and would be interested to hear what other ppl
think as well...

cheers
dim




RE: design question

2001-11-22 Thread Lai Kok Cheong

It is quite tricky to answer your question as you did not mention additional
info i.e best practices is also depend on the  application size ( how much
client it will cater and for what purpose )
anyway this is what I hope you'll get something from my assumption :-
1) if the number of client is not too many i.e only have 100 + but no more
than or never goes beyond 100 000 ( the number is abitrary , just to show
you how big is big )
then session will be the choice since it is faster  to retrieve the data ,
but if you 're going to have many clients then state bean will be more
efficient since the session will used up your memory while the state bean (
session bean) will passivate if it is not used ( and save the memory ) 

2) Please refer to the www.javasoft.com website and find the EJB tutorial
from there 
3) That depend on your architecture.basically the bean should stick to the
javabeans specification design and should not have any jdbc calls ( but
there is an exceptio for that . i.e if you create a bean for your taglibs
you'll need to embed the jdbc to it )


> -Original Message-
> From: Màris Orbidàns [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, November 22, 2001 4:54 PM
> To:   Struts-list (E-mail)
> Subject:  design question
> 
> Hello
> 
> I have several questions about design, "best practises":
> 
> 1)  Where to store client's profile information (like login name) ?
> session  or system state bean ?
> 
> 2)  How to create and use a system state bean ?
> 
> System state bean should be in scope "session", shouldnt it ?
> 
> 3) Where to put business logic (where I invoke JDBC) ?  
>   Should business logic class be a bean ?
> 
> thanx in advance
> Maris Orbidans
>   
> 
> 
> --
> 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 question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Dmitri Colebatch

but doesn't struts require the setName()/getName() to be JavaBean
compliant for populating the form with data before passing it to the
action?  or is there a way to tell struts to do differently?

I agree the my way is much more typing :(

cheers
dim

On Thu, 22 Nov 2001, Michelle Popovits wrote:

> Hi Dim,
> 
> Your example is similar to my approach with the exception that you are still
> duplicating
> methods of the value object inside of the action form.  Instead of including
> the individual accessors in the form, just include
> the accessor for the value object (see my original example)...much less
> unnecessary typing this way.
> When you need to access the value object properties in java you just cal the
> employeeForm.getEmployeeVo().getName() method and when you are in a jsp and
> want to bind the value object property to a text field you refer to the
> property as "employeeVo.name".
> 
> HTH,
> Michelle
> 
> - Original Message -
> From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, November 22, 2001 5:34 PM
> Subject: RE: Design question - Action Form vs Business Delegates/Value Obj
> ects
> 
> 
> > Hi,
> >
> > I also agree with Michelle...
> >
> > I think what you are thinking is maybe you could use the struts form _as_
> > the value object?  imho this would be bad design, as the whole idea of
> > putting the logic in a separate tier is to have it not bound to any one
> > form of presentation.  What Michelle is suggesting though, is something
> > like:
> >
> > public class EmployeeForm extends ActionForm
> > {
> >   private EmployeeVO vo = new EmployeeVO();
> >
> >   public String getName()
> >   {
> > return vo.getName();
> >   }
> >
> >   public void setName(String name)
> >   {
> > vo.setName(name);
> >   }
> >
> >   // and so on
> >
> >   // get the vo
> >   public EmployeeVO getEmployeeVO()
> >   {
> > return vo;
> >   }
> > }
> >
> > so say you have an action class:
> >
> > public class AddEmployeeAction()
> > {
> >   public void perform( ... )
> >   {
> > EmployeeForm eform = (EmployeeForm) form;
> > employeeManager.add(eform.getEmployeeVO());
> >   }
> > }
> >
> > etc... very simplified example, but hopefully this is a bit clearer... I
> > use this all the time, and would be interested to hear what other ppl
> > think as well...
> >
> > cheers
> > dim
> >
> > On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:
> >
> > > Michelle,
> > >
> > > thanks for your reply... but I'm not sure I understand your answer.
> Probably
> > > my message wasn't clear.
> > >
> > > To use an example, I have:
> > >
> > > EmployeeForm extends ActionForm
> > > +getName():String
> > > +getAge():String
> > > +getDateOfBirth():String
> > >
> > > EmployeeVO
> > > +getName():String
> > > +getAge():Integer
> > > +getDateOfBirth():Date
> > >
> > > EmployeeForm is a simple Struts mapping of the data displayed on the
> HTML
> > > page. EmployeeVO is the intermediate value/business object where the
> fields
> > > have a "real" meaning (a Date is a Date).
> > >
> > > I don't see the reasons of making EmployeeVO an instance variable of
> > > EmployeeForm. And EmployeeVO can not be used directly inside Struts to
> map
> > > data from an HttpRequest because (I think) that only Strings (and int?)
> can
> > > be handled in ActionForms.
> > >
> > > My question was somehow: should I get rid of EmployeeVO? It certainly
> makes
> > > the application cleaner but it may just be a "picky thing" that will
> simply
> > > waste resources.
> > >
> > > Thanks.
> > >
> > > Andrej
> > > -Original Message-
> > > From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, November 22, 2001 4:13 PM
> > > To: [EMAIL PROTECTED]
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: Design question - Action Form vs Business Delegates/Value
> > > Objects
> > >
> > >
> > > Hi,
> > >
> > > I suggest to not duplicate variables that are in your Value Objects in
> your
> > > form object.  Instead include the value obje

RE: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Dmitri Colebatch

Hi,

I also agree with Michelle...

I think what you are thinking is maybe you could use the struts form _as_
the value object?  imho this would be bad design, as the whole idea of
putting the logic in a separate tier is to have it not bound to any one
form of presentation.  What Michelle is suggesting though, is something
like:

public class EmployeeForm extends ActionForm
{
  private EmployeeVO vo = new EmployeeVO();

  public String getName()
  {
return vo.getName();
  }

  public void setName(String name)
  { 
vo.setName(name);
  }

  // and so on

  // get the vo
  public EmployeeVO getEmployeeVO()
  { 
return vo;
  }
}

so say you have an action class:

public class AddEmployeeAction()
{
  public void perform( ... )
  { 
EmployeeForm eform = (EmployeeForm) form;
employeeManager.add(eform.getEmployeeVO());
  }
}

etc... very simplified example, but hopefully this is a bit clearer... I
use this all the time, and would be interested to hear what other ppl
think as well...

cheers
dim

On Thu, 22 Nov 2001, Sobkowski, Andrej wrote:

> Michelle,
> 
> thanks for your reply... but I'm not sure I understand your answer. Probably
> my message wasn't clear.
> 
> To use an example, I have:
> 
> EmployeeForm extends ActionForm
> +getName():String
> +getAge():String
> +getDateOfBirth():String
> 
> EmployeeVO
> +getName():String
> +getAge():Integer
> +getDateOfBirth():Date
> 
> EmployeeForm is a simple Struts mapping of the data displayed on the HTML
> page. EmployeeVO is the intermediate value/business object where the fields
> have a "real" meaning (a Date is a Date).
> 
> I don't see the reasons of making EmployeeVO an instance variable of
> EmployeeForm. And EmployeeVO can not be used directly inside Struts to map
> data from an HttpRequest because (I think) that only Strings (and int?) can
> be handled in ActionForms.
> 
> My question was somehow: should I get rid of EmployeeVO? It certainly makes
> the application cleaner but it may just be a "picky thing" that will simply
> waste resources.
> 
> Thanks.
> 
> Andrej
> -Original Message-
> From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 22, 2001 4:13 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Design question - Action Form vs Business Delegates/Value
> Objects
> 
> 
> Hi,
> 
> I suggest to not duplicate variables that are in your Value Objects in your 
> form object.  Instead include the value object as a member of the the form 
> object.
> 
> ie.
> 
> Form class - below the AccountVo is a value object within the form bean
> 
> public class AddAccountForm extends ActionForm {
> 
> 
>   public AccountVo getAccount() {
>   return account;
>   }
> 
>   public void setAccount(AccountVo aAccount) {
>   account = aAccount;
>   }
> 
> 
> }
> 
> Then, in your jsp you reference the accountvo members like so using the dot 
> notation -- the property "account.password" gets converted to 
> getAccount().getPassword() or getAccount().setPassword(value).
> 
> 
>  maxlength="100" />
> 
> 
> This feature of struts/javabeans is a real time saver in terms of 
> development.  Once something is in a value object then that value object 
> gets passed from the back-end all the way to the front end without needing 
> to touch any of it's attributes.  And if you're editing the data on a web 
> page when you submit the page the new data automatically gets set into the 
> value object which can then be passed to the back end (no unnecessary 
> handling of the data).
> 
> HTH,
> Michelle
> 
> >From: "Sobkowski, Andrej" <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> >Subject: Design question - Action Form vs Business Delegates/Value Objects
> >Date: Thu, 22 Nov 2001 13:28:05 -0500
> >
> >Hello,
> >
> >we're working on a quite large project with J2EE (including EJBs) and we're
> >using Struts (we're still in the early phases). To design a "clean"
> >application, I've defined different "object conversions":
> >* Request phase
> >- the ActionForm is converted to a Value Object
> >- the Value Object is passed to the EJBs
> >* Response phase
> >- the EJBs return one ore more Value Objects
> >- the Value Object(s) is (are) converted back to ActionForms.
> >
> >I think it's a good approach, but:
> >- my ActionForm and Value Objects have an almost identical interface. 

Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Sandeep Takhar

I'm interested in this mapper you talked about,

thanks,


btw: What is the difference between this one and the
one on Ted Husted's?  Are you talking about Mapco?

Sandeep
--- "Sobkowski, Andrej" <[EMAIL PROTECTED]>
wrote:
> Hello,
> 
> we're working on a quite large project with J2EE
> (including EJBs) and we're
> using Struts (we're still in the early phases). To
> design a "clean"
> application, I've defined different "object
> conversions":
> * Request phase
> - the ActionForm is converted to a Value Object
> - the Value Object is passed to the EJBs
> * Response phase
> - the EJBs return one ore more Value Objects
> - the Value Object(s) is (are) converted back to
> ActionForms.
> 
> I think it's a good approach, but:
> - my ActionForm and Value Objects have an almost
> identical interface. The
> main difference is that the ActionForm instance
> variables are always of type
> String while for the Value Object  have "final
> types" information (Date,
> Integer, whatever)
> - the conversion "ActionForm to VO" and back is
> slowing down the performance
> as my EJBs often return hundreds of VOs (each one to
> be converted to an
> ActionForm).
> I know this can be improved by using paging
> (Page-by-Page iterator) on both
> the back-end and the front-end; furthermore, I've
> written a small "mapper"
> that uses extensively the Reflection API to
> automatically perform the
> mapping and this probably has an impact on the
> overall performance.
> 
> My question is: what are the best practices for this
> type of issues? Does
> anybody have the same problems? Should I reduce the
> level of abstraction
> between the layers?
> 
> Thank you!
> 
> Andrej
> 
> PS. if you're interested, I can share the simple
> mapper. It's a very small
> mapper (less than 15k) that works fine with my app.
> It's waaay less
> complete than the mapper on Ted Husted's site but...
> 
> -Original Message-
> From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 22, 2001 12:10 PM
> To: 'Struts Users Mailing List'
> Subject: RE: design question
> 
> 
> 
> 
> -Original Message-
> From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]] 
> Sent: 22 November 2001 16:54
> To: Struts-list (E-mail)
> Subject: design question
> 
> Hello
> 
> I have several questions about design, "best
> practises":
> 
> 1)  Where to store client's profile information
> (like login name) ?
> session  or system state bean ?
> 
> Use the HttpSession. But be aware that you should
> put as little as possible
> into the session. Large sessions do not work well in
> a cluster.
> 
> 2)  How to create and use a system state bean ?
> 
> System state bean should be in scope "session",
> shouldnt it ?
> 
> Again put as little as possible in the session and
> avoid statefull session
> beans. If you must put a bean in the session, make
> it as small as possible,
> ideally it would just hold key info that can be used
> to request beans at
> request level when needed. This is a trade off
> between performance and
> scalability.
> 
> 3) Where to put business logic (where I invoke JDBC)
> ?  
>   Should business logic class be a bean ?
> 
> If you have an app server business logic should go
> into a stateless session
> bean (BusinessService), which is invoked (via a
> BusinessDelegate) from a
> struts Action class. If you are not using EJBs then
> the Action class should
> still invoke a business delegate, but the delegate
> would simply create a
> normal Java bean to act as the Business Service. The
> business service
> (Stateless EJB or Java Bean) should delegate to
> another class to access a
> datasource. If your are using EJBs this should be a
> CMP or BMP+DAO depending
> on your app server (EJB 2 compliant consider CMP,
> else try CMP if supported
> but be prepared to subclass to a BMP+DAO at a later
> date).
> 
> thanx in advance
> Maris Orbidans
>   
> 
> Jon Ridgway.
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 


__
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

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




RE: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Sobkowski, Andrej

Michelle,

thanks for your reply... but I'm not sure I understand your answer. Probably
my message wasn't clear.

To use an example, I have:

EmployeeForm extends ActionForm
+getName():String
+getAge():String
+getDateOfBirth():String

EmployeeVO
+getName():String
+getAge():Integer
+getDateOfBirth():Date

EmployeeForm is a simple Struts mapping of the data displayed on the HTML
page. EmployeeVO is the intermediate value/business object where the fields
have a "real" meaning (a Date is a Date).

I don't see the reasons of making EmployeeVO an instance variable of
EmployeeForm. And EmployeeVO can not be used directly inside Struts to map
data from an HttpRequest because (I think) that only Strings (and int?) can
be handled in ActionForms.

My question was somehow: should I get rid of EmployeeVO? It certainly makes
the application cleaner but it may just be a "picky thing" that will simply
waste resources.

Thanks.

Andrej
-Original Message-
From: Michelle Popovits [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 4:13 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Design question - Action Form vs Business Delegates/Value
Objects


Hi,

I suggest to not duplicate variables that are in your Value Objects in your 
form object.  Instead include the value object as a member of the the form 
object.

ie.

Form class - below the AccountVo is a value object within the form bean

public class AddAccountForm extends ActionForm {


  public AccountVo getAccount() {
return account;
  }

  public void setAccount(AccountVo aAccount) {
account = aAccount;
  }


}

Then, in your jsp you reference the accountvo members like so using the dot 
notation -- the property "account.password" gets converted to 
getAccount().getPassword() or getAccount().setPassword(value).





This feature of struts/javabeans is a real time saver in terms of 
development.  Once something is in a value object then that value object 
gets passed from the back-end all the way to the front end without needing 
to touch any of it's attributes.  And if you're editing the data on a web 
page when you submit the page the new data automatically gets set into the 
value object which can then be passed to the back end (no unnecessary 
handling of the data).

HTH,
Michelle

>From: "Sobkowski, Andrej" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
>Subject: Design question - Action Form vs Business Delegates/Value Objects
>Date: Thu, 22 Nov 2001 13:28:05 -0500
>
>Hello,
>
>we're working on a quite large project with J2EE (including EJBs) and we're
>using Struts (we're still in the early phases). To design a "clean"
>application, I've defined different "object conversions":
>* Request phase
>- the ActionForm is converted to a Value Object
>- the Value Object is passed to the EJBs
>* Response phase
>- the EJBs return one ore more Value Objects
>- the Value Object(s) is (are) converted back to ActionForms.
>
>I think it's a good approach, but:
>- my ActionForm and Value Objects have an almost identical interface. The
>main difference is that the ActionForm instance variables are always of 
>type
>String while for the Value Object  have "final types" information (Date,
>Integer, whatever)
>- the conversion "ActionForm to VO" and back is slowing down the 
>performance
>as my EJBs often return hundreds of VOs (each one to be converted to an
>ActionForm).
>I know this can be improved by using paging (Page-by-Page iterator) on both
>the back-end and the front-end; furthermore, I've written a small "mapper"
>that uses extensively the Reflection API to automatically perform the
>mapping and this probably has an impact on the overall performance.
>
>My question is: what are the best practices for this type of issues? Does
>anybody have the same problems? Should I reduce the level of abstraction
>between the layers?
>
>Thank you!
>
>Andrej
>
>PS. if you're interested, I can share the simple mapper. It's a very small
>mapper (less than 15k) that works fine with my app. It's waaay less
>complete than the mapper on Ted Husted's site but...
>
>-Original Message-
>From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, November 22, 2001 12:10 PM
>To: 'Struts Users Mailing List'
>Subject: RE: design question
>
>
>
>
>-Original Message-
>From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]]
>Sent: 22 November 2001 16:54
>To: Struts-list (E-mail)
>Subject: design question
>
>Hello
>
>I have several questions about 

Re: Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Michelle Popovits

Hi,

I suggest to not duplicate variables that are in your Value Objects in your 
form object.  Instead include the value object as a member of the the form 
object.

ie.

Form class - below the AccountVo is a value object within the form bean

public class AddAccountForm extends ActionForm {


  public AccountVo getAccount() {
return account;
  }

  public void setAccount(AccountVo aAccount) {
account = aAccount;
  }


}

Then, in your jsp you reference the accountvo members like so using the dot 
notation -- the property "account.password" gets converted to 
getAccount().getPassword() or getAccount().setPassword(value).





This feature of struts/javabeans is a real time saver in terms of 
development.  Once something is in a value object then that value object 
gets passed from the back-end all the way to the front end without needing 
to touch any of it's attributes.  And if you're editing the data on a web 
page when you submit the page the new data automatically gets set into the 
value object which can then be passed to the back end (no unnecessary 
handling of the data).

HTH,
Michelle

>From: "Sobkowski, Andrej" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
>Subject: Design question - Action Form vs Business Delegates/Value Objects
>Date: Thu, 22 Nov 2001 13:28:05 -0500
>
>Hello,
>
>we're working on a quite large project with J2EE (including EJBs) and we're
>using Struts (we're still in the early phases). To design a "clean"
>application, I've defined different "object conversions":
>* Request phase
>- the ActionForm is converted to a Value Object
>- the Value Object is passed to the EJBs
>* Response phase
>- the EJBs return one ore more Value Objects
>- the Value Object(s) is (are) converted back to ActionForms.
>
>I think it's a good approach, but:
>- my ActionForm and Value Objects have an almost identical interface. The
>main difference is that the ActionForm instance variables are always of 
>type
>String while for the Value Object  have "final types" information (Date,
>Integer, whatever)
>- the conversion "ActionForm to VO" and back is slowing down the 
>performance
>as my EJBs often return hundreds of VOs (each one to be converted to an
>ActionForm).
>I know this can be improved by using paging (Page-by-Page iterator) on both
>the back-end and the front-end; furthermore, I've written a small "mapper"
>that uses extensively the Reflection API to automatically perform the
>mapping and this probably has an impact on the overall performance.
>
>My question is: what are the best practices for this type of issues? Does
>anybody have the same problems? Should I reduce the level of abstraction
>between the layers?
>
>Thank you!
>
>Andrej
>
>PS. if you're interested, I can share the simple mapper. It's a very small
>mapper (less than 15k) that works fine with my app. It's waaay less
>complete than the mapper on Ted Husted's site but...
>
>-Original Message-
>From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, November 22, 2001 12:10 PM
>To: 'Struts Users Mailing List'
>Subject: RE: design question
>
>
>
>
>-Original Message-
>From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]]
>Sent: 22 November 2001 16:54
>To: Struts-list (E-mail)
>Subject: design question
>
>Hello
>
>I have several questions about design, "best practises":
>
>1)  Where to store client's profile information (like login name) ?
>session  or system state bean ?
>
>Use the HttpSession. But be aware that you should put as little as possible
>into the session. Large sessions do not work well in a cluster.
>
>2)  How to create and use a system state bean ?
>
>System state bean should be in scope "session", shouldnt it ?
>
>Again put as little as possible in the session and avoid statefull session
>beans. If you must put a bean in the session, make it as small as possible,
>ideally it would just hold key info that can be used to request beans at
>request level when needed. This is a trade off between performance and
>scalability.
>
>3) Where to put business logic (where I invoke JDBC) ?
>   Should business logic class be a bean ?
>
>If you have an app server business logic should go into a stateless session
>bean (BusinessService), which is invoked (via a BusinessDelegate) from a
>struts Action class. If you are not using EJBs then the Action class should
>still invoke a business delegate, but the delegate would simply create a

Design question - Action Form vs Business Delegates/Value Objects

2001-11-22 Thread Sobkowski, Andrej

Hello,

we're working on a quite large project with J2EE (including EJBs) and we're
using Struts (we're still in the early phases). To design a "clean"
application, I've defined different "object conversions":
* Request phase
- the ActionForm is converted to a Value Object
- the Value Object is passed to the EJBs
* Response phase
- the EJBs return one ore more Value Objects
- the Value Object(s) is (are) converted back to ActionForms.

I think it's a good approach, but:
- my ActionForm and Value Objects have an almost identical interface. The
main difference is that the ActionForm instance variables are always of type
String while for the Value Object  have "final types" information (Date,
Integer, whatever)
- the conversion "ActionForm to VO" and back is slowing down the performance
as my EJBs often return hundreds of VOs (each one to be converted to an
ActionForm).
I know this can be improved by using paging (Page-by-Page iterator) on both
the back-end and the front-end; furthermore, I've written a small "mapper"
that uses extensively the Reflection API to automatically perform the
mapping and this probably has an impact on the overall performance.

My question is: what are the best practices for this type of issues? Does
anybody have the same problems? Should I reduce the level of abstraction
between the layers?

Thank you!

Andrej

PS. if you're interested, I can share the simple mapper. It's a very small
mapper (less than 15k) that works fine with my app. It's waaay less
complete than the mapper on Ted Husted's site but...

-Original Message-
From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 12:10 PM
To: 'Struts Users Mailing List'
Subject: RE: design question




-Original Message-
From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]] 
Sent: 22 November 2001 16:54
To: Struts-list (E-mail)
Subject: design question

Hello

I have several questions about design, "best practises":

1)  Where to store client's profile information (like login name) ?
session  or system state bean ?

Use the HttpSession. But be aware that you should put as little as possible
into the session. Large sessions do not work well in a cluster.

2)  How to create and use a system state bean ?

System state bean should be in scope "session", shouldnt it ?

Again put as little as possible in the session and avoid statefull session
beans. If you must put a bean in the session, make it as small as possible,
ideally it would just hold key info that can be used to request beans at
request level when needed. This is a trade off between performance and
scalability.

3) Where to put business logic (where I invoke JDBC) ?  
Should business logic class be a bean ?

If you have an app server business logic should go into a stateless session
bean (BusinessService), which is invoked (via a BusinessDelegate) from a
struts Action class. If you are not using EJBs then the Action class should
still invoke a business delegate, but the delegate would simply create a
normal Java bean to act as the Business Service. The business service
(Stateless EJB or Java Bean) should delegate to another class to access a
datasource. If your are using EJBs this should be a CMP or BMP+DAO depending
on your app server (EJB 2 compliant consider CMP, else try CMP if supported
but be prepared to subclass to a BMP+DAO at a later date).

thanx in advance
Maris Orbidans


Jon Ridgway.

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



RE: design question

2001-11-22 Thread Jon.Ridgway



-Original Message-
From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]] 
Sent: 22 November 2001 16:54
To: Struts-list (E-mail)
Subject: design question

Hello

I have several questions about design, "best practises":

1)  Where to store client's profile information (like login name) ?
session  or system state bean ?

Use the HttpSession. But be aware that you should put as little as possible
into the session. Large sessions do not work well in a cluster.

2)  How to create and use a system state bean ?

System state bean should be in scope "session", shouldnt it ?

Again put as little as possible in the session and avoid statefull session
beans. If you must put a bean in the session, make it as small as possible,
ideally it would just hold key info that can be used to request beans at
request level when needed. This is a trade off between performance and
scalability.

3) Where to put business logic (where I invoke JDBC) ?  
Should business logic class be a bean ?

If you have an app server business logic should go into a stateless session
bean (BusinessService), which is invoked (via a BusinessDelegate) from a
struts Action class. If you are not using EJBs then the Action class should
still invoke a business delegate, but the delegate would simply create a
normal Java bean to act as the Business Service. The business service
(Stateless EJB or Java Bean) should delegate to another class to access a
datasource. If your are using EJBs this should be a CMP or BMP+DAO depending
on your app server (EJB 2 compliant consider CMP, else try CMP if supported
but be prepared to subclass to a BMP+DAO at a later date).

thanx in advance
Maris Orbidans


Jon Ridgway.

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




design question

2001-11-22 Thread Màris Orbidàns

Hello

I have several questions about design, "best practises":

1)  Where to store client's profile information (like login name) ?
session  or system state bean ?

2)  How to create and use a system state bean ?

System state bean should be in scope "session", shouldnt it ?

3) Where to put business logic (where I invoke JDBC) ?  
Should business logic class be a bean ?

thanx in advance
Maris Orbidans



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




Re: Design Question. Better to have jsp files in root or in WEB-INF/jsp-files

2001-11-20 Thread Ted Husted

It's mainly a security thing. So the value is tied to your security
needs.

It first came up in thread regarding MVC purity, and ensuring that
control passed through an Action before it went to a JSP. 

The basic idea is that if you have an architecture where all flow goes
through Actions and then to JSPs, putting the JSPs down there ensures
that this plan is always followed. It also absolutely prevents a user
from retrieving a JSP directly. If none of this matters in your
circumstances, then don't bother.

Meanwhile, if you do follow the Action:JSP arcitechture, then the
location of your JSPs is never revealed on the address bar. It may still
be available if you use html:base and they peek at the source. But that
only matters if there were a JSP that they could recall directly that
could reveal sensitive information. Most often this is not the case,
since the Action fetches the sensitive information. 

Last I knew, Weblogic did not support this part of the spec, so it's not
an option for many people.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


[EMAIL PROTECTED] wrote:
> 
> Hi Folks
> 
> I am wanting to know what people think is better.  To have all the jsp
> files in the root directory of the web app or in a directory like
> 
> WEB-INF/jsp-pages
> 
> I have seen in a few places people putting all there jsp-pages in this
> directory and I cannot see the advantages in doing so, why is this
> better than putting them in the root directory?  It seems like extra
> work to have to then make mappings to get to the jsp files in the
> struts-config.xml file.  Is it worth it?
> 
> Cheers
> 
> Tony
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

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




Re: Design Question. Better to have jsp files in root or in WEB-INF/jsp-files

2001-11-20 Thread antony

Is this possible to do via the web.xml file?

Jin Bal wrote:

> One reason why people may be doing this is to hide the directory structure
> of their jsps.

>>I am wanting to know what people think is better.  To have all the jsp
>>files in the root directory of the web app or in a directory like
>>
>>WEB-INF/jsp-pages
>>
>>I have seen in a few places people putting all there jsp-pages in this
>>directory and I cannot see the advantages in doing so, why is this
>>better than putting them in the root directory?  It seems like extra
>>work to have to then make mappings to get to the jsp files in the
>>struts-config.xml file.  Is it worth it?
>>





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




Re: Design Question. Better to have jsp files in root or in WEB-INF/jsp-files

2001-11-20 Thread Jin Bal

One reason why people may be doing this is to hide the directory structure
of their jsps.
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 20, 2001 7:29 AM
Subject: Design Question. Better to have jsp files in root or in
WEB-INF/jsp-files


> Hi Folks
>
> I am wanting to know what people think is better.  To have all the jsp
> files in the root directory of the web app or in a directory like
>
> WEB-INF/jsp-pages
>
> I have seen in a few places people putting all there jsp-pages in this
> directory and I cannot see the advantages in doing so, why is this
> better than putting them in the root directory?  It seems like extra
> work to have to then make mappings to get to the jsp files in the
> struts-config.xml file.  Is it worth it?
>
> Cheers
>
> Tony
>
>
> --
> 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]>




Design Question. Better to have jsp files in root or in WEB-INF/jsp-files

2001-11-19 Thread antony

Hi Folks

I am wanting to know what people think is better.  To have all the jsp 
files in the root directory of the web app or in a directory like

WEB-INF/jsp-pages

I have seen in a few places people putting all there jsp-pages in this 
directory and I cannot see the advantages in doing so, why is this 
better than putting them in the root directory?  It seems like extra 
work to have to then make mappings to get to the jsp files in the 
struts-config.xml file.  Is it worth it?

Cheers

Tony


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




Re: Newbee: design question

2001-08-08 Thread Martin Cooper

You don't have to create a form bean if you don't want or need to. In your
example, the form bean would only have one property, and that property came
directly from a link (minimizing the risk of invalid values, and hence the
need for validation in the form bean), so you could just use
request.getParameter() instead if you wanted to.

Regarding "unifying" access to form fields and parameters, I'm not sure what
you're getting at. If a form bean is used, Struts will populate it from the
request parameters regardless of how the request was submitted. So long as
the form bean has a property corresponding to each parameter name, the form
will contain all of the request parameter values when your action class is
called.

--
Martin Cooper


- Original Message -
From: "Andreas Leitner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 1:13 AM
Subject: Newbee: design question


>
> Hi,
>
> I am pretty new to tomcat/struts but nevertheless trying to create a
> simple application using the two (; I have troubles getting my design
> right, maybe some people on this list could give me some hints, they
> would be greatly appreciated.
>
> The idea is that I have a DB backend that stores a bunch of documents
> identified by an integer. Now the user can click on a link and view the
> document (that's the first step). Now the link looks like this:
> 

RE: Struts Design Question

2001-08-08 Thread Aaron Ravenberg

Yes you can do the add/edit all on the same form.  If have a database
generated code or key you can put that in a hidden field.  When in the
action examine the form or request obj to see if that key is there, if it is
you have a modify, if not add the record.

Have you page that lists the songs pass a the code/key as a parameter to the
SongForm.jsp. Then you can use the jsp:useBean as follows:


 


Then to pre populate the form you can make a DataBase call in your form
setSongKey() method and use the result to set the other values in the form.

For a delete you can have a second form on the same page (with its own
submit button) that has the songKey set into the SongDeleteForm and the
submit is mapped to a DeleteAction that just uses the key to delete the
record.

I am new at the struts stuff myself, so these may not be the best ways to
accomplish what you are trying to do, but I know it works.  So anyone else
please feel free to critique.

Aaron


-Original Message-
From: Shriver, Ryan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 08, 2001 9:30 AM
To: '[EMAIL PROTECTED]'
Subject: Struts Design Question


Hello all,
I downloaded Struts last week and have enjoyed playing with it. I've come
upon a design problem and I was hoping some folks on this list could help
solve it. I've had no luck finding an answer in the mail archives.

I want to maintain a list of songs. Through a web interface, I want to add a
new song, edit information about an existing song (composer, artist, etc)
and also delete a song. Under the covers this will do some sort of database
insert, update and delete, respectively.

The forms for adding a new song and editing an existing song are practically
identical. They contain the same field names with the difference being edit
pre-populates the fields with the existing values of a song whereas the
fields are blank for add. Question #1: Can one ActionForm suffice for both
add and edit form pages? My gut says yes, but I want to make sure.

Actions. In the simplest scenario, I could create separate actions for all
operations. I'd have AddSongAction, EditSongAction and DeleteSongAction
classes each with their own logic in perform(). This would work, but there's
something that bothers me about having three different classes performing
operations on one entity. It seems like overkill.

DispatchActions. I saw the post about using DispatchAction to have multiple
methods in a single Action class. I really like this approach, as I could
have insert, update and delete methods in my Action class. However, the
input="" attribute in the action mapping definition (in struts-config.xml)
is shared for all of them. So if I have separate addsong.jsp and
editsong.jsp form pages sharing the same Action, and a validation error
occurs, Struts can only return to one (whatever input="" is). So this won't
work.

Question #2: Is there a happy medium between these two approaches?

One idea that I haven't worked through is using one songform.jsp page for
add/edit/delete. Calling songform.jsp?method=add would produce a blank page
for entering a new song. Songform.jsp?method=edit&id=1234 would populate the
form with values from a song whose id = 1234. From here one could edit or
delete the selected song. In Struts I'd use the DispatchAction to pass all
add/edit/delete requests to one Action class. Because all were using the
same form, the input="" attribute problem above would be avoided.

Question #3: Will this approach work? Can anyone offer a better solution for
this problem?

Thanks for the feedback.

-ryan




Struts Design Question

2001-08-08 Thread Shriver, Ryan

Hello all,
I downloaded Struts last week and have enjoyed playing with it. I've come
upon a design problem and I was hoping some folks on this list could help
solve it. I've had no luck finding an answer in the mail archives.

I want to maintain a list of songs. Through a web interface, I want to add a
new song, edit information about an existing song (composer, artist, etc)
and also delete a song. Under the covers this will do some sort of database
insert, update and delete, respectively.

The forms for adding a new song and editing an existing song are practically
identical. They contain the same field names with the difference being edit
pre-populates the fields with the existing values of a song whereas the
fields are blank for add. Question #1: Can one ActionForm suffice for both
add and edit form pages? My gut says yes, but I want to make sure.

Actions. In the simplest scenario, I could create separate actions for all
operations. I'd have AddSongAction, EditSongAction and DeleteSongAction
classes each with their own logic in perform(). This would work, but there's
something that bothers me about having three different classes performing
operations on one entity. It seems like overkill.

DispatchActions. I saw the post about using DispatchAction to have multiple
methods in a single Action class. I really like this approach, as I could
have insert, update and delete methods in my Action class. However, the
input="" attribute in the action mapping definition (in struts-config.xml)
is shared for all of them. So if I have separate addsong.jsp and
editsong.jsp form pages sharing the same Action, and a validation error
occurs, Struts can only return to one (whatever input="" is). So this won't
work.

Question #2: Is there a happy medium between these two approaches? 

One idea that I haven't worked through is using one songform.jsp page for
add/edit/delete. Calling songform.jsp?method=add would produce a blank page
for entering a new song. Songform.jsp?method=edit&id=1234 would populate the
form with values from a song whose id = 1234. From here one could edit or
delete the selected song. In Struts I'd use the DispatchAction to pass all
add/edit/delete requests to one Action class. Because all were using the
same form, the input="" attribute problem above would be avoided.

Question #3: Will this approach work? Can anyone offer a better solution for
this problem?

Thanks for the feedback.

-ryan



Re: Templates: a design question

2001-08-02 Thread troy hart

In my mind it's a cleaner separation to do it with multiple files. The
page(s) responsible for the "content" can focus exclusively on that content,
and the page responsible for laying out the template (i.e. putting the named
"content" elements in place) can focus on that. It ends up being very easy
to maintain this way. This is especially true in the case where your
template defines multiple "non-direct" named "content" elements. In my
example you can develop these elements of content as reusable components...

To be honest, I had never even given your suggestion any thought. I imagine
there may be situations where this would be extremely convenient, and as
long as it works I'd say do it if it fits your needs...

Troy

- Original Message -
From: "Erik Hatcher" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 12:46 AM
Subject: Re: Templates: a design question


> Troy,
>
> Why have two pages for each page that uses templates rather than collapse
> them into a single page with the content embedded like this:
>
> 
> content here
> 
>
> By having two pages, don't you end up with one page having the page title,
> and the other with the content as well as possibly other things separated?
>
> Erik
>
> - Original Message -
> From: "troy hart" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 01, 2001 9:25 AM
> Subject: Re: Templates: a design question
>
>
> > The approach I use (and I believe it is a common approach) is to have
two
> > jsp pages for each page on my site that is going to use templates. For
> > example, if I have an ecommerce site it is likely I will have a shopping
> > cart page, a search page and a search results pages... For this example,
> the
> > set of jsp pages would be as follows:
> >
> > MainLayout.jsp - the main template layout page.
> > ShopCart_content.jsp - the actual content of the shopping card page.
> > ShopCart.jsp - the shopping cart page that references MainLayout.jsp and
> > tells it to use ShopCart_content.jsp...
> > Search_content.jsp - the actual content of the search page.
> > Search.jsp - the search page that references MainLayout.jsp and tells it
> to
> > use Search_content.jsp...
> > SearchResults_content.jsp - the actual content of the search results
page.
> > SearchResults.jsp - the search results page that references
MainLayout.jsp
> > and tells it to use SearchResults_content.jsp...
> >
> > This way your action mappings reference ShopCart.jsp, Search.jsp, and
> > SearchResults.jsp...
> >
> > Hope this helps,
> >
> > Troy
> >
> >
> > - Original Message -
> > From: "Oleg Bondarenko" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, August 01, 2001 10:57 AM
> > Subject: Templates: a design question
> >
> >
> >
> > Hello all,
> >
> > I am very new to Struts and I find it interesting. I like the action
> mapping
> > and also templates, but I have difficulties using them together.
> >
> > E.g. I have a central page, say Main.jsp that has a template which
> contains
> > constant header and footer and a variable content part. This content
part
> (a
> > jsp) must be determined at the run-time. Because of the template I have
to
> > always send back to the user the Main.jsp. How to use action mapping
then?
> >
> > One possible solution would be the following. The action handler stores
> the
> > variable content part as a session attribute and always returns the
global
> > mapping "main" (which is mapped to the Main.jsp). The Main.jsp retrieves
> the
> > central variable part from the session and pass it to the template.
> >
> > This works, but I have a feeling that I am not correctly using the
Struts.
> > Any input from experts would be highly appreciated.
> >
> > Best Regards,
> > Oleg Bondarenko
> >
> >
> >
> > --
> >
> > Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
> > Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail
> > irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
> > vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
> > Weitergabe dieser Mail ist nicht gestattet.
> >
> > This e-mail may contain confidential and/or privileged information. If
you
> > are not the intended recipient (or have received this e-mail in error)
> > please notify the sender immediately and destroy this e-mail. Any
> > unauthorised copying, disclosure or distribution of the material in this
> > e-mail is strictly forbidden.
> >
> >
> >
>
>




Re: Templates: a design question

2001-08-01 Thread Erik Hatcher

Troy,

Why have two pages for each page that uses templates rather than collapse
them into a single page with the content embedded like this:


content here


By having two pages, don't you end up with one page having the page title,
and the other with the content as well as possibly other things separated?

Erik

- Original Message -
From: "troy hart" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 01, 2001 9:25 AM
Subject: Re: Templates: a design question


> The approach I use (and I believe it is a common approach) is to have two
> jsp pages for each page on my site that is going to use templates. For
> example, if I have an ecommerce site it is likely I will have a shopping
> cart page, a search page and a search results pages... For this example,
the
> set of jsp pages would be as follows:
>
> MainLayout.jsp - the main template layout page.
> ShopCart_content.jsp - the actual content of the shopping card page.
> ShopCart.jsp - the shopping cart page that references MainLayout.jsp and
> tells it to use ShopCart_content.jsp...
> Search_content.jsp - the actual content of the search page.
> Search.jsp - the search page that references MainLayout.jsp and tells it
to
> use Search_content.jsp...
> SearchResults_content.jsp - the actual content of the search results page.
> SearchResults.jsp - the search results page that references MainLayout.jsp
> and tells it to use SearchResults_content.jsp...
>
> This way your action mappings reference ShopCart.jsp, Search.jsp, and
> SearchResults.jsp...
>
> Hope this helps,
>
> Troy
>
>
> - Original Message -
> From: "Oleg Bondarenko" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 01, 2001 10:57 AM
> Subject: Templates: a design question
>
>
>
> Hello all,
>
> I am very new to Struts and I find it interesting. I like the action
mapping
> and also templates, but I have difficulties using them together.
>
> E.g. I have a central page, say Main.jsp that has a template which
contains
> constant header and footer and a variable content part. This content part
(a
> jsp) must be determined at the run-time. Because of the template I have to
> always send back to the user the Main.jsp. How to use action mapping then?
>
> One possible solution would be the following. The action handler stores
the
> variable content part as a session attribute and always returns the global
> mapping "main" (which is mapped to the Main.jsp). The Main.jsp retrieves
the
> central variable part from the session and pass it to the template.
>
> This works, but I have a feeling that I am not correctly using the Struts.
> Any input from experts would be highly appreciated.
>
> Best Regards,
> Oleg Bondarenko
>
>
>
> --
>
> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
> irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
> vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
> Weitergabe dieser Mail ist nicht gestattet.
>
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and destroy this e-mail. Any
> unauthorised copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
>
>
>




RE: Templates: a design question

2001-08-01 Thread Tim Colson

> The approach I use (and I believe it is a common approach) is to have two
> jsp pages for each page on my site that is going to use templates.
> MainLayout.jsp - the main template layout page.
> ShopCart_content.jsp - the actual content of the shopping card page.
> ShopCart.jsp - the shopping cart page that references MainLayout.jsp and
+1
Heh heh - we even use the same naming convention pagename.jsp +
pagename_content.jsp.

One little issue we've run across is when the Designer wants to display
something dynamically in the MainLayout.jsp based on conditions/stuff
happening in the content.jsp.

Cheers,
Tim





Re: Templates: a design question

2001-08-01 Thread troy hart

The approach I use (and I believe it is a common approach) is to have two
jsp pages for each page on my site that is going to use templates. For
example, if I have an ecommerce site it is likely I will have a shopping
cart page, a search page and a search results pages... For this example, the
set of jsp pages would be as follows:

MainLayout.jsp - the main template layout page.
ShopCart_content.jsp - the actual content of the shopping card page.
ShopCart.jsp - the shopping cart page that references MainLayout.jsp and
tells it to use ShopCart_content.jsp...
Search_content.jsp - the actual content of the search page.
Search.jsp - the search page that references MainLayout.jsp and tells it to
use Search_content.jsp...
SearchResults_content.jsp - the actual content of the search results page.
SearchResults.jsp - the search results page that references MainLayout.jsp
and tells it to use SearchResults_content.jsp...

This way your action mappings reference ShopCart.jsp, Search.jsp, and
SearchResults.jsp...

Hope this helps,

Troy


- Original Message -
From: "Oleg Bondarenko" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 01, 2001 10:57 AM
Subject: Templates: a design question



Hello all,

I am very new to Struts and I find it interesting. I like the action mapping
and also templates, but I have difficulties using them together.

E.g. I have a central page, say Main.jsp that has a template which contains
constant header and footer and a variable content part. This content part (a
jsp) must be determined at the run-time. Because of the template I have to
always send back to the user the Main.jsp. How to use action mapping then?

One possible solution would be the following. The action handler stores the
variable content part as a session attribute and always returns the global
mapping "main" (which is mapped to the Main.jsp). The Main.jsp retrieves the
central variable part from the session and pass it to the template.

This works, but I have a feeling that I am not correctly using the Struts.
Any input from experts would be highly appreciated.

Best Regards,
Oleg Bondarenko



--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.






Templates: a design question

2001-08-01 Thread Oleg Bondarenko


Hello all,

I am very new to Struts and I find it interesting. I like the action mapping and also 
templates, but I have difficulties using them together.

E.g. I have a central page, say Main.jsp that has a template which contains constant 
header and footer and a variable content part. This content part (a jsp) must be 
determined at the run-time. Because of the template I have to always send back to the 
user the Main.jsp. How to use action mapping then?

One possible solution would be the following. The action handler stores the variable 
content part as a session attribute and always returns the global mapping "main" 
(which is mapped to the Main.jsp). The Main.jsp retrieves the central variable part 
from the session and pass it to the template.

This works, but I have a feeling that I am not correctly using the Struts. Any input 
from experts would be highly appreciated.

Best Regards,
Oleg Bondarenko



--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn 
Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, 
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das 
unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorised copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.




Newbee: design question

2001-07-25 Thread Andreas Leitner


Hi,

I am pretty new to tomcat/struts but nevertheless trying to create a
simple application using the two (; I have troubles getting my design
right, maybe some people on this list could give me some hints, they
would be greatly appreciated.

The idea is that I have a DB backend that stores a bunch of documents
identified by an integer. Now the user can click on a link and view the
document (that's the first step). Now the link looks like this:

Re: design question

2001-06-26 Thread Linnea Ahlbeck

Hi!

In the struts-config.xml-file:


   
  
  
   

Hope I understood your problem correctly and that this can help you!!
/Linnéa

- Original Message -
From: "Vandenberk, Kris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 10:26 AM
Subject: design question


> I have a detail screen with some fields on it
> and a save button, reset button and a link to the master page...
>
> How do I return to the same page after the save ?
> let say the link to this page is something like
> /editPersonalInfo.do?action=edit
>
>
> thanks,
> Kris
>
> P.S. can you put me in cc when replying I am using a different email
account
> here at work
> [EMAIL PROTECTED]
>
>
>
>
>




design question

2001-06-26 Thread Vandenberk, Kris

I have a detail screen with some fields on it
and a save button, reset button and a link to the master page...

How do I return to the same page after the save ?
let say the link to this page is something like
/editPersonalInfo.do?action=edit


thanks,
Kris

P.S. can you put me in cc when replying I am using a different email account
here at work
[EMAIL PROTECTED]







security design question

2001-06-12 Thread Peter Alfors

Hello all,

I have a design question for the web gurus out there.
Initialy, our security only determined if the current user could access
the desired page.  However, now, we are taking it one step farther.
Depending on the user, fields must either be displayed or not.
Since our pages currently consist of taglibs that are formatted using
tables, it is not as simple as allowing the taglibs to determine if they
should write themselves to the screen.  This will create rather
unpleasent results.
I am contemplating creating some sort of 'smart' table taglibs, that
will redefine themsleves as needed for security.
I was wondering how others are addressing this???

Any thought would be greatly appreciated,
Pete


begin:vcard 
n:;
x-mozilla-html:FALSE
org:http://www.irista.com/logo/irista.gif";>Bringing Vision to Your Supply Chain
adr:;;
version:2.1
end:vcard



Re: File upload/download design question

2001-05-30 Thread Craig R. McClanahan



On Wed, 25 Apr 2001 [EMAIL PROTECTED] wrote:

> 
> I have a design question regarding file upload/download which is not
> completely Struts related but I was hoping someone could provide some
> suggestions.  I have succeeded with the upload using the struts upload
> package, and then I load the file into an Oracle BLOB field. Now I need to
> get it back to the user if they want to view it.
> 
> I was planning to create an Action for processing the file download. The
> user will click on a URL and pass in the ID of the file as a request
> parameter to the Action (i.e. fileDownload.do?id=1234). The Action will
> access a session EJB which then locates the requested file and returns it to
> the Action as a File object. Here is where I need advice: what is the best
> way to send this File back to the browser?  Can I change the response type
> to "file" somehow and stream this to the browser? Another option I thought
> about was saving the file to a temp directory and then redirecting the
> browser to this file. I would rather not write temp files if I don't have
> to. Or, is there any functionality provided with struts for sending a file
> back to the browser?
> 

This is one of the cases where you might actually want to have an Action
create the response itself, instead of forwarding to a JSP page to do
it.  The reason for this is that JSP pages aren't meant for binary output
(like a GIF image) -- but servlets can do this easily.

An example of an Action to do this might look like this:

  byte buffer[] = ... load byte array from the database ...
  int size = xxx; // Number of bytes to be sent

  response.setContentLength(size);
  response.setContentType("image/gif");  // Or whatever is correct
  ServletOutputStream stream = response.getOutputStream();
  int sent = 0;
  while (sent < size) {
int count = stream.write(buffer, sent, size - sent);
sent += count;
  }
  stream.flush();

  return (null);

Note that NULL is returned, instead of an ActionForward.  This is the
signal to the controller servlet that the Action has already created the
response, so no forwarding is required.


> Any suggestions greatly appreciated...
> 
> Thanks,
> Bob
> 

Craig





RE: Basic Design Question...

2001-05-10 Thread Calvin Yu


I think some people are missing the point you're
trying to make, so I I'm going to take a stab at it.

Yes, the Servlet and Action APIs are very similar, but
a Servlet and an Action really have are two different
entities.  A Servlet's set of interfaces covers what
is required of an Action and much more.  You usually
want to have a set of interfaces that describes
succinctly what an entity is suppose to do.  An Action
performs a particular web action.  This does not
necessarily describe a servlet.  You would risk
bringing in a lot of confusion into the whole
framework.  Can an Action be setup as a standalone
Servlet?  To what extent should an Action adhere to
the Servlet spec?  What would the init() and destroy()
methods do?

Calvin

--- Prakash Dominic <[EMAIL PROTECTED]> wrote:
> 
> I understand MVC/Model 2.  And I don't
> think Action layer in Struts map to Model in MVC. 
> Actions in Struts are -Controllers- in the MVC
> pattern as they translate user actions to the Model
> and select the appropriateView.
> 
> The point I was trying to make was that, instead of
> creating a whole new set of APIs why not leverage
> the
> existing Servlet API/spec for the -Controller-
> layer. 
> 
> And I am not still clear what the problem is with
> having
> many Servlets(still java instances under the hood).
> 
> --Prakash
> 
> 
> -Original Message-
> From: Jason Chaffee <[EMAIL PROTECTED]>
> Date: Wed, 9 May 2001 14:03:01 -0700 
> To: "'[EMAIL PROTECTED]'"
> <[EMAIL PROTECTED]>
> Subject: RE: Basic Design Question...
> 
> 
> > Read up on the MVC/Model 2 design pattern.  Struts
> is based on this design
> > pattern.  It much better to have one servlet
> (controller) and several
> > actions (models), than to have serveral servlets.
> > 
> > -Original Message-
> > From: Prakash Dominic
> [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, May 09, 2001 2:04 PM
> > To: [EMAIL PROTECTED]
> > Subject: Basic Design Question...
> > 
> > 
> > Hello Folks,
> > 
> > A quick design question. This might be nit 
> > picking from a design standpoint but still a
> > valid question.
> > 
> > Struts uses the Action.perform(...) API for 
> > action hadling/controller. I am curious to know
> > why Servlets can't be used for the Action Handling
> > layer. That way there is no need to introduce
> > 2 new APIs to learn - Action and
> struts-config.xml.
> > 
> > The web.xml could replace the struts-config for 
> > action mapping. And framework users simply
> implement
> > Servlets instead of Action subclasses.
> > 
> > Does this make sense or am I am missing something
> > here ?
> > 
> > Thanks,
> > Prakash
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 
> > ===
> > 
> > Another FREE service from Jayde Online <  HREF="http://www.jayde.com>" TARGET="_new"> COLOR="BLUE">http://www.jayde.com>
> > Private, Web-based email accounts at   HREF="http://www.jaydemail.com"; TARGET="_new"> COLOR="BLUE">http://www.jaydemail.com
> > 
> > Powered by Outblaze
> > 
> 
> -- 
> 
> ===
> 
> Another FREE service from Jayde Online
> <http://www.jayde.com>
> Private, Web-based email accounts at
> http://www.jaydemail.com
> 
> Powered by Outblaze


__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



RE: Basic Design Question...

2001-05-10 Thread Nanduri, Amarnath

The problem with multiple servlets.

1) Security is a pain when you should check in each and every servlet. In a
single servlet you have one point of entry/ on point of exit. So security
can be implemented quite efficiently.

2) Ease of maintenance. For example when you are porting across multiple
servlet engines then maintenance is a problem.

3) Changes in how you handle your requests can be easily applied (since you
handle them at nly one servlet).

I am sure that there are tons of other reasons out there. However i think
the above points are valid enough for me to stick to a single servlet
instead of multiple ones... I worked on projects before (when the servlet
api has come out) where i used multilpe servlets. Trust me, it is not a
pleasant thought for me now when i think of those times, cause i ran into
all those problems i had mentioned above.

cheers,
Amar..

-Original Message-
From: Prakash Dominic [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 09, 2001 6:52 PM
To: [EMAIL PROTECTED];
"'[EMAIL PROTECTED]'"@jaydemail.com;
[EMAIL PROTECTED]
Subject: RE: Basic Design Question...



I understand MVC/Model 2.  And I don't
think Action layer in Struts map to Model in MVC. 
Actions in Struts are -Controllers- in the MVC pattern as they translate
user actions to the Model and select the appropriateView.

The point I was trying to make was that, instead of
creating a whole new set of APIs why not leverage the
existing Servlet API/spec for the -Controller- layer. 

And I am not still clear what the problem is with having
many Servlets(still java instances under the hood).

--Prakash


-Original Message-
From: Jason Chaffee <[EMAIL PROTECTED]>
Date: Wed, 9 May 2001 14:03:01 -0700 
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
Subject: RE: Basic Design Question...


> Read up on the MVC/Model 2 design pattern.  Struts is based on this design
> pattern.  It much better to have one servlet (controller) and several
> actions (models), than to have serveral servlets.
> 
> -Original Message-
> From: Prakash Dominic [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 09, 2001 2:04 PM
> To: [EMAIL PROTECTED]
> Subject: Basic Design Question...
> 
> 
> Hello Folks,
> 
> A quick design question. This might be nit 
> picking from a design standpoint but still a
> valid question.
> 
> Struts uses the Action.perform(...) API for 
> action hadling/controller. I am curious to know
> why Servlets can't be used for the Action Handling
> layer. That way there is no need to introduce
> 2 new APIs to learn - Action and struts-config.xml.
> 
> The web.xml could replace the struts-config for 
> action mapping. And framework users simply implement
> Servlets instead of Action subclasses.
> 
> Does this make sense or am I am missing something
> here ?
> 
> Thanks,
> Prakash
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> ===
> 
> Another FREE service from Jayde Online < http://www.jayde.com>"
TARGET="_new">http://www.jayde.com>
> Private, Web-based email accounts at  http://www.jaydemail.com";
TARGET="_new">http://www.jaydemail.com
> 
> Powered by Outblaze
> 

-- 

===

Another FREE service from Jayde Online <http://www.jayde.com>
Private, Web-based email accounts at http://www.jaydemail.com

Powered by Outblaze



RE: Basic Design Question...

2001-05-09 Thread Prakash Dominic


I understand MVC/Model 2.  And I don't
think Action layer in Struts map to Model in MVC. 
Actions in Struts are -Controllers- in the MVC pattern as they translate user actions 
to the Model and select the appropriateView.

The point I was trying to make was that, instead of
creating a whole new set of APIs why not leverage the
existing Servlet API/spec for the -Controller- layer. 

And I am not still clear what the problem is with having
many Servlets(still java instances under the hood).

--Prakash


-Original Message-
From: Jason Chaffee <[EMAIL PROTECTED]>
Date: Wed, 9 May 2001 14:03:01 -0700 
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
Subject: RE: Basic Design Question...


> Read up on the MVC/Model 2 design pattern.  Struts is based on this design
> pattern.  It much better to have one servlet (controller) and several
> actions (models), than to have serveral servlets.
> 
> -Original Message-
> From: Prakash Dominic [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 09, 2001 2:04 PM
> To: [EMAIL PROTECTED]
> Subject: Basic Design Question...
> 
> 
> Hello Folks,
> 
> A quick design question. This might be nit 
> picking from a design standpoint but still a
> valid question.
> 
> Struts uses the Action.perform(...) API for 
> action hadling/controller. I am curious to know
> why Servlets can't be used for the Action Handling
> layer. That way there is no need to introduce
> 2 new APIs to learn - Action and struts-config.xml.
> 
> The web.xml could replace the struts-config for 
> action mapping. And framework users simply implement
> Servlets instead of Action subclasses.
> 
> Does this make sense or am I am missing something
> here ?
> 
> Thanks,
> Prakash
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> ===
> 
> Another FREE service from Jayde Online < http://www.jayde.com>" 
>TARGET="_new">http://www.jayde.com>
> Private, Web-based email accounts at  http://www.jaydemail.com"; 
>TARGET="_new">http://www.jaydemail.com
> 
> Powered by Outblaze
> 

-- 

===

Another FREE service from Jayde Online <http://www.jayde.com>
Private, Web-based email accounts at http://www.jaydemail.com

Powered by Outblaze



RE: Basic Design Question...

2001-05-09 Thread Jason Chaffee
Title: RE: Basic Design Question...





Read up on the MVC/Model 2 design pattern.  Struts is based on this design pattern.  It much better to have one servlet (controller) and several actions (models), than to have serveral servlets.

-Original Message-
From: Prakash Dominic [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 09, 2001 2:04 PM
To: [EMAIL PROTECTED]
Subject: Basic Design Question...



Hello Folks,


A quick design question. This might be nit 
picking from a design standpoint but still a
valid question.


Struts uses the Action.perform(...) API for 
action hadling/controller. I am curious to know
why Servlets can't be used for the Action Handling
layer. That way there is no need to introduce
2 new APIs to learn - Action and struts-config.xml.


The web.xml could replace the struts-config for 
action mapping. And framework users simply implement
Servlets instead of Action subclasses.


Does this make sense or am I am missing something
here ?


Thanks,
Prakash












-- 


===


Another FREE service from Jayde Online <http://www.jayde.com>
Private, Web-based email accounts at http://www.jaydemail.com


Powered by Outblaze





Basic Design Question...

2001-05-09 Thread Prakash Dominic

Hello Folks,

A quick design question. This might be nit 
picking from a design standpoint but still a
valid question.

Struts uses the Action.perform(...) API for 
action hadling/controller. I am curious to know
why Servlets can't be used for the Action Handling
layer. That way there is no need to introduce
2 new APIs to learn - Action and struts-config.xml.

The web.xml could replace the struts-config for 
action mapping. And framework users simply implement
Servlets instead of Action subclasses.

Does this make sense or am I am missing something
here ?

Thanks,
Prakash











-- 

===

Another FREE service from Jayde Online <http://www.jayde.com>
Private, Web-based email accounts at http://www.jaydemail.com

Powered by Outblaze



RE: File upload/download design question

2001-04-25 Thread Nanduri, Amarnath


Let me add some more to this question. If it is possible to send files down
the network (to the client), and an Applet is
receiving the file. Is it possible for the Applet to display the file
(within itself or using a plugin) no matter what kind
of File is send down (like Word, Powerpoint etc..). Any help-tips will be
greatly appreciated. Thanks a lot.

cheers,
Amar..


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 25, 2001 3:45 PM
To: [EMAIL PROTECTED]
Subject: File upload/download design question



I have a design question regarding file upload/download which is not
completely Struts related but I was hoping someone could provide some
suggestions.  I have succeeded with the upload using the struts upload
package, and then I load the file into an Oracle BLOB field. Now I need to
get it back to the user if they want to view it.

I was planning to create an Action for processing the file download. The
user will click on a URL and pass in the ID of the file as a request
parameter to the Action (i.e. fileDownload.do?id=1234). The Action will
access a session EJB which then locates the requested file and returns it to
the Action as a File object. Here is where I need advice: what is the best
way to send this File back to the browser?  Can I change the response type
to "file" somehow and stream this to the browser? Another option I thought
about was saving the file to a temp directory and then redirecting the
browser to this file. I would rather not write temp files if I don't have
to. Or, is there any functionality provided with struts for sending a file
back to the browser?

Any suggestions greatly appreciated...

Thanks,
Bob



File upload/download design question

2001-04-25 Thread rhayden


I have a design question regarding file upload/download which is not
completely Struts related but I was hoping someone could provide some
suggestions.  I have succeeded with the upload using the struts upload
package, and then I load the file into an Oracle BLOB field. Now I need to
get it back to the user if they want to view it.

I was planning to create an Action for processing the file download. The
user will click on a URL and pass in the ID of the file as a request
parameter to the Action (i.e. fileDownload.do?id=1234). The Action will
access a session EJB which then locates the requested file and returns it to
the Action as a File object. Here is where I need advice: what is the best
way to send this File back to the browser?  Can I change the response type
to "file" somehow and stream this to the browser? Another option I thought
about was saving the file to a temp directory and then redirecting the
browser to this file. I would rather not write temp files if I don't have
to. Or, is there any functionality provided with struts for sending a file
back to the browser?

Any suggestions greatly appreciated...

Thanks,
Bob



Re: Struts design question

2000-12-27 Thread Ted Husted

> Why do Action, ActionForm and ActionMappings classes keep references
to the ActionServlet?

So that they can access the many features available through the
servlet, like logging and (lately) a JBDC DataSource.

The ActionServlet is like a switchboard, and the references a way they
can dial "0" for the operator.

For more about how Struts works, there is a  "Walking Tour of the
Example Application" at 

< http://husted.com/about/struts/ >

along with a sample JBDC applicaton. 

*** REPLY SEPARATOR  ***

On 12/27/2000 at 6:41 PM Punyansky, Alex wrote:

Hi,

I'm going through Struts code trying to understand how this whole thing
works. I could figure out almost everything except one thing: Why do
Action,
ActionForm and ActionMappings classes keep references to the
ActionServlet?
Can anybody explain this?

Thanks

Alex






Struts design question

2000-12-27 Thread Punyansky, Alex

Hi,

I'm going through Struts code trying to understand how this whole thing
works. I could figure out almost everything except one thing: Why do Action,
ActionForm and ActionMappings classes keep references to the ActionServlet?
Can anybody explain this?

Thanks

Alex




Re: design question

2000-12-07 Thread Craig R. McClanahan

"Lacerda, Wellington (AFIS)" wrote:

> If you can identify consistent patterns in your scriptlet usage, yes.
> Otherwise it's questionable. Even the division of labor is questionable case
> you can't, because page designers will end up having to deal with several
> different tags used once or twice among the several pages (which tag for
> what in which page ?).
>
> So, the idea is to plan in advance. Heavily.
>

One more issue to consider is development tools support.

As we look into the (very) near-term future, we see tools that are starting to
support custom tags in exciting ways, including creating the actual visual
representation by running a servlet container in the background while you are
developing.  Thanks to the TLD, an IDE can create a nice UI for selecting
available custom tags, populating the attributes (including knowing about
required attributes and those that take runtime expressions), and so on.

Pretty much none of this is possible if you are using scriptlets.

To say nothing of the fact that you now need Java developers to maintain your
pages ...

>
> My 2 cents.
>
> Wellington
>

Craig McClanahan





RE: design question

2000-12-07 Thread Lacerda, Wellington (AFIS)

If you can identify consistent patterns in your scriptlet usage, yes.
Otherwise it's questionable. Even the division of labor is questionable case
you can't, because page designers will end up having to deal with several
different tags used once or twice among the several pages (which tag for
what in which page ?).

So, the idea is to plan in advance. Heavily.

My 2 cents.

Wellington


-Original Message-
From:   Jim Richards [mailto:[EMAIL PROTECTED]]
Sent:   07 December 2000 02:56
To: [EMAIL PROTECTED]
Subject:    design question


As I understand it, is the basic design of struts generally
to avoid
any direct Java code in the .jsp files, and do everything
through tags?

And although we can so things within <% %> tags, it is not
preferred?

Just wondering before I embark on my project, if it's worth
including the
design of any extra tags, or just doing the things I want in
<% %> ...


--
Kumera - a new Open Source Content Management System
for small to medium web sites written in Perl and using XML
http://www.cyber4.org/kumera/index.html



Re: design question

2000-12-06 Thread Wong Kok Wai

One issue not really discussed is the performance
aspect of using tags. Looking at the generated Java
source from a JSP, a single tag can be expanded into 5
or more lines of Java code. For a simple tag like
"ifNull", I would think using scriptlets with a if
statement will lead to better performance (although
I've NOT done any timing measurement).

Just my two cents.

--- David Geary <[EMAIL PROTECTED]> wrote:
> Of course, the functionality in the JSP page listed
> above could be
> implemented as a custom tag. Whether you implement
> JSP pages or custom tags
> is largely a matter of taste. Custom tags are a
> little more difficult to
> develop, but they are easier for page authors to
> use. JSP components are
> easier to develop, but they are a little more
> difficult for page authors to
> use because they must be included.
> 
> > Just wondering before I embark on my project, if
> it's worth including the
> > design of any extra tags, or just doing the things
> I want in <% %> ...
> 
> The bottom line is twofold: reuse and division of
> labor. You can't reuse
> scriptlets buried in a JSP page, but you can reuse
> custom tags or JSP
> components. If you're on a large project with
> software developers and page
> authors, ideally you'd like the page authors to use
> tags implemented by
> developers. This helps maintain a division of labor
> where software developers
> and page authors can work in parallel, with few
> dependencies.
> 
> 
> david
> 


__
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/



Re: design question

2000-12-06 Thread David Geary

Jim Richards wrote:

> As I understand it, is the basic design of struts generally to avoid
> any direct java code in the .jsp files, and do everything through tags?

Tags and beans, yes.

> And although we can so things within <% %> tags, it is not
> preferred?

That's the conventional wisdom; however, IMHO it's sometimes
permissible to use scriplets. Consider this JSP page:

<%
   java.util.Enumeration e = request.getParameterNames();
   boolean hasParams = false;

   while(e.hasMoreElements()) {
  String name = (String)e.nextElement();
  String[] values = request.getParameterValues(name);

  hasParams = true;

  for(int i=0; i < values.length; ++i) {
 String next = values[i];
 if(i == 0) { %>
<%= name %>: <%= next %>
<%   }
 else { %>
, <%= next %>
<%   }
   } %>
<% }
   if(!hasParams) { %>
  No parameters with this request
<% } %>

The JSP page listed above prints request parameters, which is useful for
debugging. I refer to JSP pages that are mostly scriptlets with a small
amount of HTML sprinkled throughout as JSP components, for lack of a better
term. In such cases, I believe scriptlets are just fine.

Of course, the functionality in the JSP page listed above could be
implemented as a custom tag. Whether you implement JSP pages or custom tags
is largely a matter of taste. Custom tags are a little more difficult to
develop, but they are easier for page authors to use. JSP components are
easier to develop, but they are a little more difficult for page authors to
use because they must be included.

> Just wondering before I embark on my project, if it's worth including the
> design of any extra tags, or just doing the things I want in <% %> ...

The bottom line is twofold: reuse and division of labor. You can't reuse
scriptlets buried in a JSP page, but you can reuse custom tags or JSP
components. If you're on a large project with software developers and page
authors, ideally you'd like the page authors to use tags implemented by
developers. This helps maintain a division of labor where software developers
and page authors can work in parallel, with few dependencies.


david




design question

2000-12-06 Thread Jim Richards


As I understand it, is the basic design of struts generally to avoid
any direct java code in the .jsp files, and do everything through tags?

And although we can so things within <% %> tags, it is not
preferred?

Just wondering before I embark on my project, if it's worth including the
design of any extra tags, or just doing the things I want in <% %> ...


--
Kumera - a new Open Source Content Management System
for small to medium web sites written in Perl and using XML
http://www.cyber4.org/kumera/index.html



Re: Actions - design question + an offtopic question

2000-11-28 Thread Joe Peer

wow.thanks for the explanation!!

joe




Re: Actions - design question + an offtopic question

2000-11-27 Thread Craig R. McClanahan

Malcolm Davis wrote:

> This "Security" issue has always bothered me.
> The servlet API provides a Form Based Authentication via 'j_username' and '
> j_password'.
> Tomcat supports this feature, but I don't see it in Struts.
>
> Are there plans to support Form Based Authentication via 'j_username' and '
> j_password'

In what way do you feel that Struts should support this?  It's completely
defined by the way you configure your web.xml file (and your server), and
Struts-based applications can take advantage of that fact with no code changes
at all being necessary.  This is true on *any* servlet container that implements
2.2 or later, not just Tomcat.

One reasonable follow-up question is "why does the example application do its
own login processing?".  And the answer is based on a longer discussion from
earlier today -- the interface between a servlet container and the underlying
database of users and roles is not portable, and I didn't want to have to
research how to set that up on every single server that Struts might be run on.
The whole idea of an example application is to be able to drop it in and run, as
a quick test to make sure that Struts works in your environment.

>
> Thans,
> Malcolm

Craig



RE: Actions - design question + an offtopic question

2000-11-27 Thread Malcolm Davis

This "Security" issue has always bothered me.
The servlet API provides a Form Based Authentication via 'j_username' and '
j_password'.
Tomcat supports this feature, but I don't see it in Struts.

Are there plans to support Form Based Authentication via 'j_username' and '
j_password'
Thans,
Malcolm

> -Original Message-
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 27, 2000 2:06 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Actions - design question + an offtopic question
>
>
> Joe Peer wrote:
>
> > hi,
> >
> > i just read Craig's answer to denis' question and i was
> wondering if there
> > is some kind of "j2ee compliant" way of doing user auth and
> role-asignment -
> > are there any standards one is supposed to use
> > (i apologize for this offtopic question, since it's not an
> struts issue, i
> > guess)
> >
>
> Well, it's not off topic if you want to use Struts-based apps in a J2EE
> environment :-).
>
> >
> > today i always use my own user/roles tables in my (relational)
> database and
> > i am doing all these things "by hand, means by jdbc queries" - should i
> > change that?
> >
>
> The J2EE recommendation for this is to use container-managed
> security (i.e. the
>  elements defined in web.xml) for user
> authentication and
> access control.  Doing so means that the container is taking care of these
> issues for you, and (perhaps more importantly) that user
> identities are shared
> between the web layer and the EJB layer, because the server will
> be using the
> same underlying "database" of users and roles.
>
> The only downside to this approach is that there is not yet a
> standardized API
> for portably accessing and maintaining a "database" of users and
> roles (I'm
> putting "database" in quotes because the actual implementation
> could be pretty
> much anything, including static text files or directory servers).
>
> Instead, most servers provide a server-specific API to do this
> kind of thing.
> For example, in Tomcat you can implement an API called a Realm
> that talks to
> your existing database of users, and then tell Tomcat to use this Realm
> implementation for user authentication.  In that way, new users
> added to the
> database (by whatever means) become instantly authorized for web
> use also.  If
> you were to switch to a different engine, you would need to
> re-implement this
> function according to the APIs provided by the new server, but
> you would not
> need to update your applications.
>
> >
> > any hint / pointer to doc / suggestions would be nice!
>
> The API that I'm the most familiar with is Tomcat -- if you grab
> the source
> distribution of the "jakarta-tomcat-4.0" CVS module from
> <http://jakarta.apache.org>, look in file
>
> catalina/src/share/org/apache/catalina/Realm.java
>
> for the details of what you have to implement to create your own
> Realm.  There
> is even a provided JDBCRealm implementation that lets you connect
> Tomcat to a
> database already -- all you need to do is configure it in the
> conf/server.xml
> file, and there are several examples commented out in the stock
> version of this
> file.
>
>
> >
> > joe
> >
>
> Craig
>
>
> >
> > - Original Message -
> > From: Craig R. McClanahan <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, November 27, 2000 6:37 PM
> > Subject: Re: Actions - design question
> >
> > > Denis Hanson wrote:
> > >
> > > > Hi all,
> > > >
> > > > I am starting to move our existing web application to the struts
> > framework
> > > > and would like to ask a design question.
> > > >
> > > > Here's my problem. After logon, the application user is
> forwarded to one
> > of
> > > > three screens - sysadmin, admin, user.  The screen used is
> determined by
> > the
> > > > user's role.  (The three screens have no commonality, so I
> don't think I
> > can
> > > > use the one  action attrubute
> shown in the
> > > > example application.)
> > > >
> > > > I'm looking for some way to define the various paths in
> > struts-config.xml so
> > > > that the logon action class doesn't have hardcoded paths to
> the three
> > > > ro

Re: Actions - design question + an offtopic question

2000-11-27 Thread Craig R. McClanahan

Joe Peer wrote:

> hi,
>
> i just read Craig's answer to denis' question and i was wondering if there
> is some kind of "j2ee compliant" way of doing user auth and role-asignment -
> are there any standards one is supposed to use
> (i apologize for this offtopic question, since it's not an struts issue, i
> guess)
>

Well, it's not off topic if you want to use Struts-based apps in a J2EE
environment :-).

>
> today i always use my own user/roles tables in my (relational) database and
> i am doing all these things "by hand, means by jdbc queries" - should i
> change that?
>

The J2EE recommendation for this is to use container-managed security (i.e. the
 elements defined in web.xml) for user authentication and
access control.  Doing so means that the container is taking care of these
issues for you, and (perhaps more importantly) that user identities are shared
between the web layer and the EJB layer, because the server will be using the
same underlying "database" of users and roles.

The only downside to this approach is that there is not yet a standardized API
for portably accessing and maintaining a "database" of users and roles (I'm
putting "database" in quotes because the actual implementation could be pretty
much anything, including static text files or directory servers).

Instead, most servers provide a server-specific API to do this kind of thing.
For example, in Tomcat you can implement an API called a Realm that talks to
your existing database of users, and then tell Tomcat to use this Realm
implementation for user authentication.  In that way, new users added to the
database (by whatever means) become instantly authorized for web use also.  If
you were to switch to a different engine, you would need to re-implement this
function according to the APIs provided by the new server, but you would not
need to update your applications.

>
> any hint / pointer to doc / suggestions would be nice!

The API that I'm the most familiar with is Tomcat -- if you grab the source
distribution of the "jakarta-tomcat-4.0" CVS module from
<http://jakarta.apache.org>, look in file

catalina/src/share/org/apache/catalina/Realm.java

for the details of what you have to implement to create your own Realm.  There
is even a provided JDBCRealm implementation that lets you connect Tomcat to a
database already -- all you need to do is configure it in the conf/server.xml
file, and there are several examples commented out in the stock version of this
file.


>
> joe
>

Craig


>
> - Original Message -
> From: Craig R. McClanahan <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, November 27, 2000 6:37 PM
> Subject: Re: Actions - design question
>
> > Denis Hanson wrote:
> >
> > > Hi all,
> > >
> > > I am starting to move our existing web application to the struts
> framework
> > > and would like to ask a design question.
> > >
> > > Here's my problem. After logon, the application user is forwarded to one
> of
> > > three screens - sysadmin, admin, user.  The screen used is determined by
> the
> > > user's role.  (The three screens have no commonality, so I don't think I
> can
> > > use the one  action attrubute shown in the
> > > example application.)
> > >
> > > I'm looking for some way to define the various paths in
> struts-config.xml so
> > > that the logon action class doesn't have hardcoded paths to the three
> > > role-based screens.
> > >
> > > Do I need to create my own ActionMapping class and add additional
>  > > name=/> entries, or is there some other way to do this?
> > >
> >
> > Because we're talking about "what does the logon action forward to", you
> won't
> > need any additional action definitions.  However, you might want some
> additional
> > forwards defined.  For concreteness, let's assume that your three roles
> are
> > named "admin", "manager", and "user".
> >
> > One approach to this would be to define, nested within the 
> element for
> > the login action, some forwards that are specific to only this action:
> >
> > 
> > ...
> > 
> > ...
> >  type="com.mycompany.mypackage.LoginAction">
> > 
> > 
> > 
> > 
> > ...
> > 
> > ...
> > 
> >
> > In this scenario, you can do the following at the end of the login action:
> >
> >

Re: Actions - design question + an offtopic question

2000-11-27 Thread Joe Peer

hi,

i just read Craig's answer to denis' question and i was wondering if there
is some kind of "j2ee compliant" way of doing user auth and role-asignment -
are there any standards one is supposed to use
(i apologize for this offtopic question, since it's not an struts issue, i
guess)

today i always use my own user/roles tables in my (relational) database and
i am doing all these things "by hand, means by jdbc queries" - should i
change that?

any hint / pointer to doc / suggestions would be nice!
joe

- Original Message -
From: Craig R. McClanahan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 27, 2000 6:37 PM
Subject: Re: Actions - design question


> Denis Hanson wrote:
>
> > Hi all,
> >
> > I am starting to move our existing web application to the struts
framework
> > and would like to ask a design question.
> >
> > Here's my problem. After logon, the application user is forwarded to one
of
> > three screens - sysadmin, admin, user.  The screen used is determined by
the
> > user's role.  (The three screens have no commonality, so I don't think I
can
> > use the one  action attrubute shown in the
> > example application.)
> >
> > I'm looking for some way to define the various paths in
struts-config.xml so
> > that the logon action class doesn't have hardcoded paths to the three
> > role-based screens.
> >
> > Do I need to create my own ActionMapping class and add additional
 > name=/> entries, or is there some other way to do this?
> >
>
> Because we're talking about "what does the logon action forward to", you
won't
> need any additional action definitions.  However, you might want some
additional
> forwards defined.  For concreteness, let's assume that your three roles
are
> named "admin", "manager", and "user".
>
> One approach to this would be to define, nested within the 
element for
> the login action, some forwards that are specific to only this action:
>
> 
> ...
> 
> ...
> 
> 
> 
> 
> 
> ...
> 
> ...
> 
>
> In this scenario, you can do the following at the end of the login action:
>
> String role = ... look up the role for this user ...
> return (mapping.findForward(role));
>
> to forward control to the menu for your user, without the action having to
know
> what the JSP page name is -- only the role name.
>
> In the example above, the forwards "admin", "manager", and "user" are
defined
> locally for this particular action, and are not visible to any other
action.
> You can also define global forwards by nesting them in the

> section instead.  When the findForward() method is executed, it searches
first
> in the local forwards for this particular action, and then in the global
> forwards.
>
>
> >
> > Thanks,
> >
> > Denis Hanson
>
> Craig McClanahan
>
>




Re: Actions - design question

2000-11-27 Thread Craig R. McClanahan

Denis Hanson wrote:

> Hi all,
>
> I am starting to move our existing web application to the struts framework
> and would like to ask a design question.
>
> Here's my problem. After logon, the application user is forwarded to one of
> three screens - sysadmin, admin, user.  The screen used is determined by the
> user's role.  (The three screens have no commonality, so I don't think I can
> use the one  action attrubute shown in the
> example application.)
>
> I'm looking for some way to define the various paths in struts-config.xml so
> that the logon action class doesn't have hardcoded paths to the three
> role-based screens.
>
> Do I need to create my own ActionMapping class and add additional  name=/> entries, or is there some other way to do this?
>

Because we're talking about "what does the logon action forward to", you won't
need any additional action definitions.  However, you might want some additional
forwards defined.  For concreteness, let's assume that your three roles are
named "admin", "manager", and "user".

One approach to this would be to define, nested within the  element for
the login action, some forwards that are specific to only this action:


...

...





...

...


In this scenario, you can do the following at the end of the login action:

String role = ... look up the role for this user ...
return (mapping.findForward(role));

to forward control to the menu for your user, without the action having to know
what the JSP page name is -- only the role name.

In the example above, the forwards "admin", "manager", and "user" are defined
locally for this particular action, and are not visible to any other action.
You can also define global forwards by nesting them in the 
section instead.  When the findForward() method is executed, it searches first
in the local forwards for this particular action, and then in the global
forwards.


>
> Thanks,
>
> Denis Hanson

Craig McClanahan





Actions - design question

2000-11-27 Thread Denis Hanson


Hi all,

I am starting to move our existing web application to the struts framework
and would like to ask a design question.

Here's my problem. After logon, the application user is forwarded to one of
three screens - sysadmin, admin, user.  The screen used is determined by the
user's role.  (The three screens have no commonality, so I don't think I can
use the one  action attrubute shown in the
example application.)

I'm looking for some way to define the various paths in struts-config.xml so
that the logon action class doesn't have hardcoded paths to the three
role-based screens.

Do I need to create my own ActionMapping class and add additional  entries, or is there some other way to do this?

Thanks,

Denis Hanson









Re: Design question: Frames or

2000-11-21 Thread Craig R. McClanahan



Nikolaus Rumm wrote:

Hello, I
have a question regarding the best practise in page design using struts.
One common problem is that a page is composed of several jsp-pages. Normally
one would do this using frames, but struts allows a solution with tables
and -tags. *
IMHO different frames lead to different request-paths, as every frame is
an independent page. In the case of  tags, will I get
a single request, or one for each page ?*
Is it possible to refresh a frame or an included page programmatically
from another page/action ? What I'm looking for is something as a forward
tag with a target property. Regards Nikolaus
The last time I suggested frames to a particular web developer that I was
working with, it's a good thing I was standing a ways back -- she would
have broken my nose :-).  There tend to be very strong feelings on
both sides of this issue, so Struts is basically capable of supporting
either style.
On your latter question, you can indeed cause a different frame to be
refreshed programmatically using JavaScript.
Craig
PS:  One note -- you should only use the  tag
instead of  if you are nested inside another tag (like
perhaps an iteration).  Otherwise, go ahead and use ,
which will give you higher performance.  The reason for this is that
 currently has a limitation that its output can only go
straight to the response, and cannot be buffered.  The 
tag works around this by initiating a separate HTTP request inside the
tag, and then buffering the response.
 




Re[2]: Design question: Frames or

2000-11-21 Thread Matthias Kerkhoff

>> You have at least three options to update "foreign" frames:
>>
>> client-side:
>> - You can use JavaScript
>> - You can use the target= parameter of 'S or 's

> -links are not applicable, as they require user interaction for
> triggering the update.

So, you're looking for some kind of auto-update w/o any user
interaction ...

>> Server-side:
>> - You can use the "Window-Target:" header at the server side
>>   to specify the target window of the response. (Both Mozilla
>>   and IE5* support this little-known feature)

... then the server-side approach will not be usable anyway,
because Window-Target is set in the _response_ (ie. you have
to have a client-initiated request that you can respond to)

Server-side push generally scales very bad, because each
push client usually has an open connection to the server.

I remember that there is an IBM redbook with some interesting
infos on the subject. They have a nice description of all
options and their (dis-)advantages. I think it was in
"Design and Implement Servlets, JSPs, and EJBs for IBM
 WebSphere Application Server".

Matthias

PS: Window-Target _may_ work too with IE4, I just haven't it.
Navigator 4.7x and probably earlier versions do support
Window-Target (which originally has been introduced from
Netscape).





Re: Design question: Frames or

2000-11-21 Thread Nikolaus Rumm

Thank you for your fast response.
>From the given solutions only JavaScript is applicable to my project, as it
requires support for version-4-browsers. I hoped that I had not to use
JavaScript for this job. Isn't this a standard problem ?

> You have at least three options to update "foreign" frames:
>
> client-side:
> - You can use JavaScript
> - You can use the target= parameter of 'S or 's

-links are not applicable, as they require user interaction for
triggering the update.

>
> Server-side:
> - You can use the "Window-Target:" header at the server side
>   to specify the target window of the response. (Both Mozilla
>   and IE5* support this little-known feature)
>





Re: Design question: Frames or

2000-11-21 Thread Matthias Kerkhoff

> * IMHO different frames lead to different request-paths, as every frame is an 
>independent page. In the case of  tags, will I get a single request, 
>or one for each page ?
> * Is it possible to refresh a frame or an included page programmatically from 
>another page/action ? What I'm looking for is something as a forward tag with a 
>target property.

I've choosen FRAME's in my current project, because they allow me to
minimize the traffic between the server and the client.
In my case, one of the frames contains a large explorer tree, that
has about ~30k. Loading this tree with each request (due to including
it) would slow down the overall response time dramatically.
To further reduce traffic, I have a global stylesheet and JavaScript
library, both loaded at the first visit of the site. If the user
hasn't turned of caching (or uses Mozilla 6 with it's broken cache
implementation), the stylesheet and the script lib are fetched from
the browsers cache for subsequent pages.

You have at least three options to update "foreign" frames:

client-side:
- You can use JavaScript
- You can use the target= parameter of 'S or 's

Server-side:
- You can use the "Window-Target:" header at the server side
  to specify the target window of the response. (Both Mozilla
  and IE5* support this little-known feature)

There are some things you should be aware of when you use frames:
- The client may open a framed sub-window in it's own window.
- The client may bookmark a sub-window and later load that bookmark.
- Setting the various cache-header's get's even more important, if
  you're forwarding into "foreign" frames. Forgetting to do so,
  may lead to very strange results on the client side (esp. when
  the client uses IE5*)
  
HTH.
-- 
Matthias(mailto:[EMAIL PROTECTED])





Design question: Frames or

2000-11-21 Thread Nikolaus Rumm



Hello,
 
I have a question regarding the best practise in 
page design using struts. One common problem is that a page is composed of 
several jsp-pages. Normally one would do this using frames, but struts allows a 
solution with tables and -tags.
 
* IMHO different frames lead to different 
request-paths, as every frame is an independent page. In the case of 
 tags, will I get a single request, or one for each page 
?
* Is it possible to refresh a frame or an included 
page programmatically from another page/action ? What I'm looking for is 
something as a forward tag with a target property.
 
Regards
 
Nikolaus


RE: Design question

2000-11-10 Thread Juan Gargiulo

Craig,

My understanding from what you responded me about ActionForm being EJBs was
wrong, sorry about that. However, your explanation in the last email was
extremely useful.

Thanks,

juan

-Original Message-
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 10, 2000 4:35 PM
To: [EMAIL PROTECTED]
Subject: Re: Design question


Juan Gargiulo wrote:

> Craig,
>
> Thanks a lot for your answer.
> I think that I'm very close of defining the architecture for my
application.
> Using action classes as adapters and session EJBs for business logic
sounds
> good.

Yep.

> Also using EJBs as actionforms is a good idea because they are a good
> target for object reuse. But it is not clear to me how do this. I don't
see
> how struts is going to know how to get one of this EJB-actionforms from
the
> context. How I specify the name of the home for the EJB-form to the action
> class (to the struts descriptor)?
>

Actually, I do *not* believe it is a good idea to re-use an EJB as an
ActionForm.  In fact, this will be somewhat more difficult in 1.0, now that
ActionForm is a class rather than an interface.

The reasoning behind my belief goes like this:

* An ActionForm is part of the view layer of MVC, not the model
  layer like an EJB (or a regular JavaBean that represents
  persistent data).

* The sole purpose of an ActionForm is to maintain the state of
  all the input variables on a particular form, so that you can
  reproduce the form pre-filled-in if the user made an error that they
  need to fix.  This matches the expectations of users who are used
  to GUI-based client server apps, that never make you retype any
  input except the stuff you did wrong.

* Because of the above, the "domain" of an ActionForm does not
  necessarily match any existing EJBs or model layer JavaBeans.
  It is not uncommon to have inputs from a single form that will
  ultimately cause updates to more than one undelrying EJB or
  model bean.

* Using a separate class for the ActionForm means you can
  change the underlying organization of your model beans or EJBs
  without impacting the view layer (although there might be modest
  impacts on the Action classes that copy things back and forth).

* In addition, most EJBs and model beans have validation rules
  internally that prevent them from accepting semantically invalid
  data.  Such rules would prevent you from accomplishing the
  primary purpose of an ActionForm -- storing all of the user's
  input fields, so that you can reproduce the input screen.

* Also, if your form is multiple pages and you were using the real
  EJB, let's say you start updating properties based on receiving
  the first page.  Now, you've potentially started locking resources
  in the underlying database -- and you have to deal with the fact
  that the user may never come back and finish this transaction.

So, my bottom line recommendation is that you plan on building simple
JavaBeans
for your ActionForms.  Most of the time, an ActionForm will have just
getters
and setters, with no error checking (other than a validate() method if you
want
to use it, plus the reset() method).  PropertyUtils also has a convenience
function that can copy properties with like names from your EJB to the
ActionForm bean (or vice versa), to reduce the amount of tedious code that
this
approach implies.  And, at some future point, it's reasonable to expect a
development tool to be able to auto-generate ActionForm beans for you.

Using an EJB as a bean that provides data values used in the presentation,
on
the other hand, is pretty easy.  Just store the client-side instance you get
back from the EJB server as a request attribute or session attribute -- from
the
perspective of the Struts custom tags, this EJB just looks like a JavaBean
with
getter methods, so they don't care that it is really an EJB.  NOTE:  If the
EJBs
are really on a remote server this could have some performance impact -- you
might be better served to copy data into local beans in that case.

>
> Thanks,
>
> juan
>

Craig






<    1   2   3   4   5   >