You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Muhammad Momin Rashid <mo...@amaana.com> on 2004/07/22 16:37:44 UTC

Form Bean and decions based on Business Logic calls

Hello,

I have a form bean which needs to retrieve some information from the
business logic.  I want to know how I can redirect to different pages on the
bases of data retrieved.

e.g. I need to retrieve and display a list of countries for the user to
select from.  In case of failure to retrieve the information I would like to
take user to a different page to indicate error.

What would be the best way to accomplish this?  I am using struts 1.1 with
Tiles.

Regards,
Muhammad Momin Rashid




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Bean and decions based on Business Logic calls

Posted by Muhammad Momin Rashid <mo...@amaana.com>.
Thank you for your answer, aparently in my persuit for something different I
had overlooked such basic things.  You answer has refreshed my knowledge.
Sometimes we press too hard for answers which are already in front of us.

Once again thanks for your time and effort.  I really appreciate your
guidance.

Regards,
Muhammad Momin Rashid.

"Robert Taylor" <rt...@mulework.com> wrote in message
news:OCEBJBKGJIBAILNJEGCKCEPFICAA.rtaylor@mulework.com...
> The information which exists in the query string is just string values.
> The correpsonding parameter names can be defined in the form.
> When invoked, Struts will populate the form and pass it on to the action
> class. The action class extracts the values from the form and passes them
> to the business logic. The business logic does its thing and returns some
> values to the action class. The action class then uses these values to
> decide where to send the user.
>
> robert
>
> > -----Original Message-----
> > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> > Sent: Saturday, July 24, 2004 7:54 AM
> > To: user@struts.apache.org
> > Subject: Re: Form Bean and decions based on Business Logic calls
> >
> >
> > Ok, I guess thats fair enough to keep business logic calls limited to
action
> > classes only.
> >
> > How do you suggest I impliemnt the case where the user is supposed to
> > directly land on a URL, and some information from business logic is
> > required.
> >
> > e.g the case where user clicks on a forgot password email sent to
him/her.
> > Here the information embeded in the URL needs to be sent to the Business
> > Logic for processing.  Based on information returned by the Business
Logic
> > the user is allowed to proceed to reset password or not.
> >
> > Regards,
> > Muhammad Momin Rashid
> >
> > "Robert Taylor" <rt...@mulework.com> wrote in message
> > news:OCEBJBKGJIBAILNJEGCKMEJGICAA.rtaylor@mulework.com...
> > > As Jim already mentioned, its best to keep the form beans as simple as
> > possible
> > > and void of logic.
> > >
> > > Place calls to business logic or delegates in the action class.
> > >
> > > robert
> > >
> > > > -----Original Message-----
> > > > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin
Rashid
> > > > Sent: Thursday, July 22, 2004 12:30 PM
> > > > To: user@struts.apache.org
> > > > Subject: Re: Form Bean and decions based on Business Logic calls
> > > >
> > > >
> > > > Thank you for your quick response.
> > > >
> > > > I do have the appropriate action class with the desired forwards
defined
> > (as
> > > > you have also outlined), but the problem is that the form bean
itself is
> > > > making the business logic calls to get its desired data.  Upon
failure
> > to
> > > > get the desired data, how can I forward to a different page?
Keeping in
> > > > mind that the decision to forward to an failure action is to be done
> > within
> > > > the Form Bean here.
> > > >
> > > > I am also interested in knowing if this is the correct approach to
have
> > the
> > > > form bean make such calls.  If not, then kindly suggest a better
> > > > implementation.
> > > >
> > > > Regards,
> > > > Muhammad Momin Rashid.
> > > >
> > > > "Robert Taylor" <rt...@mulework.com> wrote in message
> > > > news:OCEBJBKGJIBAILNJEGCKAEIOICAA.rtaylor@mulework.com...
> > > > > Define success and failure forwards in your struts-config file for
the
> > > > > specified action.
> > > > >
> > > > > In the action class (which should delegate to a business object),
> > > > > retrieve the data. Upon failure, forward to the "failure" forward,
> > > > > else forward to the "success" forward.
> > > > >
> > > > > You could achieve the same using declarative exceptions.
> > > > >
> > > > > If the list of countries doesn't vary between users, you
> > > > > can do this when your application starts up and place the
> > > > > country list in ServletContext. In this fashion, you only
> > > > > have a single database hit for getting the countries.
> > > > >
> > > > > robert
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad
Momin
> > Rashid
> > > > > > Sent: Thursday, July 22, 2004 10:38 AM
> > > > > > To: user@struts.apache.org
> > > > > > Subject: Form Bean and decions based on Business Logic calls
> > > > > >
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > I have a form bean which needs to retrieve some information from
the
> > > > > > business logic.  I want to know how I can redirect to different
> > pages on
> > > > the
> > > > > > bases of data retrieved.
> > > > > >
> > > > > > e.g. I need to retrieve and display a list of countries for the
user
> > to
> > > > > > select from.  In case of failure to retrieve the information I
would
> > > > like to
> > > > > > take user to a different page to indicate error.
> > > > > >
> > > > > > What would be the best way to accomplish this?  I am using
struts
> > 1.1
> > > > with
> > > > > > Tiles.
> > > > > >
> > > > > > Regards,
> > > > > > Muhammad Momin Rashid
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > > > For additional commands, e-mail: user-help@struts.apache.org
> > > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Form Bean and decions based on Business Logic calls

Posted by Robert Taylor <rt...@mulework.com>.
The information which exists in the query string is just string values.
The correpsonding parameter names can be defined in the form.
When invoked, Struts will populate the form and pass it on to the action
class. The action class extracts the values from the form and passes them
to the business logic. The business logic does its thing and returns some
values to the action class. The action class then uses these values to 
decide where to send the user.

robert

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> Sent: Saturday, July 24, 2004 7:54 AM
> To: user@struts.apache.org
> Subject: Re: Form Bean and decions based on Business Logic calls
> 
> 
> Ok, I guess thats fair enough to keep business logic calls limited to action
> classes only.
> 
> How do you suggest I impliemnt the case where the user is supposed to
> directly land on a URL, and some information from business logic is
> required.
> 
> e.g the case where user clicks on a forgot password email sent to him/her.
> Here the information embeded in the URL needs to be sent to the Business
> Logic for processing.  Based on information returned by the Business Logic
> the user is allowed to proceed to reset password or not.
> 
> Regards,
> Muhammad Momin Rashid
> 
> "Robert Taylor" <rt...@mulework.com> wrote in message
> news:OCEBJBKGJIBAILNJEGCKMEJGICAA.rtaylor@mulework.com...
> > As Jim already mentioned, its best to keep the form beans as simple as
> possible
> > and void of logic.
> >
> > Place calls to business logic or delegates in the action class.
> >
> > robert
> >
> > > -----Original Message-----
> > > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> > > Sent: Thursday, July 22, 2004 12:30 PM
> > > To: user@struts.apache.org
> > > Subject: Re: Form Bean and decions based on Business Logic calls
> > >
> > >
> > > Thank you for your quick response.
> > >
> > > I do have the appropriate action class with the desired forwards defined
> (as
> > > you have also outlined), but the problem is that the form bean itself is
> > > making the business logic calls to get its desired data.  Upon failure
> to
> > > get the desired data, how can I forward to a different page?  Keeping in
> > > mind that the decision to forward to an failure action is to be done
> within
> > > the Form Bean here.
> > >
> > > I am also interested in knowing if this is the correct approach to have
> the
> > > form bean make such calls.  If not, then kindly suggest a better
> > > implementation.
> > >
> > > Regards,
> > > Muhammad Momin Rashid.
> > >
> > > "Robert Taylor" <rt...@mulework.com> wrote in message
> > > news:OCEBJBKGJIBAILNJEGCKAEIOICAA.rtaylor@mulework.com...
> > > > Define success and failure forwards in your struts-config file for the
> > > > specified action.
> > > >
> > > > In the action class (which should delegate to a business object),
> > > > retrieve the data. Upon failure, forward to the "failure" forward,
> > > > else forward to the "success" forward.
> > > >
> > > > You could achieve the same using declarative exceptions.
> > > >
> > > > If the list of countries doesn't vary between users, you
> > > > can do this when your application starts up and place the
> > > > country list in ServletContext. In this fashion, you only
> > > > have a single database hit for getting the countries.
> > > >
> > > > robert
> > > >
> > > > > -----Original Message-----
> > > > > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin
> Rashid
> > > > > Sent: Thursday, July 22, 2004 10:38 AM
> > > > > To: user@struts.apache.org
> > > > > Subject: Form Bean and decions based on Business Logic calls
> > > > >
> > > > >
> > > > > Hello,
> > > > >
> > > > > I have a form bean which needs to retrieve some information from the
> > > > > business logic.  I want to know how I can redirect to different
> pages on
> > > the
> > > > > bases of data retrieved.
> > > > >
> > > > > e.g. I need to retrieve and display a list of countries for the user
> to
> > > > > select from.  In case of failure to retrieve the information I would
> > > like to
> > > > > take user to a different page to indicate error.
> > > > >
> > > > > What would be the best way to accomplish this?  I am using struts
> 1.1
> > > with
> > > > > Tiles.
> > > > >
> > > > > Regards,
> > > > > Muhammad Momin Rashid
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > > For additional commands, e-mail: user-help@struts.apache.org
> > > > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Bean and decions based on Business Logic calls

