First, I would like to apologize that this mail is not about JDBC, some
people may be very furious that we are talking about JSP stuffs on this
mailing list! ;-)
In the case explain earlier where the action is calling an EJB, the action
is used as a glue between your middle tier and your JSP. The EJB is then in
charge to go pursue the action requested in the EIS. Your problem as I
understand it is that your are trying to understand how to get to the
action.
First, there is the invocation method. Most of the people because they are
working in the MVC environement are saying that Action are instance of
ActionListener, which give the actionPerformed method witht an ActionEvent
as a parameter. The way you invoke this action is by creating manually an
event (don't forget to put the logical name of your action in it) and to
call the actionPerformed method directly. Of course to get the instance,
several strategies could apply depending if you are in a multithreaded
environement, if your action is stateless or statefull, ...
The other parameter that you want to provide (as the source of your event)
is the HttpRequest associated with servlet/JSP request.
The other question that may wander is how to translate a logic name for your
action into a classname. This in fact could be done in a very simple way
using the actionDispatcher mechanism. Basically, you could implement an
action whose only purpose is to take the action name out of the event and do
a lookup in a property file and to instantiate the classname retrieved and
then invoke itself the actionPerformed method giving the event orginally
passed. The lookup method could be of course much more elaborate.
Note that having this property file make your servlet/jsp very generic and
adding new actions requires only editing a property fileinstead of a full
engineering roundtrip.
Hope this help!
Frederik Delacourt
----------------------
Windchill R&D - PTC
----------------------
"The only good bug is adead bug!" - Starship Troopers
----------------------
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Manisha Menon
Sent: Tuesday, June 20, 2000 3:42 PM
To: [EMAIL PROTECTED]
Subject: Re: Translation of action.
Thank you craig.
I am definitely looking at the struts framework today.
But can you please enlighten me about the action
dispatcher in the framework.
I sincerely thank you for showing some direction.
Manisha.
--- "Craig R. McClanahan"
<[EMAIL PROTECTED]> wrote:
> Manisha Menon wrote:
>
> > Hi Craig,
> >
> > Exactly ! We have done in the same way.
> >
> > 1. Getting the action name from the hidden field.
> > String action_name =
> > request.getParameter("ACTION_NAME");
> >
> > Then instantiating the business object in either
> of
> > the following ways.
> >
> > a) BusinessInterface businessObject =
> (BusinessObject)
> > action_name;
> >
> > b) BusinessInterface businessObject =
> >
>
BusinessObjectfactory.createBusinessObject(action_name);
> >
> > But I would like to know from you, whether this
> > approach is not running short of anything ?
> >
> > I have seen few of the approaches made use of
> event
> > delagation methodology. Can someone explain that
> > methodology in web context and also a possible
> > comparison between the two ? I am sorry if I am
> trying
> > to bring something unusual here.
> >
> > Thank you foryour replies,
> >
> > Manisha
> >
>
> This doesn't directly address your questions, but
> you might want to take a look at
> the Struts framework at
> <http://jakarta.apache.org/struts>, which provides a
> fleshed out framework for the MVC controller servlet
> and action dispatcher, plus
> some nice support for dealing with forms and
> internationalized applications through
> a JSP custom tag library.
>
> For simple applications, I implement my business
> logic in the action class that
> gets invoked by the controller servlet. For more
> complex needs, I think of the
> action class as following the "adapter" design
> pattern, translating the HTTP
> request parameters into appropriate property setter
> calls on business logic beans
> (either EJBs or regular JavaBeans). The business
> logic beans, then, are insulated
> from the fact that they were invoked in a web
> application, so you can reuse them
> elsewhere.
>
> Craig McClanahan
>
>
> >
> > --- "Craig R. McClanahan"
> > <[EMAIL PROTECTED]> wrote:
> > > Manisha Menon wrote:
> > >
> > > > Hi all,
> > > >
> > > > I know the question is very silly, but I am
> sorry
> > > I
> > > > could not avoid asking your help.
> > > >
> > > > I follow the MVC design methodology in my web
> > > > framework which has got servlets, jsp and
> beans.
> > > >
> > > > JSP page forwards the request to the
> controller
> > > > servlet requesting for a certain action.
> > > > The servlet controller after receiving the
> request
> > > > object,instantiates the appropriate
> > > > business bean, which will use connection pool
> > > manager
> > > > and data access beans for manipulating
> > > > the data. After completing the data handling
> > > > operations, the servlet
> > > > controller returns the manipulated data back
> to a
> > > new
> > > > JSP page.
> > > >
> > > > Now my question :
> > > >
> > > > How is the conversion/ translation of the
> action
> > > (say
> > > > for example updation, insertion or deletion)
> which
> > > is
> > > > coming from the client JSP page done by the
> > > controller
> > > > servlet taken to the
> > > > right instance of business bean ? A single
> page
> > > may
> > > > have more than one action. Now, how do the
> > > controller
> > > > servlet calls the UpdateBusinessBean for
> update
> > > action
> > > > and InsertBusinessBean for insert action ? The
> > > method
> > > > that will be used by the client to invoke the
> > > servlet
> > > > is "POST". Can I ask you, what are the
> possible
> > > ways
> > > > of doing this, (Already I have adopted one
> method
> > > in
> > > > my last assignment, but I am not too happy
> about
> > > it,
> > > > as it did not consider scalabilty issues and
> also
> > > it
> > > > was tightly coupled.)
> > > >
> > > > Manisha
> > > >
> > >
> > > In a "database maintenance" application like
> what
> > > you describe, it is common to
> > > have a single action class that is called upon
> to
> > > perform slightly different
> > > actions (such as an INSERT for a new row, or an
> > > UPDATE for a second).
> > >
> > > What I often do in such situations is include a
> > > hidden field in the input form that
> > > says one of the following things:
> > >
> > > <input type="hidden" name="action"
> > > value="Create">
> > > <input type="hidden" name="action"
> > > value="Delete">
> > > <input type="hidden" name="action"
> value="Edit">
> > >
> > > depending on which action the user originally
> asked
> > > for. That way, the action
> > > class knows what to do, based on calling:
> > >
> > > request.getParameter("action")
> > >
> > > to see what was included in the form.
> > >
> > > For cases where the user doesn't select which
> action
> > > to perform until the form is
> > > submitted, this field could be set in a
> JavaScript
> > > function, or be chosen by which
> > > submit button was pressed.
> > >
> > > Craig McClanahan
> > >
> > >
> >
>
===========================================================================
> > > To unsubscribe: mailto [EMAIL PROTECTED]
> with
> > > body: "signoff JSP-INTEREST".
> > > Some relevant FAQs on JSP/Servlets can be found
> at:
> > >
> > > http://java.sun.com/products/jsp/faq.html
> > > http://www.esperanto.org.nz/jsp/jspfaq.html
> > >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >
> >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Send instant messages with Yahoo! Messenger.
> > http://im.yahoo.com/
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with
> body:
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets