• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with LookupDispatchAction

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
}
}
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic