• 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

need help regarding multiple submit buttons...

 
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 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");
}
}
}
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we know that what error you are getting , please paste the error here
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
give Struts config entry to help u more
 
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
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
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Straws are for suckers. Now suck on this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic