Ques: 20 How will you configure the Plugin in your web
application.
Ans: To deploy and configure
your Plugin class, you must:
* Compile and move the
Plugin class file into your application's WEB-INF/classes/ directory.
* Add a <plug-in>
element to your struts-config.xml file. For example:
<plug-in
className="MyPlugin"/>
The <plug-in>
element should be the last element in the struts-config.xml file.
* Restart the Web
application.
Ques: 21 What are the advanced Action classes? Why do you need
ForwardAction class?
Ans: Advanced Action classes
are the built-in Action classes that come with the Struts. These are:
* ForwardAction
* IncludeAction
* DispatchAction
* LookupDispatchAction
* SwitchAction
ForwardAction: The ForwardAction acts as a bridge from the current
view (JSP) and the pages it links to. It uses the RequestDispatcher to forward
to a specified web resource. It is the glue that allows you to link to
an action instead of directly to a JSP. It follow the two steps:
* Use the
<html:link> tag with the action attribute, add a link
to a JSP page that points to the action.
* Create an action mapping
in the Struts configuration file that uses ForwardAction with the
parameter attribute to specify the JSP path.
Ques: 22 Which is better approach, forward attribute or
ForwardAction in the Struts framework to forward the request to next
view.?
Ans:The Struts configuration
file includes support for both the forward attribute and ForwardAction.
The ForwardAction:
<action
path="/home" type="org.apache.struts.action.ForwardAction"
parameter="/index.jsp">
The forward attribute:
<action
path="/home" forward="/index.jsp">
These two mappings are funtionally equivalent. It is an
easy decision to pick the one you should use, of course, the shorter one.
Ques: 23 What is the difference between the ForwardAction
and the IncludeAction in the Struts?
Ans: The main difference
between the ForwardAction and the IncludeAction is that you need to use
IncludeAction only if the action is going to be included by another action or
JSP.
Therefore, if you have code in your JSP that looks like this:
<jsp:include
page="/someWebApp/someModule/someAction.do"/>
the action could not use a ForwardAction because it would forward
control to the new action rather than including its output within the output of
the JSP, or throw a IlligalStateException if the output buffer is already
committed.
Ques: 24 Which class would you use to forward the group related
actions and what are steps involved.
Ans: The DispatchAction class
is used to forward the group related actions into one class. DispatchAction is
an abstract class, so you must override it to use it. It extends the Action
class.
Rather than having a single execute method, you have a method for
each logical action. The DispatchAction dispatches to one of the logical
actions represented by the method. It picks a method to invoke based on an
incoming request parameter. You should follow the following steps:
* Create an action handler
class that subclasses DispatchAction.
* Create a method to
represent each logical related action.
* Create an action mapping
for this action handler using the parameter attribute to specify the request
parameter that carries the name of the method you want ot invoke.
* Pass the action a
request parameter that refers to the method you want to invoke.
Ques: 25 What are the two input tags of the <html:form/>
tags?
Ans: The <html:form/>
tag serves as the container for all other Struts HTML input tags. It acts as a
parent to two other HTML tags:
The <html:text/> tag:
This tag is equivalent to the HTML text input tag, with the only
difference being the property attribute, which names a unique data member found
in the ActionForm bean class named by the form's type attribute.
<html:text property="" />
The <html:submit/> tag:
This tag simply emulates an HTML Submit button by submitting the
request to the targeted action.
Ques: 26 What are the ActionForm Bean objects in Struts?
Ans: The
org.apache.struts.action.ActionForm objects are JavaBeans that are used to
encapsulate and validate the request data submitted by an HTTP request. All of
the ActionForm must extends the org.apache.struts.action.ActionForm.
It contains setters and getters methods. The setters method are
called by The Struts framework when a request is submitted with a parameter
matching a data member's name.
Ques: 27 What is the alternatice approach to the ActionForm in
Struts?
Ans: You have to develop a
new ActionForm object for just about every piece of business logic, i.e. for
every Action object. This process is time consuming and irritating.
Struts solve this problem by introducing of a dynamic ActionForm,
called the DynaActionForm. It gives the developer the ability to define a Form
object using an XML entry in the struts-config.xml file.
0 comments:
Post a Comment