DispatchAction Error on struts

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.SendReportAction.updateData(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

Here I add the necessary parts of jsp, struts config.xml, ActionFormclass 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>

Message Details

<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().equals("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().equals("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().equals("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().equals("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").toString()%></OPTION>

<%

}

%>

</select>

</td>

</tr>

<tr>

<td> </td>

<td> </td>

</tr>

<tr>

<td height="54"> </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>

</td>

</tr>

</table>

</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.SendSMSView;

/**

* MyEclipse Struts

* Creation date: 01-18-2007

*

* XDoclet definition:

* @struts.form name="showDetailsForm"

*/

publicclass ShowDetailsFormextends 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.

*/

publicvoid setStatus(Integer status){

//this.status = status;

sendSMSView.setStatus(status);

}

publicvoid setStatusType(int statusType){

if(statusType == 1){

setStatus(new Integer(1));

}

elseif(statusType == 2){

setStatus(new Integer(2));

}

elseif(statusType == 3){

setStatus(new Integer(3));

}

elseif(statusType == 4){

setStatus(new Integer(4));

}

}

public String getStatusType(){

String status ="";

if((getStatus()!=null)&&(getStatus().equals("Success"))){

status ="Success";

}

elseif((getStatus()!=null)&&(getStatus().equals("Failed"))){

status ="Failed";

}

elseif((getStatus()!=null)&&(getStatus().equals("Pending"))){

status ="Pending";

}

elseif((getStatus()!=null)&&(getStatus().equals("Queued"))){

status ="Queued";

}

else{

status ="testing";

}

return status;

}

public String getModule(){

return sendSMSView.getModule();

}

publicvoid setModule(String module){

sendSMSView.setModule(module);

}

public String getModuleType(){

String moduleType ="";

if((getModule()!=null)&&(getModule().equals("GEN"))){

moduleType ="GEN";

}

return moduleType;

}

publicvoid 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.

*/

publicvoid 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

returnnull;

}

/**

* Method reset

* @param mapping

* @param request

*/

publicvoid 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.

*/

publicvoid setSendSMSView(SendSMSView sendSMSView){

this.sendSMSView = sendSMSView;

}

}

--

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

publicclass SendReportActionextends 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..

[19291 byte] By [lmw_sa] at [2007-11-26 18:08:06]
# 1
Use a simple action and see whether it works fine or not...then turn into a dispatch or lookupdispatch action..regardsShanu
mshanua at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hiwhy ur <form > tag is under logic:iterate ?and where u have closed it ?Secondly, when u submit the form what url u will se on tha address bar ? is it showing "next=updateData " ?
java_usera at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

hello

first u need to understand why u should use dispatchAction..this is used if u have same kind of 2-3 mehods so instead of writing separate action for we write the dispatchAction.

the problem is with ur calling procedure

u can do in two ways

either specify the method name in the jsp where u have specified next=

use ?method=methodnane

or u can do it in struts-config.xml

just check on google

rakesh_thakura at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Hi java_user,

This is the url when I submit the data.. and its where I get that exception.

http://localhost:8080/SMSWeb/pages/jsp/smsserver/submitData.do?next=updateData

I have also added the </form> tag and see. But still the error was there..Can you please help me.

Thanx..

lmw_sa at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Dear rakesh_thakur,

I have 2 more methods in that class.Which I used to get data.but I didnt show them here. So in the post action

<form method="post" action="submitData.do?next=updateData">

the method name is updateData which I need to call.I have already shown my struts configuration.xml code here. So can you please check it and show me my mistake. thanx..

lmw_sa at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

hello iwa

dear i have spend some time with u code but everything appears correct and i dont know where is the problem.

why it is not finding the method.

u can try these things.

1. use struts <html:form action="/urAction.do?next=updateData" > tag dont forget to attach /(slash) before ur action.

and if u are using validation framework then remove reset and validate method from ur form bean class

and let me know

or do one things send ur struts-config,form bean and this action class and jsp file as attachment to rakesh.kumar@zed-axis.com

i will check it tomorrow

dont be get depressed just spend a little more time with it

i hope u will rectify it...

bye

rakesh_thakura at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Dear Rakesh,I have sent you a mail.If you have time just go through it. Thanx alot.Bye..
lmw_sa at 2007-7-9 5:39:40 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...