struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <>
Subject RE: How does LookupDispatchAction lookup.
Date Fri, 20 Dec 2002 15:36:03 GMT
> I want to use LookupDispatchAction.
> Reading one of Ted's tips, it seems that the value returned by my
> submit buttons MUST be stored in a .properties file, and looked up
> inside my JSP:
> <html:submit property="submit">
>  <bean:message key="button.add"/>
> </html:submit>
> There's no way to have a hard-coded value? or a value
> coming from somewhere else?
> Then how do I code the getKeyMethodMap?
> I would have liked to return such a map:
>  "Add Item" => "add"
> "Delete Item" => "delete"
> Is it possible?

I don't know if you can get around the .properties file; it's an integral
part of using Struts.  As to how to do the getKeyMethodMap method, here's

 protected Map getKeyMethodMap()
      Map map = new HashMap();
      map.put( "button.add.prospect", "addProspect" );
      map.put( "button.delete.prospect", "deleteProspect" );
      // ... more map.put's deleted to save space
      return map;

button.add.prospect is in the .properties file, and addProspect is the name
of the method to call.

If there's any chance of this action being called *without* the parameter
you've specified, you might want to override the execute method and provide
a default behavior:

 public ActionForward execute( ... ) {
      if ( request.getParameter( mapping.getParameter() ) == null ) {
            return ( mapping.findForward( "failure" ) );
      } else {
         //parameter is present, let LookupDispatchAction do its thing:
         return super.execute( mapping, form, request, response );

Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message