You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Curtney Jacobs <c....@comcast.net> on 2003/08/05 01:50:39 UTC
Calling A default Action Upon Application Startup
Greetings everyone!
I would like to preopulate serveral forms with default values retrieve from a
database upon application startup or after a successful login by the user.
I have an approach in mind, however, I am not sure if it is the most efficient
or best approach. My approach is to use a filter that creates and stores in
memory default ActionForms. The ActionForm will contain default values for
select fields (or any other fields) retrieved from a database. The
ActionForms will be stored within the current user session and then controll
will be given over to Struts ActionServlet.
Another similar approach would be to register a listerner
(HttpSessionAttributeListener) that would essentially wait for a specific
attribute to be added into the session (i.e SETUP_FORMS) then it would query
the database for neccessary application setup data.
I read the message archive, and a few have suggested calling a "setup action"
per request that prepopulates the default values in the ActionForm. This is a
valid approach, but IMHO only for small applications. It just seems that
there will be to much "traffic" going on between the app and the database.
Correct me if I am wrong.
If you have gotten this far please share your thoughts on this topic.
Curtney
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Calling A default Action Upon Application Startup
Posted by Aguirre Carlos Federico <fa...@cba.com.ar>.
For load your default values at aplication startup you can create a
HttpServlet, and load data from database and store in application scope.
In struts 1.1 instead of HttpServlet you can create a Struts plugin to do
the same.
second, when a user need access to one "use case" with default data, create
an action that populate your form with data stored in application scope.
"Curtney Jacobs" <c....@comcast.net> escribi� en el mensaje
news:200308050748.46588.c.curtneyjacobs@comcast.net...
> Greetings Carlos. Thanks for replying.
>
> Yes. I can populate a form that way. However, it wouldn't quite give me
what I
> want. For instance, as the application is initially loaded there should be
> default values already in the forms; this should be done prior to any user
> action.
>
> I like your one action approach. Is there a way to call this action as the
> application is initially loaded. Again, no user interaction should trigger
> this action class.
>
> Thanks,
>
> Curtney
>
> On Monday 04 August 2003 05:09 pm, Aguirre Carlos Federico wrote:
> > if you need to populate a form, you can do in one action
> > and then forward to jsp, why you need to pre-populate ??
> >
> > "Curtney Jacobs" <c....@comcast.net> escribi� en el mensaje
> > news:200308041650.40020.c.curtneyjacobs@comcast.net...
> >
> > > Greetings everyone!
> > >
> > >
> > > I would like to preopulate serveral forms with default values retrieve
> >
> > from a
> >
> > > database upon application startup or after a successful login by the
> > > user.
> > >
> > > I have an approach in mind, however, I am not sure if it is the most
> >
> > efficient
> >
> > > or best approach. My approach is to use a filter that creates and
stores
> >
> > in
> >
> > > memory default ActionForms. The ActionForm will contain default values
> > > for select fields (or any other fields) retrieved from a database. The
> > > ActionForms will be stored within the current user session and then
> >
> > controll
> >
> > > will be given over to Struts ActionServlet.
> > >
> > >
> > > Another similar approach would be to register a listerner
> > > (HttpSessionAttributeListener) that would essentially wait for a
> > > specific attribute to be added into the session (i.e SETUP_FORMS) then
it
> > > would
> >
> > query
> >
> > > the database for neccessary application setup data.
> > >
> > >
> > > I read the message archive, and a few have suggested calling a "setup
> >
> > action"
> >
> > > per request that prepopulates the default values in the ActionForm.
This
> >
> > is a
> >
> > > valid approach, but IMHO only for small applications. It just seems
that
> > > there will be to much "traffic" going on between the app and the
> > > database. Correct me if I am wrong.
> > >
> > > If you have gotten this far please share your thoughts on this topic.
> > >
> > > Curtney
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Calling A default Action Upon Application Startup
Posted by Curtney Jacobs <c....@comcast.net>.
Greetings Carlos. Thanks for replying.
Yes. I can populate a form that way. However, it wouldn't quite give me what I
want. For instance, as the application is initially loaded there should be
default values already in the forms; this should be done prior to any user
action.
I like your one action approach. Is there a way to call this action as the
application is initially loaded. Again, no user interaction should trigger
this action class.
Thanks,
Curtney
On Monday 04 August 2003 05:09 pm, Aguirre Carlos Federico wrote:
> if you need to populate a form, you can do in one action
> and then forward to jsp, why you need to pre-populate ??
>
> "Curtney Jacobs" <c....@comcast.net> escribió en el mensaje
> news:200308041650.40020.c.curtneyjacobs@comcast.net...
>
> > Greetings everyone!
> >
> >
> > I would like to preopulate serveral forms with default values retrieve
>
> from a
>
> > database upon application startup or after a successful login by the
> > user.
> >
> > I have an approach in mind, however, I am not sure if it is the most
>
> efficient
>
> > or best approach. My approach is to use a filter that creates and stores
>
> in
>
> > memory default ActionForms. The ActionForm will contain default values
> > for select fields (or any other fields) retrieved from a database. The
> > ActionForms will be stored within the current user session and then
>
> controll
>
> > will be given over to Struts ActionServlet.
> >
> >
> > Another similar approach would be to register a listerner
> > (HttpSessionAttributeListener) that would essentially wait for a
> > specific attribute to be added into the session (i.e SETUP_FORMS) then it
> > would
>
> query
>
> > the database for neccessary application setup data.
> >
> >
> > I read the message archive, and a few have suggested calling a "setup
>
> action"
>
> > per request that prepopulates the default values in the ActionForm. This
>
> is a
>
> > valid approach, but IMHO only for small applications. It just seems that
> > there will be to much "traffic" going on between the app and the
> > database. Correct me if I am wrong.
> >
> > If you have gotten this far please share your thoughts on this topic.
> >
> > Curtney
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Calling A default Action Upon Application Startup
Posted by Aguirre Carlos Federico <fa...@cba.com.ar>.
if you need to populate a form, you can do in one action
and then forward to jsp, why you need to pre-populate ??
"Curtney Jacobs" <c....@comcast.net> escribi� en el mensaje
news:200308041650.40020.c.curtneyjacobs@comcast.net...
> Greetings everyone!
>
>
> I would like to preopulate serveral forms with default values retrieve
from a
> database upon application startup or after a successful login by the user.
>
> I have an approach in mind, however, I am not sure if it is the most
efficient
> or best approach. My approach is to use a filter that creates and stores
in
> memory default ActionForms. The ActionForm will contain default values for
> select fields (or any other fields) retrieved from a database. The
> ActionForms will be stored within the current user session and then
controll
> will be given over to Struts ActionServlet.
>
>
> Another similar approach would be to register a listerner
> (HttpSessionAttributeListener) that would essentially wait for a specific
> attribute to be added into the session (i.e SETUP_FORMS) then it would
query
> the database for neccessary application setup data.
>
>
> I read the message archive, and a few have suggested calling a "setup
action"
> per request that prepopulates the default values in the ActionForm. This
is a
> valid approach, but IMHO only for small applications. It just seems that
> there will be to much "traffic" going on between the app and the database.
> Correct me if I am wrong.
>
> If you have gotten this far please share your thoughts on this topic.
>
> Curtney
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org