• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem between Form and Action

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there... i m creating an webportal using struts...
my work was going smoothly and i was doing interaction with database also...
then while further coding i dont know what went wrong and now when i try to run my application the control comes back from Form only...
it performs Form level validations but then it doesnt go to Action neither it gives any error...
i m attaching here the codes of my JSP Form and Action and Struts-config...

m not able to attache my code also....

on debuging i got stuck at RequestProcessor.class
giving error that
the source attachment does not contain the source for the file RequestProcessor.class

and giving button to change the source...
i tried changing it with a number struts.jar but yet it is not procedding ahead...

please give me a solution if u have...
thanx in advance... hoping to have a solution soon...



[ May 06, 2006: Message edited by: lubna arab ]
[ May 06, 2006: Message edited by: lubna arab ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's very difficult for us to help you debug this without you posting at least fragments of your code.

Regarding your problem with the debugger: The struts.jar file does not contain any source. You must download the source separately for the version of Struts that you are using from http://struts.apache.org

Unzip it to your hard drive, and then point Eclipse to <source root>/src/share.

Be aware, though, that Srruts also uses a lot of Apache Commons classes, and if you want to debug those, you will have to get the source to each commons library separately.
 
lubna kausar
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually i dont want to debug internal functions neither i go inside any internal function but after performin formlevel validation i.e. returning ActionError object i get this problem saying no source for RequestProcessor.class so i also got confused as before it was working properly while debuging also ... i tried to attach source code but site is not allowing me to do so and says to change many portions of code...but will try to upload files somewhere and will post the link here...
 
lubna kausar
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any bodey please help me...
it took my 2 days n yet m not able to locate the problem...
my application doesnt go beyond UserForm.java
and the thing is that it was working properly when i did initial coding but after adding some more features... it is not interacting with UserAction...
my code is
UserForm

// Created by Xslt generator for Eclipse.
// XSL : not found (java.io.FileNotFoundException: (The handle is invalid))
// Default XSL used : easystruts.jar$org.easystruts.xslgen.JavaClass.xsl

package com.patni.peass.form.user;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMessage;
//import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* UserForm.java created by EasyStruts - XsltGen.
* http://easystruts.sf.net
* created on 05-02-2006
*
* XDoclet definition:
* @struts:form name="userForm"
*/
public class UserForm extends ActionForm {
// --------------------------------------------------------- Instance Variables
/** mobileNo property */
private String mobileNo = null;
/** countryCode property */
private String countryCode = null;
/** phoneNo property */
private String phoneNo = null;
/** lastName property */
private String lastName = null;
/** middleName property */
private String middleName = null;
/** roleId property */
private String roleId = "2";
/** firstName property */
private String firstName = null;
/** userName property */
private String userName = null;
/** userEmailID property */
private String userEmailID = null;
/** extensionNo property */
private String extensionNo = null;
/** admin property */
/**private String admin = null;
/** areaCode property */
private String areaCode = null;
/** userAlias property */
private String userAlias = null;
/** location property */
private String location=null;
/** user'list property*/
private String userList=null;
//** buttond property...*/
private String function=null;




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

ActionErrors ae = new ActionErrors();
if(request.getParameterMap().containsKey("button.edit"))
{
}
if(userName==null || userName.equals(""))
{
ae.add("userName",new ActionMessage("userName is a required field"));
//ae.add("userName",new ActionError("error.no.userName"));
}
/*if(roleId==null || roleId.equals(""))
{
ae.add("roleId",new ActionError("error.no.roleId"));
}
*/
if(userEmailID==null || userEmailID.equals(""))
{
ae.add("userEmailID",new ActionMessage("EmailID is a required field"));
//ae.add("userEmailID",new ActionError("error.no.userEmailID"));
}
if(countryCode!=null || areaCode!=null || phoneNo!= null)
{
if(!(isNumeric(countryCode) && isNumeric(areaCode) && isNumeric(phoneNo)))
{
ae.add("contactNo",new ActionMessage("contactNo can have numeric values only"));
//ae.add("contactNo",new ActionError("error.invalid.contactNo"));
}
}
if(extensionNo!= null)
{
if(!(isNumeric(extensionNo)))
{
ae.add("extensionNo",new ActionMessage("extensionNo can have numeric values only"));
//ae.add("extensionNo",new ActionError("error.invalid.extensionNo"));
}
}
if(mobileNo != null)
{
if(!(isNumeric(mobileNo)))
{
ae.add("mobileNo",new ActionMessage("mobileNo can have numeric values only"));
//ae.add("mobileNo",new ActionError("error.invalid.mobileNo"));
}
}

return ae;
}

/** To check whether entered string is numeric or not...
* returns true if string is numeric and false otherwise...
*
*/
public boolean isNumeric(String number)
{
for(int i=0;i<number.length()-1;i++)
{
if((number.charAt(i)<'0' || number.charAt(i)>'9'))
return false;
}
return true;

}
/**
* Returns the mobileNo.
* @return String
*/
public String getMobileNo() {
return mobileNo;
}
/**
* Set the mobileNo.
* @param mobileNo The mobileNo to set
*/
public void setMobileNo(String mobileno) {
this.mobileNo = mobileno;
}
/**
* Returns the countryCode.
* @return String
*/
public String getCountryCode() {
return countryCode;
}
/**
* Set the countryCode.
* @param countryCode The countryCode to set
*/
public void setCountryCode(String countrycode) {
this.countryCode = countrycode;
}
/**
* Returns the phoneNo.
* @return String
*/
public String getPhoneNo() {
return phoneNo;
}
/**
* Set the phoneNo.
* @param phoneNo The phoneNo to set
*/
public void setPhoneNo(String phoneno) {
this.phoneNo = phoneno;
}
/**
* Returns the lastName.
* @return String
*/
public String getLastName() {
return lastName;
}
/**
* Set the lastName.
* @param lastName The lastName to set
*/
public void setLastName(String lastname) {
this.lastName = lastname;
}
/**
* Returns the middleName.
* @return String
*/
public String getMiddleName() {
return middleName;
}
/**
* Set the middleName.
* @param middleName The middleName to set
*/
public void setMiddleName(String middlename) {
this.middleName = middlename;
}

/**
* Returns the firstName.
* @return String
*/
public String getFirstName() {
return firstName;
}
/**
* Set the firstName.
* @param firstName The firstName to set
*/
public void setFirstName(String firstname) {
this.firstName = firstname;
}
/**
* Returns the userName.
* @return String
*/
public String getUserName() {
return userName;
}
/**
* Set the userName.
* @param userName The userName to set
*/
public void setUserName(String username) {
this.userName = username;
}
/**
* Returns the userEmailID.
* @return String
*/
public String getUserEmailID() {
return userEmailID;
}
/**
* Set the userEmailID.
* @param userEmailID The userEmailID to set
*/
public void setUserEmailID(String email) {
this.userEmailID = email + "@patni.com";
}
/**
* Returns the extensionNo.
* @return String
*/
public String getExtensionNo() {
return extensionNo;
}
/**
* Set the extensionNo.
* @param extensionNo The extensionNo to set
*/
public void setExtensionNo(String extensionno) {
this.extensionNo = extensionno;
}

/**
* Returns the areaCode.
* @return String
*/
public String getAreaCode() {
return areaCode;
}
/**
* Set the areaCode.
* @param areaCode The areaCode to set
*/
public void setAreaCode(String areacode) {
this.areaCode = areacode;
}
/**
* Returns the userAlias.
* @return String
*/
public String getUserAlias() {
return userAlias;
}
/**
* Set the userAlias.
* @param userAlias The userAlias to set
*/
public void setUserAlias(String useralias) {
this.userAlias = useralias;
}
/**
* @return
*/
public String getLocation() {
return location;
}

/**
* @param string
*/
public void setLocation(String string) {
location = string;
}

/**
* @return
*/
public String getUserList() {
return userList;
}

/**
* @param string
*/
public void setUserList(String string) {
userList = string;
}

/**
* @param integer
*/
public void setRoleId(String string) {
if(string=="admin")
roleId="1";
if(string=="normal")
roleId="2";
}
public String getRoleId()
{
return (String)(roleId);
}
/**
* @return
*/

/**
* @return
*/
public String getFunction() {
return function;
}

/**
* @param string
*/
public void setFunction(String string) {
function = string;
}
public void reset(HttpServletRequest request)
{
setAreaCode(null);
setCountryCode(null);
setExtensionNo(null);
setFirstName(null);
setFunction(null);
setLastName(null);
setLocation(null);
setMiddleName(null);
setMobileNo(null);
setPhoneNo(null);
setRoleId(null);
setUserAlias(null);
setUserEmailID(null);
setUserName(null);
}
}

and UserAction

// Created by Xslt generator for Eclipse.
// XSL : not found (java.io.FileNotFoundException: (Bad file descriptor))
// Default XSL used : easystruts.jar$org.easystruts.xslgen.JavaClass.xsl

package com.patni.peass.action.user;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.patni.peass.bean.user.UserBean;
import com.patni.peass.business.UserBusiness;
import com.patni.peass.utils.common.PasswordUtil;

/**
* UserAction.java created by EasyStruts - XsltGen.
* http://easystruts.sf.net
* created on 05-02-2006
*
* XDoclet definition:
* @struts:action validate="true"
*/
public class UserAction extends Action {
/**
*
*/
public UserAction() {
super();
}



/* (non-Javadoc)
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/

public UserBean createBean(HttpServletRequest request)
{
String password=null;
String contactNo=request.getParameter("countryCode")+'-'+request.getParameter("areaCode")+'-'+request.getParameter("phoneNo");
password=PasswordUtil.generatePassword();
UserBean ub = new UserBean();
ub.setUserName(request.getParameter("userName"));
ub.setUserPassword(password);
ub.setRoleId((int) 2);
//ub.setRoleId(Integer.parseInt(request.getParameter("roleId")));
ub.setUserEmailID(request.getParameter("userEmailID"));
ub.setUserAlias(request.getParameter("userAlias"));
ub.setFirstName(request.getParameter("firstName"));
ub.setLastName(request.getParameter("lastName"));
ub.setContactNo(contactNo);
ub.setLocation(request.getParameter("location"));
ub.setExtensionNo(request.getParameter("extensionNo"));
ub.setMobileNo(request.getParameter("mobileNo"));
return ub;
}

public ArrayList createBean(ArrayList userList)
{
return userList;
}

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
ArrayList userList=new ArrayList();
userList=UserBusiness.findAll();
request.setAttribute("users",userList);
return mapping.findForward("success");
}

public ActionForward save(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
boolean res=false;
boolean res1=false;
UserBean ub=createBean(request);
res1=UserBusiness.validateUser(request,ub);
if(res1){
res=UserBusiness.addRecord(ub);
}
if(res)
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("faliour");
}
}
/**
* Method edit
* @param ActionMapping mapping
* @param ActionForm form
* @param HttpServletRequest request
* @param HttpServletResponse response
* @return ActionForward
* @throws Exception
*/

public ActionForward edit(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
boolean res=false;
boolean res1=false;
UserBean ub=createBean(request);
res1=UserBusiness.validateUser(request,ub);
if(res1)
{
res=UserBusiness.updateRecord(ub);
}
if(res)
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("faliour");
}
}

