Hi all,

I can't get started with the example about using LookupDispatchAction of Ted 
Husted, Tip #3 (http://husted.com/struts/tips/index.html).
What is my error or can I get some working code ?

This is the problem:
++++++++++++++++
The forward
 
 <html:link forward="testit" styleClass="menuitem">test it</html:link>
 
gets

ERROR DispatchAction:220 - Request[/test] does not contain handler parameter 
named 'method'.  This may be caused by whitespace in the label text.

Altering the global forward 'testit' to

<forward name="testit" path="/test.do?method=button.add"/>

gets

javax.servlet.ServletException: Action[/test] missing resource 'button.add' in 
key method map
        
org.apache.struts.actions.LookupDispatchAction.getLookupMapName(LookupDispatchAction.java:240)
        
org.apache.struts.actions.LookupDispatchAction.getMethodName(LookupDispatchAction.java:281)
        
org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:158)
        
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
        
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
        org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
        org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

+++++++++++++++++

This is the code

+++Action

public final class MyAction extends LookupDispatchAction {
    
private static Log log = LogFactory.getLog(MyAction.class);

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

    public ActionForward add(ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
      throws IOException, ServletException {
      // do add
      log.info("--- in add()");
      return mapping.findForward("success");
    }

    public ActionForward delete(ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
        throws IOException, ServletException {
      // do delete
        log.info("--- in delete()");    
      return mapping.findForward("success");
    }

}

+++Form:

public final class MyForm extends ActionForm {
       
        private String prop;

        public String getProp() {
                return prop;
        }

        public void setProp(String prop) {
                this.prop = prop;
        }
    
}

+++JSP: /tiles/test.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ include file="taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test LookupDispatchAction...</title>
</head>
<body>

<html:form action="/test">
        <html:submit property="method">
                <bean:message key="button.add"/>
        </html:submit>
        <html:submit property="method">
                <bean:message key="button.delete"/>
        </html:submit>
</html:form>


</body>
</html>



+++application.properties:

button.add=add it all
button.delete=delete it all

+++struts-config

    <global-forwards>
        <forward name="welcome" path="/Welcome.do"/>
        <forward name="testit" path="/test.do"/>
    </global-forwards>

    <form-bean 
        name="MyForm" 
        type="lau.layers.actions.forms.MyForm"/>

<action-mappings>
 <action path="/test"
        type="lau.layers.actions.MyAction"
        name="MyForm"
        scope="request"
        input="/tiles/test.jsp"
        parameter="method">
        <forward name="success" path="/Welcome.do"></forward>
 </action>
 </action-mappings>
 
++++++++++++++++++

Thanks, Volker.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to