Hi all,
I am trying to list some names (with and ID code) and I want for each name listed create a link, then when the user clicks on the link I want to edit the record (the bean).

With this I have my list there with all the names:
   http://localhost:8080/ExemploStruts/ListagemClientes.do

The problem is when I click on the name/link and it should call an action in my DispatchAction, but it gives me an error on the server:

HTTP Status 404 - /CadastroClienteDispatchAction.do
------------------------------------------------------------------------
*type* Status report
*message* _/CadastroClienteDispatchAction.do_
*description* _The requested resource (/CadastroClienteDispatchAction.do) is not available._
------------------------------------------------------------------------
Apache Tomcat/5.5.8


For listing the names I am using an this Action, which is org.apache.struts.action.ActionForm type: <action path="/ListagemClientes" type="br.com.manager.action.ListagemClientesAction">
           <forward path="/pages/dadosCliente.jsp" name="sucesso" />
           <forward path="/pages/erros.jsp" name="falha" />
</action>

For my CRUD operations I am using an action of type org.apache.struts.actions.DispatchAction:
<action input="/pages/cadastroCliente.jsp" name="ClienteForm"
           parameter="acao" path="/CadastroClienteDispatchAction"
scope="session" type="br.com.manager.action.ClienteDispatchAction">
           <forward name="retorno" path="/pages/cadastroCliente.jsp" />
           <forward name="sucesso" path="/pages/dadosCliente.jsp" />
           <forward name="falha" path="/pages/erros.jsp" />
</action>

This is my .JSP where I create the links:
<logic:notEmpty name="listagem">
               <logic:iterate name="listagem" id="lista">
                   <tr>
                       <td bgcolor="#E6E8FA"><a
href="/CadastroClienteDispatchAction.do?acao=editar&codigo=<bean:write name='lista' property='codigo'/>">
                       <bean:write name="lista" property="nome" /></a></td>
                       <td bgcolor="#E6E8FA" width="4%" align="center"><a
href="/CadastroClienteDispatchAction.do?acao=excluir&codigo=<bean:write name='lista' property='codigo'/>">
                       <img src="imagens/lixo.gif" border=0></a></td>
                   </tr>
               </logic:iterate>
</logic:notEmpty>

These are my 2 action in the DispatchAction (excluir=delete, editar=edit) :
public ActionForward excluir(ActionMapping mapping, ActionForm form,
           HttpServletRequest request, HttpServletResponse response)
           throws Exception {

       ActionErrors erros = new ActionErrors();
       ActionForward forward = null;
       ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection());
       ClienteFormBean clienteForm = (ClienteFormBean) form;

       try {
           cadastroDAO.delete(clienteForm);
           forward = mapping.findForward("sucesso");
       } catch (SQLException e) {
erros.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.persistirCadastro", new String[] { e.getMessage() }));
           forward = mapping.findForward("falha");
       } catch (Exception e) {
erros.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.persistirCadastro", new String[] { e.getMessage() }));
           forward = mapping.findForward("falha");
       }

       if (!erros.isEmpty()) {
           saveErrors(request, erros);
       }
       return forward;
   }

public ActionForward editar(ActionMapping mapping, ActionForm form,
           HttpServletRequest request, HttpServletResponse response)
           throws Exception {
       ActionErrors erros = new ActionErrors();
       ClienteDAO cadastroDAO = new ClienteDAO(this.getConnection());
       ClienteFormBean clienteForm = (ClienteFormBean)form;
       try {
clienteForm = cadastroDAO.getDadosCliente( ((ClienteFormBean)form).getCodigo() );
           clienteForm.setAcao("editando");
       } catch (SQLException e) {
erros.add(ActionErrors.GLOBAL_ERROR,new ActionError("errors.recuperarCadastro"));
           mapping.findForward("falha");
} return mapping.findForward("sucesso");
   }

Please, could someone tell me what is wrong OR tell me another way to implement such thing.

I am using Struts 1.1

Thanks a lot

PS. My Bean and my DAO are working ok.

        

        
                
_______________________________________________________ Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e muito mais. Instale agora! www.yahoo.com.br/messenger/

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

Reply via email to