Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BDE1D11879 for ; Mon, 24 Mar 2014 17:08:03 +0000 (UTC) Received: (qmail 31190 invoked by uid 500); 24 Mar 2014 17:08:02 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 29081 invoked by uid 500); 24 Mar 2014 17:07:49 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 36426 invoked by uid 99); 22 Mar 2014 10:31:40 -0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of charitha.nagella20@gmail.com does not designate 216.139.236.26 as permitted sender) Date: Sat, 22 Mar 2014 03:31:14 -0700 (PDT) From: struts2problems To: user@struts.apache.org Message-ID: <1395484274886-5715568.post@n5.nabble.com> Subject: Struts2 multiple submit buttons in One action class MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I wrote code for multiple submit buttons of one form in one Action class by using java bean. But when I was running the application first time its working fine After that I am getting NullPointerException . Please Help me. Here is My code. *Exception:* *!st time running.* calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 We are in add calling bean getterinfo.struts2.pinfo.PInfoDTO@16ea269 add *2nd time running* we are in edit calling bean getternull edit java.lang.NullPointerException at info.struts2.pinfo.DAO.edit(DAO.java:37) at info.struts2.pinfo.PInfoBean.editOperation(PInfoBean.java:23) at info.struts2.pinfo.PersonalInfoAction.edit(PersonalInfoAction.java:103) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:446) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:285) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) //PersonalInfoAction.java package info.struts2.pinfo; import sun.security.action.GetBooleanAction; import com.opensymphony.xwork2.ActionSupport; public class PersonalInfoAction extends ActionSupport { private static PInfoDTO bean; public PInfoDTO getBean() { System.out.println("calling bean getter"+bean); return bean; } public void setBean(PInfoDTO bean) { this.bean = bean; } /*private String name; private String city; private String street; private String district; private String country; private String pincode; private String pno; private String mno; private String email; private PInfoDTO pdto=new PInfoDTO(); public String getName() { return name; } public void setName(String name) { this.name = name; pdto.setName(name); } public String getCity() { return city; } public void setCity(String city) { this.city = city; pdto.setCity(city); } public String getStreet() { return street; } public void setStreet(String street) { this.street = street; pdto.setStreet(street); } public String getDistrict() { return district; } public void setDistrict(String district) { this.district = district; pdto.setDistrict(district); } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; pdto.setCountry(country); } public String getPincode() { return pincode; } public void setPincode(String pincode) { this.pincode = pincode; pdto.setPincode(pincode); } public String getPno() { return pno; } public void setPno(String pno) { this.pno = pno; pdto.setPno(pno); } public String getMno() { return mno; } public void setMno(String mno) { this.mno = mno; pdto.setMno(mno); } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; pdto.setEmail(email); }*/ public String add() { System.out.println("We are in add"); PInfoBean.addOperation(this.getBean()); return "success"; } public String edit(){ System.out.println("we are in edit"); PInfoBean.editOperation(this.getBean()); return "success"; } public String delete(){ System.out.println("we are in delete"); PInfoBean.deleteOperation(this.getBean()); return "success"; } public String execute(){ return "success"; } /*public void validate(){ //System.out.println(getPdto().getName()); if(getName()==null || getName().equals("")){ addFieldError("name", getText("required.name")); } if(getCity()==null || getCity().equals("")){ addFieldError("city", getText("required.city")); } if(getDistrict()==null || getDistrict().equals("")){ addFieldError("district", getText("required.district")); } if(getStreet()==null || getStreet().equals("")){ addFieldError("street", getText("required.street")); } if(getCountry()==null || getCountry().equals("")){ addFieldError("country", getText("required.country")); } } */ } And My java Bean Code is //PInfoDTO.java package info.struts2.pinfo; public class PInfoDTO { private String name; private String city; private String street; private String district; private String country; private String pincode; private String pno; private String mno; private String email; private String add; private String edit; private String delete; public String getAdd() { return add; } public void setAdd(String add) { this.add = add; } public String getEdit() { return edit; } public void setEdit(String edit) { this.edit = edit; } public String getDelete() { return delete; } public void setDelete(String delete) { this.delete = delete; } public String getName() { System.out.println("calling getName"+name); return name; } public void setName(String name) { System.out.println("calling setName"+name); this.name = name; } public String getCity() { return city; } public void setCity(String city) { System.out.println("calling setCity"+city); this.city = city; } public String getStreet() { return street; } public void setStreet(String street) { System.out.println("calling setStreet"+street); this.street = street; } public String getDistrict() { return district; } public void setDistrict(String district) { System.out.println("calling setDistrict"+district); this.district = district; } public String getCountry() { return country; } public void setCountry(String country) { System.out.println("calling setCountry"+country); this.country = country; } public String getPincode() { return pincode; } public void setPincode(String pincode) { System.out.println("calling setPincode"+pincode); this.pincode = pincode; } public String getPno() { return pno; } public void setPno(String pno) { System.out.println("calling setPno"+pno); this.pno = pno; } public String getMno() { return mno; } public void setMno(String mno) { System.out.println("calling setMno"+mno); this.mno = mno; } public String getEmail() { return email; } public void setEmail(String email) { System.out.println("calling setEmail"+email); this.email = email; } } //pinfo1.jsp <%@ taglib uri="/struts-tags" prefix="s"%> //struts.xml pinfo.jsp pinfo.jsp pinfo.jsp pinfo.jsp pinfo.jsp pinfo.jsp pinfo.jsp pinfo.jsp How to resolve this problem please help me. -- View this message in context: http://struts.1045723.n5.nabble.com/Struts2-multiple-submit-buttons-in-One-action-class-tp5715568.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org