Re: best practice question

2002-07-29 Thread Bill Blackmon

Thanks - that's what I wanted to use and it's the way I've handled
situations like this in other
types of apps. The formbeans aren't stable since they're always
being reset at intervals I can't quite understand the reasoning behind at
this point in
my development. The collections will never be updated, at least not while
they're in
memory. I'll look into the Plug-In option and see what it offers.

Thanks,
Bill
- Original Message -
From: "Martin Cooper" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Monday, July 29, 2002 2:33 PM
Subject: RE: best practice question


> You don't want a form bean for this data, because you're not associating
it
> with a specific form, and because a form bean is not instantiated until
it's
> needed by the  tag or an associated action, neither of which
will
> happen in your scenario.
>
> Your original idea is the right one. Load the data from the database at
> startup time, storing it in one or more regular JavaBeans, as appropriate.
> Then, assuming the data is application-wide, you can put the JavaBean(s)
in
> application scope, or create a singleton to hold them.
>
> The easiest place to do this work is in a Plugin, if you're using Struts
> 1.1-b1 or a nightly build. It's an extremely simple interface, and a snap
to
> use.
>
> --
> Martin Cooper
>
>
> > -----Original Message-----
> > From: Bill Blackmon [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 29, 2002 8:09 AM
> > To: Struts Users Mailing List
> > Subject: Re: best practice question
> >
> >
> > Thanks. I'll try that. I guess I'd just create an instance of
> > the form bean
> > class at the entry to the app with the request passed in and
> > create the form
> > bean in application or session scope? The formbean would be
> > declared in the
> > struts.xml file with session or application scope? I'm just
> > thinking out
> > loud. I don't want the form bean to be attached to any action
> > if possible.
> > I'm new to this so bear with me!
> >
> > Thanks,
> > Bill
> > - Original Message -
> > From: "Struts Newsgroup" <@[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, July 29, 2002 10:40 AM
> > Subject: Re: best practice question
> >
> >
> > > Subject: Re: best practice question
> > > From: Vic C <[EMAIL PROTECTED]>
> > >  ===
> > > No need to optimize, just do it as a formbean with c:for
> > each or logic:
> > > iterate ...or html:options.
> > > v.
> > >
> > > Bill Blackmon wrote:
> > > > I have several iterators filled from db calls that will
> > be used across
> > the
> > > > app for select boxes,
> > > > lists of checkboxes, radio button etc.. In the context of
> >  Struts, would
> > it
> > > > be best to load these items as application level items at
> > startup and
> > define
> > > > them in the struts-config.xml file with a reference to
> > the class that
> > does
> > > > the loading? Any opinions are greatly appreciated.
> > > >
> > > > Bill
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


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




RE: best practice question

2002-07-29 Thread Martin Cooper

You don't want a form bean for this data, because you're not associating it
with a specific form, and because a form bean is not instantiated until it's
needed by the  tag or an associated action, neither of which will
happen in your scenario.

Your original idea is the right one. Load the data from the database at
startup time, storing it in one or more regular JavaBeans, as appropriate.
Then, assuming the data is application-wide, you can put the JavaBean(s) in
application scope, or create a singleton to hold them.

The easiest place to do this work is in a Plugin, if you're using Struts
1.1-b1 or a nightly build. It's an extremely simple interface, and a snap to
use.

--
Martin Cooper


> -Original Message-
> From: Bill Blackmon [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 29, 2002 8:09 AM
> To: Struts Users Mailing List
> Subject: Re: best practice question
> 
> 
> Thanks. I'll try that. I guess I'd just create an instance of 
> the form bean
> class at the entry to the app with the request passed in and 
> create the form
> bean in application or session scope? The formbean would be 
> declared in the
> struts.xml file with session or application scope? I'm just 
> thinking out
> loud. I don't want the form bean to be attached to any action 
> if possible.
> I'm new to this so bear with me!
> 
> Thanks,
> Bill
> - Original Message -
> From: "Struts Newsgroup" <@[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 29, 2002 10:40 AM
> Subject: Re: best practice question
> 
> 
> > Subject: Re: best practice question
> > From: Vic C <[EMAIL PROTECTED]>
> >  ===
> > No need to optimize, just do it as a formbean with c:for 
> each or logic:
> > iterate ...or html:options.
> > v.
> >
> > Bill Blackmon wrote:
> > > I have several iterators filled from db calls that will 
> be used across
> the
> > > app for select boxes,
> > > lists of checkboxes, radio button etc.. In the context of 
>  Struts, would
> it
> > > be best to load these items as application level items at 
> startup and
> define
> > > them in the struts-config.xml file with a reference to 
> the class that
> does
> > > the loading? Any opinions are greatly appreciated.
> > >
> > > Bill
> > >
> > >
> > >
> > > --
> > > 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: best practice question

2002-07-29 Thread Eddie Bush

You don't want it in the session if it's very big!  There's no reason to 
load this data repeatedly (for each user!) if it is non-volatile!  Load 
it on startup as I mentioned in my other post and merely reference it. 
 If it is volatile you'll have to devise some strategy for updating it. 
 Assuming that, when it is updated, you only have one "writer" (we know 
there are many possible "readers"), you shouldn't have to serialize any 
access to it.  That would be the most straight-forward implementation 
(you wouldn't really need anything to manage updates).  If (parts of) it 
may be updated by multiple threads, you'll want to either serialize 
updates to those pieces or take the db hit to retrieve it when you need it.

HTH,

Eddie

Bill Blackmon wrote:

>Thanks. I'll try that. I guess I'd just create an instance of the form bean
>class at the entry to the app with the request passed in and create the form
>bean in application or session scope? The formbean would be declared in the
>struts.xml file with session or application scope? I'm just thinking out
>loud. I don't want the form bean to be attached to any action if possible.
>I'm new to this so bear with me!
>
>Thanks,
>Bill
>



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




Re: best practice question

2002-07-29 Thread Bill Blackmon

Thanks. I'll try that. I guess I'd just create an instance of the form bean
class at the entry to the app with the request passed in and create the form
bean in application or session scope? The formbean would be declared in the
struts.xml file with session or application scope? I'm just thinking out
loud. I don't want the form bean to be attached to any action if possible.
I'm new to this so bear with me!

Thanks,
Bill
- Original Message -
From: "Struts Newsgroup" <@[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 29, 2002 10:40 AM
Subject: Re: best practice question


> Subject: Re: best practice question
> From: Vic C <[EMAIL PROTECTED]>
>  ===
> No need to optimize, just do it as a formbean with c:for each or logic:
> iterate ...or html:options.
> v.
>
> Bill Blackmon wrote:
> > I have several iterators filled from db calls that will be used across
the
> > app for select boxes,
> > lists of checkboxes, radio button etc.. In the context of  Struts, would
it
> > be best to load these items as application level items at startup and
define
> > them in the struts-config.xml file with a reference to the class that
does
> > the loading? Any opinions are greatly appreciated.
> >
> > Bill
> >
> >
> >
> > --
> > 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: best practice question

2002-07-29 Thread Eddie Bush

Assuming these are application-level, read-only values, I would think 
you would want to load them at start and make them in application scope 
- yes.  By doing so, not only do you not have to hit the database again, 
but you just reduced your over-all memory footprint too (since you don't 
have to mess around with loading them into a session/request).  Be 
careful about what you put there and how you manage it though ;-)  If 
these are values that change periodically, it may be easiest to just 
take the db hit.  If they are fairly stable (ie. don't change a lot) 
then putting them into the application scope would seem to me a very 
good way to go about it.  Hopefully someone else will have additional 
input ;-)

Regards,

Eddie

Bill Blackmon wrote:

>I have several iterators filled from db calls that will be used across the
>app for select boxes,
>lists of checkboxes, radio button etc.. In the context of  Struts, would it
>be best to load these items as application level items at startup and define
>them in the struts-config.xml file with a reference to the class that does
>the loading? Any opinions are greatly appreciated.
>
>Bill
>
>
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 
>



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




Re: best practice question

2002-07-29 Thread @Basebeans.com

Subject: Re: best practice question
From: Vic C <[EMAIL PROTECTED]>
 ===
No need to optimize, just do it as a formbean with c:for each or logic: 
iterate ...or html:options.
v.

Bill Blackmon wrote:
> I have several iterators filled from db calls that will be used across the
> app for select boxes,
> lists of checkboxes, radio button etc.. In the context of  Struts, would it
> be best to load these items as application level items at startup and define
> them in the struts-config.xml file with a reference to the class that does
> the loading? Any opinions are greatly appreciated.
> 
> Bill
> 
> 
> 
> --
> 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: Best Practice Question/Conceptual Problem

2002-06-26 Thread Ted Husted

There's an option for using a Map if you need more than one parameter. 

"Struts Newsgroup (@Basebeans.com)" wrote:
> 
> Subject: Re: Best Practice Question/Conceptual Problem
> From: "Kenny Smith" <[EMAIL PROTECTED]>
>  ===
> Hi Mark et al,
> 
> Thank you all for your help, I've gotten it to work, and I understand the
> concept now. My next hurdle is using the bean data in  tags. I've
> found that I can use the paramId, paramName and paramProperty tags to add a
> parameter to the html:link, but what if I want to add 2 params? It seems
> kind of silly to hardcode the ability to add one parameter. Am I missing
> something?
> 
> Kenny Smith
> 
> --
> 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: Best Practice Question/Conceptual Problem

2002-06-25 Thread Kamholz, Keith (corp-staff) USX

can you really use  before the  tag?  I did
something similar (i forget if i used  or ) and I
got errors complaining about the id variable already existing or that it had
already been declared.  i may have been doing something wrong, but it didn't
work for me.

Keith Kamholz
Moog 
East Aurora, NY
(716) 687-7282
[EMAIL PROTECTED]


-Original Message-
From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:40 PM
To: 'Struts Users Mailing List'
Subject: RE: Best Practice Question/Conceptual Problem


It gets it from a JavaBean, List or Map either already in some reachable
scope or defined in your JSP.  For example, if I've defined a list of states
in an action class like:


List statesList = new ArrayList( State.getStates());

where State is a command object or stateless session bean querying the
database to retrieve a list of states, and I stick them into application
scope (so everyone can use it):

ServletContext servletContext = this.servlet.getServletContext();
servletContext.setAttribute( "listStates", listStates);

I can iterate through this list on a JSP and display the names like:









or perhaps I need a data object specific to the user on the JSP:



where "customer" is an Order object specific to this customer's ID
(retrieved from the database when the user passes his ID through a form), so
I can display the pending orders this customer has placed:










There are tons of examples in the archive.

Mark

-Original Message-
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:10 PM

Subject: Re: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

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

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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread Galbreath, Mark

It gets it from a JavaBean, List or Map either already in some reachable
scope or defined in your JSP.  For example, if I've defined a list of states
in an action class like:


List statesList = new ArrayList( State.getStates());

where State is a command object or stateless session bean querying the
database to retrieve a list of states, and I stick them into application
scope (so everyone can use it):

ServletContext servletContext = this.servlet.getServletContext();
servletContext.setAttribute( "listStates", listStates);

I can iterate through this list on a JSP and display the names like:









or perhaps I need a data object specific to the user on the JSP:



where "customer" is an Order object specific to this customer's ID
(retrieved from the database when the user passes his ID through a form), so
I can display the pending orders this customer has placed:










There are tons of examples in the archive.

Mark

-Original Message-
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 4:10 PM

Subject: Re: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

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




Re: Best Practice Question/Conceptual Problem

2002-06-24 Thread Ted Husted

The name parameter you pass to the iterate tag matches the name of the
attribute in (page,request,session,application) scope. 

In other words, the context and the tags use the same "protocol" for the
property names. 

The other parameter to iterate, id, tells the tag what name to use when
it exposes each entry in the collection. 

The tag looks in the page context first, then request, session, and
application. (Unless you specify a scope.)

"Struts Newsgroup (@Basebeans.com)" wrote:
> 
> Subject: Re: Best Practice Question/Conceptual Problem
> From: "Kenny Smith" <[EMAIL PROTECTED]>
>  ===
> Hi Keith,
> 
> But how does the logic:iterate tag know where to get the information from?
> That's the part that is really baffling me. I don't understand how it's
> getting the information, so I'm not sure how to apply it to other
> applications, etc. Could you (or anyone) please explain how it knows?
> 
> Kenny

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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread James Mitchell

Your best bet is to take a look at some source code for the taglibs, it can
clear up a few things for you.

HTH!

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -Original Message-
> From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]]
> Sent: Monday, June 24, 2002 4:10 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Best Practice Question/Conceptual Problem
>
>
> Subject: Re: Best Practice Question/Conceptual Problem
> From: "Kenny Smith" <[EMAIL PROTECTED]>
>  ===
> Hi Keith,
>
> But how does the logic:iterate tag know where to get the information from?
> That's the part that is really baffling me. I don't understand how it's
> getting the information, so I'm not sure how to apply it to other
> applications, etc. Could you (or anyone) please explain how it knows?
>
> 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]>




Re: Best Practice Question/Conceptual Problem

2002-06-24 Thread @Basebeans.com

Subject: Re: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
Hi Keith,

But how does the logic:iterate tag know where to get the information from?
That's the part that is really baffling me. I don't understand how it's
getting the information, so I'm not sure how to apply it to other
applications, etc. Could you (or anyone) please explain how it knows?

Kenny




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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread Kamholz, Keith (corp-staff) USX

Use something like this:

Do this on each iteration


The tag should take care of everything for you.  I forget if you have to
specify scope="session" in the , but if you have problems try
adding it.

~ Keith


-Original Message-
From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 2:25 PM
To: [EMAIL PROTECTED]
Subject: Re: Best Practice Question/Conceptual Problem


Subject: Re: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
> It then stuffs the information into the session and forwards the request
> to a JSP page
>
> The JSP page pulls the data out, builds the page and sends it back to
> the user...
>
> Does that help?

Somewhat, yes. I understand how to get the information, but putting it in
the session and retreiving it is where I sort of fall down. I understand the
syntax of putting something in the session (although I haven't been able to
find where the Constants class is, that is used in every example).. but
something like:

Market[] markets = Market.findByActive( true ) ;
HttpSession session = request.getSession() ;
session.put( "markets" , markets ) ;

Is that correct?

but how do I get it out of the session to use with the logic:iterate tag?

Thanks for the reply,
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]>




Re: Best Practice Question/Conceptual Problem

2002-06-24 Thread @Basebeans.com

Subject: Re: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
> It then stuffs the information into the session and forwards the request
> to a JSP page
>
> The JSP page pulls the data out, builds the page and sends it back to
> the user...
>
> Does that help?

Somewhat, yes. I understand how to get the information, but putting it in
the session and retreiving it is where I sort of fall down. I understand the
syntax of putting something in the session (although I haven't been able to
find where the Constants class is, that is used in every example).. but
something like:

Market[] markets = Market.findByActive( true ) ;
HttpSession session = request.getSession() ;
session.put( "markets" , markets ) ;

Is that correct?

but how do I get it out of the session to use with the logic:iterate tag?

Thanks for the reply,
Kenny



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




RE: Best Practice Question/Conceptual Problem

2002-06-24 Thread wbchmura

Hi

When your users request the list, the request goes to an action...

The action calls the appropriate things to get the data...

It then stuffs the information into the session and forwards the request 
to a JSP page

The JSP page pulls the data out, builds the page and sends it back to 
the user...

Does that help?


-Original Message-
From: struts [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 12:25 PM
To: struts-user
Subject: Best Practice Question/Conceptual Problem


Subject: Best Practice Question/Conceptual Problem
From: "Kenny Smith" <[EMAIL PROTECTED]>
 ===
Hello,

I'm trying to write my first struts application, and I'm looking for
guidance on how to accomplish a certain task. I've read through the 
Struts
Userguide and I've been going through the struts-example application, 
but
I'm not exactly sure what concept I'm missing that is keeping me from
wrapping my head around the problem.

I have a list of "markets" in a database table. I have a Market bean 
that
can be instantiated to represent a row in the table, and it has static
methods for finding markets by id, creating markets, etc. I would like 
my
user to be able to click a "List Active Markets" link and have it take 
them
to a page where it lists the markets.

Seems simple enough, but I can't figure out how to make the data 
available
to my JSP page. I assume I should use a logic:iterate tag to display 
data
for each of the markets, but I just don't understand how I make the data
available to the JSP or logic:iterate tag.

I've been reading and reading, and I can't figure it out, there seems to 
be
some piece missing. Can anyone help me? This seems like a fairly
basic/common action, so is there anyone out there that has suggestions 
for
the "best practice" solution?

Thanks,
Kenny Smith
JournalScape.com



--
To unsubscribe, e-mail:   

For additional commands, e-mail: 




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




RE: Best Practice Question.

2002-05-05 Thread Jesse Alexander (KADA 12)

Hi,

I see three options:
 a) make the config-bean a singleton: easy to access from everywhere in the JVM
 b) put the config-bean into the servlet-context: makes it easy to access it