Posted by Muhammad Momin Rashid <mo...@amaana.com>.
Ok, I guess thats fair enough to keep business logic calls limited to action
classes only.

How do you suggest I impliemnt the case where the user is supposed to
directly land on a URL, and some information from business logic is
required.

e.g the case where user clicks on a forgot password email sent to him/her.
Here the information embeded in the URL needs to be sent to the Business
Logic for processing.  Based on information returned by the Business Logic
the user is allowed to proceed to reset password or not.

Regards,
Muhammad Momin Rashid

"Robert Taylor" <rt...@mulework.com> wrote in message
news:OCEBJBKGJIBAILNJEGCKMEJGICAA.rtaylor@mulework.com...
> As Jim already mentioned, its best to keep the form beans as simple as
possible
> and void of logic.
>
> Place calls to business logic or delegates in the action class.
>
> robert
>
> > -----Original Message-----
> > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> > Sent: Thursday, July 22, 2004 12:30 PM
> > To: user@struts.apache.org
> > Subject: Re: Form Bean and decions based on Business Logic calls
> >
> >
> > Thank you for your quick response.
> >
> > I do have the appropriate action class with the desired forwards defined
(as
> > you have also outlined), but the problem is that the form bean itself is
> > making the business logic calls to get its desired data.  Upon failure
to
> > get the desired data, how can I forward to a different page?  Keeping in
> > mind that the decision to forward to an failure action is to be done
within
> > the Form Bean here.
> >
> > I am also interested in knowing if this is the correct approach to have
the
> > form bean make such calls.  If not, then kindly suggest a better
> > implementation.
> >
> > Regards,
> > Muhammad Momin Rashid.
> >
> > "Robert Taylor" <rt...@mulework.com> wrote in message
> > news:OCEBJBKGJIBAILNJEGCKAEIOICAA.rtaylor@mulework.com...
> > > Define success and failure forwards in your struts-config file for the
> > > specified action.
> > >
> > > In the action class (which should delegate to a business object),
> > > retrieve the data. Upon failure, forward to the "failure" forward,
> > > else forward to the "success" forward.
> > >
> > > You could achieve the same using declarative exceptions.
> > >
> > > If the list of countries doesn't vary between users, you
> > > can do this when your application starts up and place the
> > > country list in ServletContext. In this fashion, you only
> > > have a single database hit for getting the countries.
> > >
> > > robert
> > >
> > > > -----Original Message-----
> > > > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin
Rashid
> > > > Sent: Thursday, July 22, 2004 10:38 AM
> > > > To: user@struts.apache.org
> > > > Subject: Form Bean and decions based on Business Logic calls
> > > >
> > > >
> > > > Hello,
> > > >
> > > > I have a form bean which needs to retrieve some information from the
> > > > business logic.  I want to know how I can redirect to different
pages on
> > the
> > > > bases of data retrieved.
> > > >
> > > > e.g. I need to retrieve and display a list of countries for the user
to
> > > > select from.  In case of failure to retrieve the information I would
> > like to
> > > > take user to a different page to indicate error.
> > > >
> > > > What would be the best way to accomplish this?  I am using struts
1.1
> > with
> > > > Tiles.
> > > >
> > > > Regards,
> > > > Muhammad Momin Rashid
> > > >
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Form Bean and decions based on Business Logic calls

Posted by Robert Taylor <rt...@mulework.com>.
As Jim already mentioned, its best to keep the form beans as simple as possible
and void of logic. 

Place calls to business logic or delegates in the action class.

