struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <Wendy.Sm...@asu.edu>
Subject RE: Problem with LookupDispatchAction and pressing ENTER in a tex t
Date Thu, 21 Nov 2002 20:20:39 GMT
JuanPedro wrote:
> Pressing  'Enter' inside a text form, the form is submited, 
> and the 'method' parameter  that is the name of all my submit buttons,
> takes no value,  and  so the LookupDispatchAction fails
> Any solution?

My solution is below... override the 'execute' method and check to see if
the action parameter is present.  You can then provide a default, fail
gracefully, or call super.execute.

What about having another attribute on the <action> tag that would provide
this function?  Perhaps 'default' to be used in conjunction with 'parameter'
for LookupDispatchAction?

public final class EditContactAction extends LookupDispatchAction
{
   public ActionForward execute( ActionMapping mapping,
         ActionForm form,
         HttpServletRequest request,
         HttpServletResponse response )
          throws Exception
   {
      System.out.println( "EditContactAction.execute..." );
      if ( request.getParameter( mapping.getParameter() ) == null ) {

         if ( request.getParameter( "contactKey" ) != null ) {
            //'action' parameter missing, but we do have a key, default to
edit:
            return editContact( mapping, form, request, response );
         } else {
            //no 'action' parameter, no key, can't do anything:
            return ( mapping.findForward( "failure" ) );
         }
      } else {
         //parameter is present, let LookupDispatchAction do its thing:
         return super.execute( mapping, form, request, response );
      }
   }

HTH,

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

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