within the webapp, but somehow you need access to request or servlet-context
 c) create a lookup-bean (JVM-singleton) and have this bean provide access
to the config-bean: usefull if you have more than one bean. Eg. we use it
to give our apps access to some helper-classes. Always the same 
mechanism to access whatever helper-class one needs...
hope this helps
Alexander 

-Original Message-
From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 30. April 2002 19:51
To: Struts User List
Subject: Best Practice Question.


I have a bean that is created when my app starts and it contains some
database table conifguration info (I'll call it my config bean). Later on in
an Action class another bean, that I'll call my logic bean, needs to access
the values of the config bean. Would it be proper to use the Action class to
pass the config bean to the logic bean and let the logic bean extract the
values or should I extract all the values from the config bean within the
Action class and pass the config info in a different manner.

Thanks,
Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws



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

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




Re: Best Practice Question.

2002-04-30 Thread Eddie Bush

The goal of keeping business logic out of action classes (IMHO) is to
increase the reusability of the logic.  Based on this, I would say it
depends on how you use your value / logic / config beans on your
non-web-based applications (if any).  Or, how you would use them if/when you
went to build other (non-web-based) applications.

Have foresight.  Think of how you can make the most out of what you are
going to write.  Have as your end goal reusability.  Build everything on
that precept.

No, you can't reuse everything you write, but the goal is to maximize code
reuse.

HTH,

Eddie


- Original Message -
From: "Phase Web and Multimedia" <[EMAIL PROTECTED]>
To: "Struts User List" <[EMAIL PROTECTED]>
Sent: Tuesday, April 30, 2002 12:50 PM
Subject: Best Practice Question.


> I have a bean that is created when my app starts and it contains some
> database table conifguration info (I'll call it my config bean). Later on
in
> an Action class another bean, that I'll call my logic bean, needs to
access
> the values of the config bean. Would it be proper to use the Action class
to
> pass the config bean to the logic bean and let the logic bean extract the
> values or should I extract all the values from the config bean within the
> Action class and pass the config info in a different manner.
>
> Thanks,
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> [EMAIL PROTECTED]
> http://www.phase.ws
>
>
>
> --
> To unsubscribe, e-mail:

> For additional commands, e-mail:

>


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




Re: Best Practice Question.

2002-04-30 Thread Craig R. McClanahan



On Tue, 30 Apr 2002, Phase Web and Multimedia wrote:

> Date: Tue, 30 Apr 2002 11:50:30 -0600
> From: Phase Web and Multimedia <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts User List <[EMAIL PROTECTED]>
> Subject: Best Practice Question.
>
> I have a bean that is created when my app starts and it contains some
> database table conifguration info (I'll call it my config bean). Later on in
> an Action class another bean, that I'll call my logic bean, needs to access
> the values of the config bean. Would it be proper to use the Action class to
> pass the config bean to the logic bean and let the logic bean extract the
> values or should I extract all the values from the config bean within the
> Action class and pass the config info in a different manner.
>

You'll need to pass a reference to the config bean as a parameter to a
logic bean method.  You could instead pass a reference to the servlet
context (so that it could pull out the config bean attribute), but that
ties you more tightly to running only in a web application -- presumably,
your config bean doesn't have any "javax.servlet.*" imports in it, so it
could be reused elsewhere.

> Thanks,
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> [EMAIL PROTECTED]
> http://www.phase.ws
>

Craig


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




RE: Best Practice Question.

2002-04-30 Thread Ajay Chitre

Hello,

Here's how I pass around Configuration properties in my Struts application.
 Certainly this isn't the best practise, but just an idea;

I have created a Singleton class called 'PropertyRetriever' which is simillar
to the "Service Locator" design pattern.  It uses Digester to read configuration
properties from a XML file.

Here's what it looks like;

public class PropertyRetriever {

// Singleton's private instance
private static PropertyRetriever me;

private static Digester digester = null;
private static AppRoot root = null;

static {
try {
me = new PropertyRetriever();
} catch (Exception ex) {
//throw new PropertyRetrieverException();
}
}

private PropertyRetriever() throws Exception {  //private construtor
to avoid instantiation
getProperties();
}

// Returns PropertyRetriever instance
static public PropertyRetriever getInstance() {
return me;
}

private void getProperties() throws Exception {

// Configure digester
digester = new Digester();

etc etc.


Now from my Action Classes in Struts, I can get any property as follows;

PropertyRetriever propertyRetriever = PropertyRetriever.getInstance();
String appName = propertyRetriever.getAppRoot().getAppName();


I am sure there are pros & cons of this approach.

HTH!

>-- Original Message --
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>From: "Phase Web and Multimedia" <[EMAIL PROTECTED]>
>To: "Struts User List" <[EMAIL PROTECTED]>
>Subject: Best Practice Question.
>Date: Tue, 30 Apr 2002 11:50:30 -0600
>
>
>I have a bean that is created when my app starts and it contains some
>database table conifguration info (I'll call it my config bean). Later
on
>in
>an Action class another bean, that I'll call my logic bean, needs to access
>the values of the config bean. Would it be proper to use the Action class
>to
>pass the config bean to the logic bean and let the logic bean extract the
>values or should I extract all the values from the config bean within the
>Action class and pass the config info in a different manner.
>
>Thanks,
>Brandon Goodin
>Phase Web and Multimedia
>P (406) 862-2245
>F (406) 862-0354
>[EMAIL PROTECTED]
>http://www.phase.ws
>
>
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 
>

Ajay Chitre

Diligent Team, Inc.
(Where Diligent People Work as a Team)

http://www.DiligentTeam.com


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




RE: Best Practice Question.

2002-04-30 Thread Phase Web and Multimedia

I have set up a mechanism similar to Tomcat's Realm at the app level. It is
used to identify the database name(jndi),tables and columns that contain
user and role information in the database. At the start of my app the
database information is placed into an application scope bean using
digester. Then whenever a secure url is requested I have a Filter class that
routes to the security Action upon request of secure url then to a specified
login form. When the login form is submitted a validation of the username
and password needs to occur. This is the point at which I have a logic bean
that validates against thte database. It does so by checking the specified
database,tables and columns for user validation etc...(there is much more
detail but I think this is sufficient to get the point). So, this explains
why I have a config bean and a need to pass info to the logic bean. All I
want to know is, is what I am doing proper form? Is it accepted practice to
pass a bean to a bean?

Also, please don't turn this into a discussion of "Why not use container
based security?" As a note, I already do in a round-about way. :-)

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws


-Original Message-
From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 12:03 PM
To: 'Struts Users Mailing List'
Subject: RE: Best Practice Question.


This is rather vague.  Why does your logicBean need your configBean?

Mark

-Original Message-
From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 1:51 PM

I have a bean that is created when my app starts and it contains some
database table conifguration info (I'll call it my config bean). Later on in
an Action class another bean, that I'll call my logic bean, needs to access
the values of the config bean. Would it be proper to use the Action class to
pass the config bean to the logic bean and let the logic bean extract the
values or should I extract all the values from the config bean within the
Action class and pass the config info in a different manner.

Thanks,
Brandon Goodin

--
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: Best Practice Question.

2002-04-30 Thread Bhaskar Gopalan

Depends.
If the logic bean is a form bean, the action class should extract values
from config bean and then call set methods on form bean, i.e. a clean
separation between db beans and form beans. else, pass the config bean
to logic bean.

-GB

-Original Message-
From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 1:51 PM
To: Struts User List
Subject: Best Practice Question.


I have a bean that is created when my app starts and it contains some
database table conifguration info (I'll call it my config bean). Later on in
an Action class another bean, that I'll call my logic bean, needs to access
the values of the config bean. Would it be proper to use the Action class to
pass the config bean to the logic bean and let the logic bean extract the
values or should I extract all the values from the config bean within the
Action class and pass the config info in a different manner.

Thanks,
Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws



--
To unsubscribe, e-mail:

For additional commands, e-mail:


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




RE: Best Practice Question.

2002-04-30 Thread Galbreath, Mark

This is rather vague.  Why does your logicBean need your configBean?

Mark

-Original Message-
From: Phase Web and Multimedia [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 1:51 PM

I have a bean that is created when my app starts and it contains some
database table conifguration info (I'll call it my config bean). Later on in
an Action class another bean, that I'll call my logic bean, needs to access
the values of the config bean. Would it be proper to use the Action class to
pass the config bean to the logic bean and let the logic bean extract the
values or should I extract all the values from the config bean within the
Action class and pass the config info in a different manner.

Thanks,
Brandon Goodin

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