aspose file tools*
The moose likes Struts and the fly likes need help regarding multiple submit buttons... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "need help regarding multiple submit buttons..." Watch "need help regarding multiple submit buttons..." New topic
Author

need help regarding multiple submit buttons...

lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
hi there can i know where i m wrong... as this code doesnt give me the result...

ACTION...

package com.patni.peass.action.user;

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

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 org.apache.struts.actions.DispatchAction;

import com.patni.peass.bean.user.UserBean;
import com.patni.peass.business.UserBusiness;
import com.patni.peass.form.user.UserForm;
import com.patni.peass.form.user.UserForm.Users;
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 DispatchAction {
/**
*
*/
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 ArrayList getList(ArrayList userbean, ActionForm form)
{
int i=0;
String listUser[] = null;
ArrayList userList=null;
while(i<userbean.size())
{
UserBean ub=(UserBean) userbean.get(i);
listUser[i]=ub.getUserName();
i++;
Users user = null;
user.setUserName(listUser[i]);
userList.add(user);
}
return userList;
}
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;
}
protected Map getKeyMethodMap(ActionMapping mapping,
ActionForm form,
HttpServletRequest request) {
Map map = new HashMap();
map.put("button.save", "add");
map.put("button.edit", "edit");
map.put("button.delete", "delete");
return map;
}

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
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;
UserBean ub=createBean(request);
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");
}
}
}
ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208
can we know that what error you are getting , please paste the error here
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
give Struts config entry to help u more
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
here is the code in struts-config...

"<"action
attribute="userForm"
input="/UserInfo.jsp"
name="userForm"
parameter="function"
path="/user"
type="com.patni.peass.action.user.UserAction">
"<"forward name="success" path="/UserInfo.jsp" />
"<"/action>
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
i also want to add that i dont understand how "function" will get values like "add", "edit" n "delete" as i m not specifying it any where...
how it gets bound???
if i need to specify that thing then please do let me know...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: need help regarding multiple submit buttons...