Erro DynaValidatorActionForm

0 respostas
F

Olá pessoal!

Estava usando um Form bean com ActionForm no struts e DispatchAction, onde funcionava tranquilamente.
Agora passei a utilizar formulário dinâmico: DynaValidatorActionForm, mas está apresentando um erro que não consigo descobrir. Se alguém puder me ajudar eu agradeço. Abraços :lol:

<<< ControleFormCadastro.java >>>

package Empresa;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.DispatchAction;
import org.apache.struts.validator.DynaValidatorActionForm;
import org.apache.struts.validator.DynaValidatorForm;

public class ControleFormCadastro extends DispatchAction {
			
	//mapeia os submits do formulário
	protected Map getKeyMethodMap() {
      		Map map = new HashMap();
      		map.put("button.inserir", "Inserir");
      		map.put("button.alterar", "Alterar");
      		map.put("button.excluir", "Excluir");
      		map.put("button.consultar", "Consultar");
      		return map;
    	}
	
	public Cliente getValues(Cliente cli,ActionForm form){
		DynaValidatorActionForm formulario = (DynaValidatorActionForm) form;		
		cli.setNome((String) formulario.get("nome"));
		cli.setEndereco((String) formulario.get("endereco"));
		cli.setTelefone((String) formulario.get("telefone"));
		cli.setEmail((String) formulario.get("email"));
		return cli;
	}
	
	public ActionForward Inserir(ActionMapping mapping,ActionForm form, 
	HttpServletRequest request, HttpServletResponse response)
			throws Exception {	
			
		Cliente cli = new Cliente();		
		ConCli conCli = new ConCli();
		conCli.setCliente(getValues(cli,form));
		conCli.Inserir();
		return mapping.findForward("ok");
	}
	
	public ActionForward Alterar(ActionMapping mapping,ActionForm form, 
	HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		Cliente cli = new Cliente();		
		ConCli conCli = new ConCli();
		conCli.setCliente(getValues(cli,form));
		conCli.Alterar();
		return mapping.findForward("ok");
	}
	
	public ActionForward Excluir(ActionMapping mapping,ActionForm form, 
	HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		Cliente cli = new Cliente();		
		ConCli conCli = new ConCli();
		conCli.setCliente(getValues(cli,form));
		conCli.Excluir();
		return mapping.findForward("ok");
	}
}

<<< struts-config.xml >>>

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>


<form-bean name="CadastroForm" dynamic="true"
			type="org.apache.struts.validator.DynaValidatorActionForm">
	<form-property name="nome" type="java.lang.String"/>
	<form-property name="endereco" type="java.lang.String"/>
	<form-property name="telefone" type="java.lang.String"/>
	<form-property name="email" type="java.lang.String"/>		
</form-bean>


		
<action-mappings>
	<action path="/inserir" name="CadastroForm" type="Empresa.ControleFormCadastro" 
			parameter="method" >
	<!-- formward que chamamos na nossa action Login -->
	<forward name="erro" path="/erro.jsp" />	
	<forward name="ok" path="/index.jsp" />			
	</action>
</action-mappings>
	
	<!--arquivo de mensagens -->
	<message-resources parameter="MessageResources" />
		
</struts-config>

<<< validator.xml >>>

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

<form-validation>

   
 <form name="CadastroForm">
     <field
         property="nome"
         depends="required">
         <arg key="CadastroForm.nome"/>
     </field>
     
     <field
         property="enedereco"
         depends="required">
         <arg key="CadastroForm.enederco"/>
     </field>
     
     <field
         property="telefone"
         depends="required">
         <arg key="CadastroForm.telefone"/>
     </field>
     
     <field
         property="email"
         depends="required">
         <arg key="CadastroForm.email"/>
     </field>
</form> 


</form-validation>

<<< index.jsp >>>

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

<<< erro apresentado >>>

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: Cannot retrieve definition for form bean CadastroForm on action /inserir
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

javax.servlet.ServletException: Cannot retrieve definition for form bean CadastroForm on action /inserir
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
	org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:88)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

javax.servlet.jsp.JspException: Cannot retrieve definition for form bean CadastroForm on action /inserir
	org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:767)
	org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:443)
	org.apache.jsp.index_jsp._jspx_meth_html_form_0(org.apache.jsp.index_jsp:164)
	org.apache.jsp.index_jsp._jspx_meth_html_html_0(org.apache.jsp.index_jsp:133)
	org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:79)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.15
Criado 31 de março de 2006
Respostas 0
Participantes 1