Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2007, 02:24 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DispatchAction - errors






When I try to submit data on a jsp with post method to a method in an action class should be called. But it gives an error like this..

 ERROR [DispatchAction] Action[/pages/jsp/smsserver/submitData] does not contain method named updateData
java.lang.NoSuchMethodException: com.orgtech.orgtice.smsservice.struts.action.SendR eportAction.updateData(org.apache.struts.action.Ac tionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

Here I add the necessary parts of jsp, struts config.xml, ActionForm class and Action class.



this is the showDetails.jsp..It shows the details to the user and also uer have the ability to edit it and submit again. So I want to get the changed details and updat ethem again to the database.


  <head>
    <html:base />

    <title>showDetails.jsp</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
  </head>

  <body>
   <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Message Details</p>

<table width="75%" border="0" id="showdatatable">


<logic:iterate name="showDetailsForm" property="allProducts" id="SingleItem">
<form method="post" action="submitData.do?next=updateData">
  <tr>
    <td>Id</td>
      <td width="3%"><bean:write name="SingleItem" property="id"/></td>
  </tr>


  <tr>
    <td>Modified Time</td>
    <td><bean:write name="SingleItem" property="modifiedTime"/></td>
  </tr>

  <tr>
    <td>Module</td>
    <td>
        <select name="smodule">
        <%
        if(request.getAttribute("moduleType").equals("GEN" )){
        %>
          <option>TEST</option>
          <option selected>GEN</option>
          <%
         }
          %>
        </select>
      </td>
  </tr>

  <tr>
    <td>Repeats</td>
    <td>
         <input type="text" name="srepeats" value="<bean:write name="SingleItem" property="repeats"/>" >
      </td>
  </tr>

  <tr>
    <td>Mobile No</td>
    <td>
        <input type="text" name="smobileNo" value="<bean:write name="SingleItem" property="mobileNo"/>">
     </td>
  </tr>
  <tr>
    <td>Message</td>
    <td>
        <textarea name="smessage"><bean:write name="SingleItem" property="message"/></textarea>
     </td>
  </tr>
  <tr>
    <td>Status</td>
    <td> <select name="sstatus">
        <%
         if(request.getAttribute("statusType").toString().e quals("Failed")){
        %>

        <option value="1">Success</option>
          <option value="2" selected>Failed</option>
          <option value="3">Pending</option>
          <option value="4">Queued</option>

           <%}
          else
           if(request.getAttribute("statusType").toString().e quals("Success")){
            %>
          <option value="1" selected>Success</option>
          <option value="2">Failed</option>
          <option value="3">Pending</option>
          <option value="4">Queued</option>

          <%
          }else
           if(request.getAttribute("statusType").toString().e quals("Pending")){
          %>
          <option value="1">Success</option>
          <option value="2">Failed</option>
          <option value="3" selected>Pending</option>
          <option value="4">Queued</option>

          <%
          }else
          if(request.getAttribute("statusType").toString().e quals("Queued")){
          %>
          <option value="1">Success</option>
          <option value="2">Failed</option>
          <option value="3">Pending</option>
          <option value="4" selected>Queued</option>
          <%
          }else{
          %>
          <OPTION><%=request.getAttribute("statusType").toSt ring()%></OPTION>
          <%
          }
          %>
        </select>
      </td>
  </tr>

  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>

  <tr>
    <td height="54">&nbsp;</td>
    <td><table width="92%" border="0">
  <tr>
    <td width="41%" height="27">
              <input name="Reset" type="reset" value="Cancel">
            </td>
    <td width="59%">
              <input type="submit" name="Submit2" value="Submit">
            </td>
  </tr>
  </logic:iterate>
</table>
&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp; </p>
  </body>
-----------------------------------------------------------
In side config.xml how I mapped the post action with the method..


<action
    name="showDetailsForm"
     path="/pages/jsp/smsserver/submitData"
     attribute="showDetailsForm"
     scope="request"
     type="com.orgtech.orgtice.smsservice.struts.action .SendReportAction"
     parameter="next"
     >
     <forward

     name="updateSuccess"
     path="system.configuration.updateSuccess"

     />
     </action>

---------------------------------------------------------
This is the ActionForm associate with the ActionClass and .jsp.It is needed when requesting the data to the jsp.And I used it inside the updateData method to update data in the database.But I didnt show that part here. I just need to call updateData method when I click submit button..



package com.orgtech.orgtice.smsservice.struts.form;

import java.util.List;
import java.util.Collection;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.irononetech.ironvoice.smsservice.view.SendSMSV iew;

/**
 * MyEclipse Struts
 * Creation date: 01-18-2007
 *
 * XDoclet definition:
 * @struts.form name="showDetailsForm"
 */
public class ShowDetailsForm extends ActionForm {

    // --------------------------------------------------------- Instance Variables

     private Collection allProducts = null;
     private SendSMSView sendSMSView = new SendSMSView();
// private String status;

    // --------------------------------------------------------- Methods

    /**
     * @return Returns the status.
     */
    public String getStatus() {
        //return status;
        return sendSMSView.getStatus().toString();
    }

    /**
     * @param status The status to set.
     */
    public void setStatus(Integer status) {
        //this.status = status;
        sendSMSView.setStatus(status);
    }


    public void setStatusType(int statusType){
        if(statusType == 1){
            setStatus(new Integer(1));
        }
        else if(statusType == 2){
            setStatus(new Integer(2));
        }
        else if(statusType == 3){
            setStatus(new Integer(3));
        }
        else if(statusType == 4){
            setStatus(new Integer(4));
        }

    }

    public String getStatusType(){
        String status = "";
        if((getStatus()!=null)&&(getStatus().equals("Succe ss"))){
            status = "Success";
        }
        else if((getStatus()!=null)&&(getStatus().equals("Faile d"))){
            status = "Failed";
        }
        else if((getStatus()!=null)&&(getStatus().equals("Pendi ng"))){
            status = "Pending";
        }
        else if((getStatus()!=null)&&(getStatus().equals("Queue d"))){
            status = "Queued";
        }
        else {
            status = "testing";
        }

        return status;
    }

    public String getModule(){
        return sendSMSView.getModule();
    }


    public void setModule(String module){
        sendSMSView.setModule(module);
    }

    public String getModuleType(){
        String moduleType = "";
        if((getModule()!=null)&&(getModule().equals("GEN") )){
            moduleType = "GEN";
        }
        return moduleType;
    }

    public void setModuleType(String moduleType){
        if(moduleType.equals("GEN")){
            setModule(new String("GEN"));
        }

    }


    /**
     * @return Returns the allProducts.
     */
    public Collection getAllProducts() {
        return allProducts;
    }

    /**
     * @param allProducts The allProducts to set.
     */
    public void setAllProducts(Collection allProducts) {
        this.allProducts = allProducts;
    }


    /**
     * Method validate
     * @param mapping
     * @param request
     * @return ActionErrors
     */
    public ActionErrors validate(
        ActionMapping mapping,
        HttpServletRequest request) {

        // TODO Auto-generated method stub
        return null;
    }

    /**
     * Method reset
     * @param mapping
     * @param request
     */
    public void reset(ActionMapping mapping, HttpServletRequest request) {

        sendSMSView = new SendSMSView();
        // TODO Auto-generated method stub
    }

    /**
     * @return Returns the sendSMSView.
     */
    public SendSMSView getSendSMSView() {
        return sendSMSView;
    }

    /**
     * @param sendSMSView The sendSMSView to set.
     */
    public void setSendSMSView(SendSMSView sendSMSView) {
        this.sendSMSView = sendSMSView;
    }


}



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

This is the SendReportAction class.......................


public class SendReportAction extends DispatchAction{

/**
     * Method updateData
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     */

public ActionForward updateData(
                ActionMapping mapping,
                ActionForm form,
                HttpServletRequest request,
                HttpServletResponse respons) {

                ShowDetailsForm showDetailsForm = new ShowDetailsForm();

            // TODO Auto-generated method stub
            try{

                String messageChange = request.getParameter("smessage");
                String moduleChange = request.getParameter("smodule");
                int repeatsChange = Integer.parseInt(request.getParameter("srepeats")) ;
                int statusChange = Integer.parseInt(request.getParameter("sstatus"));

            }catch (Exception e) {
                e.printStackTrace();
            }
            return mapping.findForward("updateSuccess");
        }


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

I know how to get data and update the details to the database..I just want to know why I got an error like cannot find updateData method inside action class and to see whet the mistake I have done..Please help me with this matter..Thank you..

Dileka





Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors nnrin Classic ASP Databases 2 December 11th, 2007 12:36 PM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
errors alihussein3 Javascript How-To 0 August 29th, 2003 04:58 PM
errors and fixing errors Droopy XML 0 August 26th, 2003 12:47 AM
Errors Errors DB Errors Ljhopkins VS.NET 2002/2003 0 July 15th, 2003 12:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.