/**
* Method edit
* @param ActionMapping mapping
* @param ActionForm form
* @param HttpServletRequest request
* @param HttpServletResponse response
* @return ActionForward
* @throws Exception
*/
public ActionForward delete(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
boolean res=false;
UserBean ub=createBean(request);
res=UserBusiness.updateRecord(ub);
if(res)
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("faliour");
}
}
}
and struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

<!-- ========== Data Source Configuration =============================== -->
<data-sources />

<!-- ========== Form Bean Definitions ================================== -->
<form-beans>
<form-bean name="userForm" type="com.patni.peass.form.user.UserForm">
<form-property name="function" type="java.lang.String" />
<form-property name="userName" type="java.lang.String" />
<form-property name="areaCode" type="java.lang.String" />
<form-property name="phoneNo" type="java.lang.String" />
<form-property name="countryCode" type="java.lang.String" />
<form-property name="userAlias" type="java.lang.String" />
<form-property name="firstName" type="java.lang.String" />
<form-property name="lastName" type="java.lang.String" />
<form-property name="userList" type="java.lang.String" />
<form-property name="mobileNo" type="java.lang.String" />
<form-property name="normal" type="java.lang.String" />
<form-property name="middleName" type="java.lang.String" />
<form-property name="location" type="java.lang.String" />
<form-property name="admin" type="java.lang.String" />
<form-property name="extensionNo" type="java.lang.String" />
<form-property name="userEmailID" type="java.lang.String" />
</form-bean>

</form-beans>

<!-- ========== Global Exception Definitions ============================== -->
<global-exceptions />

<!-- ========== Global Forward Definitions =============================== -->
<global-forwards>
<forward name="home" path="/home.jsp" />
<forward name="login" path="/index.jsp" />

</global-forwards>

<!-- ========== Action Mapping Definitions =============================== -->
<action-mappings>
<action
attribute="loginForm"
input="/index.jsp"
name="loginForm"
path="/login"
type="com.patni.peass.action.user.LoginAction">
<forward name="success" path="/home.jsp" />
<forward name="failure" path="/forgot.jsp" />
</action>
<action
input="/index.jsp"
path="/openForgot"
type="com.patni.peass.action.user.OpenForgotAction"
validate="false">
<forward name="success" path="/forgot.jsp" />
</action>
<action
attribute="forgotPassword"
input="/forgot.jsp"
name="forgotPassword"
path="/processForgot"
type="com.patni.peass.action.user.ForgotPasswordAction">
<forward name="success" path="/index.jsp" />
</action>
<action
attribute="changePassword"
input="/change.jsp"
name="changePassword"
path="/processChange"
type="com.patni.peass.action.user.ChangePasswordAction">
<forward name="success" path="/home.jsp" />
</action>
<action
input="/UserInfo.jsp"
name="userForm"
path="/user"
scope="request"
type="com.patni.peass.action.user.UserAction">
<forward name="success" path="/UserInfo.jsp" parameter="function"/>
</action>

</action-mappings>

<!-- ========== Controller Configuration ================================ -->
<controller />

<!-- ========== Message Resources Definitions ============================ -->

<!-- ========== Plug Ins Configuration ================================= -->
<message-resources parameter="com.patni.peass.ApplicationResources" />
</struts-config>
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check your validation method. If control is not going beyonf ActionForm it means either setMethod Throwing exception or validation method returning some error. Try to add input attribute in your action in struts config.
and put </html:errors> in that input jsp.
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

change this

<action
input="/UserInfo.jsp"
name="userForm"
path="/user"
scope="request"
type="com.patni.peass.action.user.UserAction">
<forward name="success" path="/UserInfo.jsp" parameter="function"/>
</action>

To

<action
input="/UserInfo.jsp"
name="userForm"
path="/user"
scope="request"
type="com.patni.peass.action.user.UserAction parameter="function"">
<forward name="success" path="/UserInfo.jsp" />
</action>

note: parameter attribute should present in action tag not in forward tag
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic