Foros del Web » Programación para mayores de 30 ;) » Java »

Struts LookupDispatchAction y html:cancel

Estas en el tema de Struts LookupDispatchAction y html:cancel en el foro de Java en Foros del Web. Hola, en mi formulario tengo 2 botones submit. Para controlar qué Action se ejecuta uso LookupDispatchAction. Esto me funciona bien pero ahora quería añadir un ...
  #1 (permalink)  
Antiguo 06/03/2006, 09:46
 
Fecha de Ingreso: junio-2004
Mensajes: 43
Antigüedad: 19 años, 11 meses
Puntos: 0
Struts LookupDispatchAction y html:cancel

Hola, en mi formulario tengo 2 botones submit. Para controlar qué Action se ejecuta uso LookupDispatchAction. Esto me funciona bien pero ahora quería añadir un botón de cancelar.

Si pongo los 3 botones:
<html:submit property="action"><bean:message key="boton.insertarfavoritos"/></html:submit>

<html:submit property="action"><bean:message key="boton.otroejercicio"/></html:submit>

<html:cancel><bean:message key="boton.cancel"/></html:cancel>

me arroja el siguiente error:
Request[/altaejercicioSubmit] does not contain handler parameter named 'action'. This may be caused by whitespace in the label text.

He intentado transformar el botón cancel en un botón submit que ejecute una nueva Action de redirijir a la página principal pero como previamente tiene que validar el formulario, pues me saltan todas las validaciones.

También he probado a poner: <html:cancel property="action"><bean:message key="boton.cancel"/></html:cancel>

pero sigo en las mismas ya que si creo un Action para controlar esto, previamente ha tenido que validar el formulario y me saltan las validaciones.

Viendo la documentación de Struts veo lo siguiente:
WARNING - If you set this attribute to a value other than the default, this will NOT be recognized as the cancel key by the Struts controller servlet or the Action.isCancelled() method. You will need to do your own cancel detection.

No entiendo lo que hay que hacer ya que en los formularios normales con 1 botón submit y otro cancel, en el Action correspondiente pongo:

if (isCancelled(request)){
return(mapping.findForward("mainmenu"));
}


Es decir, ¿cómo hago para ejecutar y manejar un botón de cancelar usando LookupDispatchAction?

Cualquier ayuda será agradecida.
  #2 (permalink)  
Antiguo 09/10/2006, 04:58
 
Fecha de Ingreso: octubre-2006
Mensajes: 2
Antigüedad: 17 años, 6 meses
Puntos: 0
isCancelled con LookupDispatchAction

Hola,

yo he tenido el mismo problema y he encontrado los siguiente:

Notes - If duplicate values exist for the keys returned by getKeys, only the first one found will be returned. If no corresponding key is found then an exception will be thrown. You can override the method unspecified to provide a custom handler. If the submit was cancelled (a html:cancel button was pressed), the custom handler cancelled will be used instead.

Has de sobreescribir el método unspecified, será el método que se llame cuando hagas un submit del html:cancell.

Zeta
  #3 (permalink)  
Antiguo 13/07/2007, 12:03
 
Fecha de Ingreso: julio-2007
Mensajes: 2
Antigüedad: 16 años, 9 meses
Puntos: 0
Re: Struts LookupDispatchAction y html:cancel

Yo realice lo siguiente y me funciono prefectamente en la funcion validate realizo lo siguiente al inicio de la funcion:


if(action.equalIgnoreCase("cancel"))
{
return error;
}

***
codigo de validacion

***


de esta forma estas evitando las validaciones...
  #4 (permalink)  
Antiguo 13/07/2007, 12:04
 
Fecha de Ingreso: julio-2007
Mensajes: 2
Antigüedad: 16 años, 9 meses
Puntos: 0
Re: Struts LookupDispatchAction y html:cancel

perdon es equalsIgnoreCase() :)

tengan buen dia
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:08.