|Home |Login |Registration |Struts Step by Step Tutorial |Hibernate Step by Step Tutorial |Spring Step by Step Tutorial |JSP Step by Step Tutorial |JDBC Step by Step Tutorial |Web Services Step by Step Tutorial |EJB fundamentals | ORACLE Step by Step Tutorial | SCJP 5.0 and SCJP 6.0 Study Guide | SCWCD 5.0 Study Guide | SCJP Tips
Java mock test | SCJP mock test | SCJP DUMP | SCBCD mock test |Java online test exam | JSP online test | ORACLE online test | Hibernate online test | Servlet online test | Struts online test | EJB online test | C online test | C++ online test | Aptitude online test

Java interview questions | JSP interview questions | ORACLE interview questions | Hibernate interview questions | Servlet interview questions | Struts interview questions | JDBC interview questions | C/C++ interview questions | Spring interview questions | JMS interview questions | Informatica interview questions | EJB interview questions | OOPS and Design Pattern interview questions
1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc) JobsJobs and Walkins

 

Recent Questions

!!! Struts Frequently Asked Questions !!!

What is difference between LookupDispatchAction and DispatchAction?

SCJP 1.5/1.6 Exam Kit

!!!Answer!!!- From Technical Expert

The difference between LookupDispatchAction and DispatchAction is that the actual method that gets called in LookupDispatchAction is based on a lookup of a key value instead of specifying the method name directly.

Details :

LookupDispatchAction is subclass of DispatchAction.
In case of DispatchAction, you have to declare the method name in the JSP page.
For Example :
http://localhost:8080/emp/empaction.do?step=add // IN CASE OF DispatchAction
here step=add , we are delaring method name in JSP.
or
<html:submit property="step">Add</html:submit> //IN CASE OF DispatchAction
so we can't use localization for button.


To over come both the issues below
a)method name declaration in JSP
b)can't use localization for button
We will go for LookupDispatchAction.

In the LookupDispatchAction :
For example :
If there are three operation like add, delete, update employee.
You can create three different Actions ?
AddEmpAction, DeleteEmpAction and UpdateEmpAction.
This is a valid approach, although not elegant since there might be duplication of code across
the Actions since they are related. LookupDispatchAction is the answer to this
problem. With LookupDispatchAction, you can combine all three Actions into one.

Example :
Step 1.
three buttons might be
<html:submit property="step">
<bean:message key="button.add"/>
</html:submit>
<html:submit property="step">
<bean:message key="button.delete"/>
</html:submit>
<html:submit property="step">
<bean:message key="button.update"/>
</html:submit>

//No need method name declaration in JSP . Button name from resource bundle.

Step 2.
In the the Resource Bundle. //Here you can add localization.
button.add=Add
button.delete=Delete
button.update=Update

Step 3.
Implement a method named getKeyMethodMap() in the subclass of the
LookupDispatchAction. The method returns a java.util.Map. The
keys used in the Map should be also used as keys in Message Resource
Bundle.

public class EmpAction extends LookupDispatchAction {

public Map getKeyMethodMap()
{
Map map = new HashMap();
map.put("button.add", "add");
map.put("button.delete", "delete");
map.put("button.update", "update");
}


public ActionForward add(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception
{
//your logic
mapping.findForward("add-success");
}

public ActionForward delete(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception
{
//your logic
mapping.findForward("delete-success");
}

public ActionForward update(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception
{
//your logic
mapping.findForward("update-success");
}

}

in struts-config.xml

<action path="/empaction"
input="/empform.jsp"
type="list.EmpAction"
parameter="step"
scope="request"
validate="false">
<forward name="add-success"
path="addEmpSuccess.jsp"
redirect="true"/>
<forward name="delete-success"
path="deleteEmpSuccess.jsp"
redirect="true"/>
<forward name="update-success"
path="updateEmpSuccess.jsp"
redirect="true"/>
</action>

for every form submission, LookupDispatchAction does the
reverse lookup on the resource bundle to get the key and then gets the method
whose name is associated with the key from
getKeyMethodmap().


Flow of LookupDispatchAction:
a) Form the button name "Add" get the key "button.add" fro resource bundle.
b) then in the Map getKeyMethodMap() find the value associated with the key "button.add".
c) value from the Map is "add" . then call add() method of the same action class.


more details :
http://www.techforum360.com/forum/viewthread?thread=135

Answered By : null Replied Date : Jan 8 2012
Answer :


Answered By : null Replied Date : Jan 6 2012
Answer :


Answered By : null Replied Date : Oct 26 2011
Answer :


Answered By : null Replied Date : Oct 13 2011
Answer :


Answered By : null Replied Date : Oct 11 2011
Answer :


Answered By : null Replied Date : Aug 12 2011
Answer :


Answered By : null Replied Date : Jun 18 2011
Answer :


Answered By : null Replied Date : Jun 17 2011
Answer :


Answered By : null Replied Date : May 29 2011
Answer :


Answered By : null Replied Date : May 11 2011
Answer :


Answered By : null Replied Date : Apr 11 2011
Answer :


Answered By : null Replied Date : Apr 11 2011
Answer :


Answered By : null Replied Date : Apr 11 2011
Answer :


Answered By : null Replied Date : Apr 6 2011
Answer :


Answered By : null Replied Date : Apr 1 2011
Answer :


Answered By : null Replied Date : Mar 23 2011
Answer :


Answered By : null Replied Date : Mar 19 2011
Answer :


Answered By : null Replied Date : Mar 19 2011
Answer :


Answered By : null Replied Date : Mar 17 2011
Answer :


Answered By : null Replied Date : Mar 2 2011
Answer :


Answered By : null Replied Date : Mar 1 2011
Answer :


Answered By : null Replied Date : Mar 1 2011
Answer :


Answered By : null Replied Date : Feb 9 2011
Answer :


Answered By : null Replied Date : Jan 19 2011
Answer :


Answered By : null Replied Date : Jan 15 2011
Answer :


Answered By : null Replied Date : Jan 12 2011
Answer :


Answered By : null Replied Date : Dec 30 2010
Answer :


Answered By : null Replied Date : Dec 25 2010
Answer :


Answered By : null Replied Date : Dec 12 2010
Answer :


Answered By : null Replied Date : Nov 23 2010
Answer :


Answered By : null Replied Date : Nov 23 2010
Answer :


Answered By : null Replied Date : Oct 4 2010
Answer :


Answered By : null Replied Date : Oct 1 2010
Answer :


Answered By : null Replied Date : Sep 29 2010
Answer :


Answered By : null Replied Date : Sep 13 2010
Answer :


Answered By : null Replied Date : Sep 9 2010
Answer :


Answered By : null Replied Date : Sep 6 2010
Answer :


Answered By : null Replied Date : Sep 2 2010
Answer :


Answered By : null Replied Date : Sep 1 2010
Answer :


Answered By : null Replied Date : Aug 21 2010
Answer :


Answered By : null Replied Date : Jul 22 2012
Answer :


Answered By : null Replied Date : Jul 29 2012
Answer :


Answered By : null Replied Date : Jul 29 2012
Answer :


Answered By : null Replied Date : Jul 29 2012
Answer :


Answered By : null Replied Date : Jul 30 2012
Answer :


Answered By : null Replied Date : Jul 31 2012
Answer :


Answered By : null Replied Date : Oct 10 2012
Answer :


Answered By : null Replied Date : Nov 4 2012
Answer :


Answered By : null Replied Date : Nov 6 2012
Answer :


Answered By : null Replied Date : Nov 10 2012
Answer :


Answered By : null Replied Date : Nov 17 2012
Answer :


Answered By : null Replied Date : Jan 19 2013
Answer :


Answered By : null Replied Date : Mar 4 2013
Answer :


Answered By : null Replied Date : Mar 5 2013
Answer :


Answered By : null Replied Date : Mar 10 2013
Answer :


Answered By : null Replied Date : Mar 22 2013
Answer :


Answered By : null Replied Date : Apr 15 2013
Answer :


Answered By : null Replied Date : Jun 2 2013
Answer :


Answered By : null Replied Date : Jun 6 2013
Answer :


 

You can also contribute to this answer:

Your Name:
Answer:

 
Ask Question and get answer from Expert.
View Answers List from Expert.

The information you are posting should be related to java and ORACLE technology. Not political.