| Author |
problem with LookupDispatchAction
|
meera rao
Ranch Hand
Joined: Jun 30, 2005
Posts: 67
|
|
I am trying to implement LookupDispatchAction in my code. I am trying to display another page when I click a button, but it doesn't forward to the new page. I don't think it even goes into the method. Kindly help. My code is as follows: Struts-config <action name="CountySummaryForm" path="/CountySummary" scope="session" parameter="action" input="/pages/SumByCounty.jsp" type="com.odps.eta.TransReports.action.CountySummaryAction"> <forward name="sumByCounty" path="/pages/SumByCounty.jsp"/> <forward name="query1" path="/pages/tmp.jsp"/> </action> jsp page <html:form action="/CountySummary"> <html:submit property="action"> <bean:message key="button.reports.query1"/> </html:submit> <INPUT TYPE=RESET VALUE="Clear"> </html:form> action class public class CountySummaryAction extends LookupDispatchAction { protected Map getKeyMethodMap() { log.info("In side map"); Map map = new HashMap(); map.put("button.reports.query1", "query1"); return map; } public ActionForward query1(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return mapping.findForward("query1"); } }
|
 |
Mauricio Caceres
Greenhorn
Joined: Jul 21, 2005
Posts: 4
|
|
Que versi�n de Struts estas utilizando?? Tienes seteado un ApplicationResources.properties dentro de tu struts-config.xml?? Do you have setting a ApplicationResources in Struts-config.xml?? Cual es el error en la consola?? What is error message in the console?
|
Attentively,<br />Mauricio C�ceres Herrera
|
 |
meera rao
Ranch Hand
Joined: Jun 30, 2005
Posts: 67
|
|
Yes i have the setting in Application properties file. I don't get an error, but it is supposed to show up a jsp page, it just shows a blank page.
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
CountySummaryForm must have a getAction() and setAction() method and an action attribute. Any time you use the property attrubute for any of the <html:xxx> tags, you must have a corresponding property on the form bean with a getter and setter. [ July 21, 2005: Message edited by: Merrill Higginson ]
|
Merrill
Consultant, Sima Solutions
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Originally posted by Merrill Higginson: CountySummaryForm must have a getAction() and setAction() method and an action attribute. Any time you use the property attrubute for any of the <html:xxx> tags, you must have a corresponding property on the form bean with a getter and setter. [ July 21, 2005: Message edited by: Merrill Higginson ]
That's not true for buttons.
|
A good workman is known by his tools.
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
|
Double-check your class paths in struts-config.xml - ESPECIALLY the one for your ActionForm. Someone around here once got a blank page because of that.
|
 |
Mauricio Caceres
Greenhorn
Joined: Jul 21, 2005
Posts: 4
|
|
File---->AppicationResources_es_CL.properties page.one= PAGE1 page.two= PAGE2 ------------------------------------------ File---->entrada.jsp <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %> <%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:html> <head> <title> entrada </title> </head> <body bgcolor="#ffffff"> <html:form action="/myAction"> <html:submit property="accion"><bean:message key="page.one"/></html:submit> <html:submit property="accion"><bean:message key="page.two"/></html:submit> </html:form> </body> </html:html> -------------------------------------- File------->flow1.jsp <html> <head> <title> flow1 </title> </head> <body bgcolor="#ffffff"> <h1> Flow1 </h1> </body> </html> ----------------------------- File-->flow2.jsp <html> <head> <title> flow2 </title> </head> <body bgcolor="#ffffff"> <h1> Flow2 </h1> </body> </html> ------------------------ File--->struts-config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <form-beans> <form-bean name="myActionForm" type="sample.actionForm.MyActionForm" /> </form-beans> <action-mappings> <action name="myActionForm" parameter="accion" path="/myAction" scope="request" type="sample.actions.MyAction" validate="false"> <forward name="pagina1" path="/flow1.jsp" /> <forward name="pagina2" path="/flow2.jsp" /> </action> </action-mappings> <message-resources parameter="sample.resources.ApplicationResources" /> </struts-config> ---------------------------------------- File-->MyActionForm.java package sample.actionForm; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import javax.servlet.http.HttpServletRequest; public class MyActionForm extends ActionForm { public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { return null; } public void reset(ActionMapping actionMapping, HttpServletRequest servletRequest) { } } -------------------------------- File-->MyAction.java package sample.actions; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForward; import org.apache.struts.actions.LookupDispatchAction; import java.util.Map; import java.util.HashMap; public class MyAction extends LookupDispatchAction { public ActionForward method1(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest servletRequest, HttpServletResponse servletResponse) { System.out.println("method1"); return actionMapping.findForward("pagina1"); } public ActionForward method2(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest servletRequest, HttpServletResponse servletResponse) { System.out.println("method2"); return actionMapping.findForward("pagina2"); } protected Map getKeyMethodMap() { Map map = new HashMap(); map.put("page.one","method1"); map.put("page.two","method2"); return map; } } can you make this code??
|
 |
 |
|
|
subject: problem with LookupDispatchAction
|
|
|