How many types of action clases are there in stuts and
their uses?
Answers were Sorted based on User's Feedback
Answer / surendraeddy.m
1.Forward Action
2.Dispatch Action
3.include Action
4.lookUpDispatch Actioc
5.MappingDispatch Action
6.switch Action
7.LocaleDispatch Action
Is This Answer Correct ? | 82 Yes | 22 No |
Answer / akbar.nk
There are 9 types of Action Classes in struts, but e use
frequently only 5 types:
1.Action class
2.DispatchAction class
3.LookupDispatchAction class
4.MappingDispatchAction class
5.LocaleAction class
6.ForwardAction class
7.IncludeAction class
8.SwitchAction class
9.DownloadAction class
Is This Answer Correct ? | 30 Yes | 5 No |
Answer / amit verma
there r only 5 actions:
1. forward action
2. include action
3. dispatch action
4. lookup dispatch action
5. switch action
Is This Answer Correct ? | 24 Yes | 9 No |
Answer / saranv
THERE ARE FOUR TYPES.
1)
DispatchAction: In this type of aggregation, the action
class must extend DispatchAction class as shown.
public final class CRUDDispatchAction extends
DispatchAction {
public ActionForward create(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
return (mapping.findForward("success"));
}
...
and the action mapping will be as
<action path="/crudDispatchAction"
type="com.companyname.projname.CRUDDispatchAction"
name="formName" scope="request" input=" homeDef"
parameter="methodToCall">
<forward name="success" path="targetDefName"/>
</action>
in your jsp you can call this action as
<html:link action="crudDispatchAction?
methodToCall=create">Create</html:link>
...
Observe that the above class extends DispatchAction and so
you cannot use this method if your class already extends
your (some) super class (eg., the class where the session
is validated/invalidated). Here the user has to send a
query string variable (methodToCall) to set the action name
to call.
2)
ActionDispatcher: This flavor of aggregation is same as
DispatchAction except that we need not extend
ActionDispatcher, so we can use this method even if our
class extends a super class. The following code snippet
shows this scenario.
public final class CRUDActionDispatcher extends Action {
protected ActionDispatcher dispatcher = new ActionDispatcher
(this, ActionDispatcher.DEFAULT_FLAVOR);
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
return dispatcher.execute(mapping, form, request, response);
}
The DEFAULT_FLAVOR field suggests that the default
parameter is "method" if none is specified as parameter in
struts-config.xml (eg,. methodToCall).
ActionDispatcher flavor also needs methodToCall parameter
to be set (using hidden variable or a query string) as in
case of DispatchAction.
3)
LookupDispatchAction: This type of aggregation is useful in
situations where in you have multiple submit buttons in a
single form. The class must extend LookupDispatchAction.
However, the great thing about this type is that its java
script free. That means, you need not set any hidden
variables or pass query string however, you must use submit
buttons as shown.
<html:submit property="submit"><bean:message
key="button.create"/></html: submit >
<html:submit property="submit"><bean:message
key="button.read"/></html: submit >
...
The example Action class will be as follows
public class CRUDLookUpDispatchAction extends
LookupDispatchAction {
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.create", "create");
?
return map;
}
public ActionForward create(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
return (mapping.findForward("success"));
}
Observe the getKeyMethodMap() method. The submit button
names are specified in a Map and their keys comes from
MessageResources file. Struts picks up the name from this
file and redirects it to the value specified in the Map.
The calling code in jsp however has multiple submit buttons
only differing in their names.
4)
MappingDispatchAction: This aggregation extends
MappingDispatchAction class. This is the most useful type
among the four types available. But as seen in other cases,
you can use this type only when your action does not extend
any other action. The good thing about this type is that
the action mappings can differ and so need not be the same
as in all other cases. To illustrate this consider the
below mappings.
<action path="/createMappingAction"
type="com.bodhtree.CRUDMappingDispatchAction"
scope="request" input="homeDef" parameter="create">
<forward name="success" path="targetDef"/>
</action>
<action path="/readMappingAction"
type="com.bodhtree.CRUDMappingDispatchAction" name="
formName" scope="request" input="homeDef" parameter=" read">
<forward name="success" path="targetDef"/>
</action>
Notice that in the first action mapping, there is no form
bean while in the second the bean name is specified. This
means that the user has the flexibility to change the
mapping according to his needs and hence not been contained
to use a constant mapping for all the CRUD actions. Note
that in all the other types of aggregations, we must use
the same mapping for all the CRUD actions.
Is This Answer Correct ? | 20 Yes | 6 No |
Answer / srinivas
1)Forward Action
2)Include Action
3)Dispatch Action
4)Switch Action.........(one more Action is there)
Is This Answer Correct ? | 41 Yes | 28 No |
Answer / sarika singh
there are 7 type of classes--
1.dispatch action class
2.forward action class.
3.include action class.
4.locale action class.
5.lookup dispatch class.
6.mapping dispatch class.
7.switch class.
Is This Answer Correct ? | 16 Yes | 4 No |
Answer / ramakrishna goud.n
Different types of action classes
1).Action Class
2).IncludeAction Class
3).ForwardAction Class
4).DispatchAction Class
5).LookUpDispatchAction Class
6).SwitchAction Class
In this we use the Action Class for implementing the
business logic
We use the IncludeAction,ForwardActions,
Suppose if you want to use your servlet application or jsp
application(which are developed previously and u want to
resue it ) should follow the struts MVC pattern then you
can acheieve that using these classes
We use the DispatchAction when you want have to perform
multiple actions through one form
We can use the switchAction when you want to use the
resources from other modules of your struts application
LookupDispatchAction is similer to DispatchAction.
this information is very useful to the guys who has the
intrest to learn struts
All the best.........
Is This Answer Correct ? | 17 Yes | 8 No |
Answer / ramesh yampalla
There are six Types of Action Classes are there in Struts----
1.ForwardAction Class
2.IncludeAction Class
3.DispatchAction Class
4.LookupDispatchAction Class
5.MappingDispatchAction Class
6.SwitchAction Class
Is This Answer Correct ? | 8 Yes | 4 No |
Answer / nagendrakumar kalagara
There are 8 Action Classes are given in org.apache.struts.actions package and this is given in struts-extras-1.3.8.jar.
1.Dispatch Action
2.LookupDispatch Action
3.MappingDispatch Action
4.Switch Action
5.Forward Action
6.Include Action
7.Download Action
8.Locale Action
this is the correct way of understanding actions.
Is This Answer Correct ? | 5 Yes | 1 No |
How does struts2 token work?
What is the purpose of @doublerangefieldvalidator annotation?
What are the differences between Struts1 and Struts2 or how Struts2 is better than Struts1?
What is the difference between struts and spring? Explain
What helpers in the form of jsp pages are provided in struts framework?
What is difference between perform() used in struts1.0 and execute() used in 1.1 ?
What is struts in j2ee?
can we change the order of parameters in execute()?
What do you mean by struts.dev mode?
advantages& 5 disadvantages of MVC architecture
What is the default location of result pages and how can we change it?
Do we need to pay the struts if being used in commercial purpose?