robert

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> Sent: Thursday, July 22, 2004 12:30 PM
> To: user@struts.apache.org
> Subject: Re: Form Bean and decions based on Business Logic calls
> 
> 
> Thank you for your quick response.
> 
> I do have the appropriate action class with the desired forwards defined (as
> you have also outlined), but the problem is that the form bean itself is
> making the business logic calls to get its desired data.  Upon failure to
> get the desired data, how can I forward to a different page?  Keeping in
> mind that the decision to forward to an failure action is to be done within
> the Form Bean here.
> 
> I am also interested in knowing if this is the correct approach to have the
> form bean make such calls.  If not, then kindly suggest a better
> implementation.
> 
> Regards,
> Muhammad Momin Rashid.
> 
> "Robert Taylor" <rt...@mulework.com> wrote in message
> news:OCEBJBKGJIBAILNJEGCKAEIOICAA.rtaylor@mulework.com...
> > Define success and failure forwards in your struts-config file for the
> > specified action.
> >
> > In the action class (which should delegate to a business object),
> > retrieve the data. Upon failure, forward to the "failure" forward,
> > else forward to the "success" forward.
> >
> > You could achieve the same using declarative exceptions.
> >
> > If the list of countries doesn't vary between users, you
> > can do this when your application starts up and place the
> > country list in ServletContext. In this fashion, you only
> > have a single database hit for getting the countries.
> >
> > robert
> >
> > > -----Original Message-----
> > > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> > > Sent: Thursday, July 22, 2004 10:38 AM
> > > To: user@struts.apache.org
> > > Subject: Form Bean and decions based on Business Logic calls
> > >
> > >
> > > Hello,
> > >
> > > I have a form bean which needs to retrieve some information from the
> > > business logic.  I want to know how I can redirect to different pages on
> the
> > > bases of data retrieved.
> > >
> > > e.g. I need to retrieve and display a list of countries for the user to
> > > select from.  In case of failure to retrieve the information I would
> like to
> > > take user to a different page to indicate error.
> > >
> > > What would be the best way to accomplish this?  I am using struts 1.1
> with
> > > Tiles.
> > >
> > > Regards,
> > > Muhammad Momin Rashid
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Bean and decions based on Business Logic calls

Posted by Muhammad Momin Rashid <mo...@amaana.com>.
Thank you for your quick response.

I do have the appropriate action class with the desired forwards defined (as
you have also outlined), but the problem is that the form bean itself is
making the business logic calls to get its desired data.  Upon failure to
get the desired data, how can I forward to a different page?  Keeping in
mind that the decision to forward to an failure action is to be done within
the Form Bean here.

I am also interested in knowing if this is the correct approach to have the
form bean make such calls.  If not, then kindly suggest a better
implementation.

Regards,
Muhammad Momin Rashid.

"Robert Taylor" <rt...@mulework.com> wrote in message
news:OCEBJBKGJIBAILNJEGCKAEIOICAA.rtaylor@mulework.com...
> Define success and failure forwards in your struts-config file for the
> specified action.
>
> In the action class (which should delegate to a business object),
> retrieve the data. Upon failure, forward to the "failure" forward,
> else forward to the "success" forward.
>
> You could achieve the same using declarative exceptions.
>
> If the list of countries doesn't vary between users, you
> can do this when your application starts up and place the
> country list in ServletContext. In this fashion, you only
> have a single database hit for getting the countries.
>
> robert
>
> > -----Original Message-----
> > From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> > Sent: Thursday, July 22, 2004 10:38 AM
> > To: user@struts.apache.org
> > Subject: Form Bean and decions based on Business Logic calls
> >
> >
> > Hello,
> >
> > I have a form bean which needs to retrieve some information from the
> > business logic.  I want to know how I can redirect to different pages on
the
> > bases of data retrieved.
> >
> > e.g. I need to retrieve and display a list of countries for the user to
> > select from.  In case of failure to retrieve the information I would
like to
> > take user to a different page to indicate error.
> >
> > What would be the best way to accomplish this?  I am using struts 1.1
with
> > Tiles.
> >
> > Regards,
> > Muhammad Momin Rashid
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Form Bean and decions based on Business Logic calls

Posted by Robert Taylor <rt...@mulework.com>.
Define success and failure forwards in your struts-config file for the
specified action.

In the action class (which should delegate to a business object), 
retrieve the data. Upon failure, forward to the "failure" forward,
else forward to the "success" forward.

You could achieve the same using declarative exceptions.

If the list of countries doesn't vary between users, you
can do this when your application starts up and place the
country list in ServletContext. In this fashion, you only
have a single database hit for getting the countries.

robert

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Muhammad Momin Rashid
> Sent: Thursday, July 22, 2004 10:38 AM
> To: user@struts.apache.org
> Subject: Form Bean and decions based on Business Logic calls
> 
> 
> Hello,
> 
> I have a form bean which needs to retrieve some information from the
> business logic.  I want to know how I can redirect to different pages on the
> bases of data retrieved.
> 
> e.g. I need to retrieve and display a list of countries for the user to
> select from.  In case of failure to retrieve the information I would like to
> take user to a different page to indicate error.
> 
> What would be the best way to accomplish this?  I am using struts 1.1 with
> Tiles.
> 
> Regards,
> Muhammad Momin Rashid
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org