Hello Sir,
I am trying to fetch database value from one page to another page. Means i am submiting the form value in database but i want to display that submit database value in another page while using struts2 and hibernate3.0. I need ur help try to short out this asap.
Hi,
Can you explain me the complete functionality of the form and then we will develop example for you.
Thanks
Thanks for your reply,
I have one leave tracking application in that application one form for employee in that form employee mark there leave as their requirement. i am using 2 calendar text box for leavefrom and leaveto and other is text area for leave description. i am using drop down list for select their leave like sl, pl, el, cl, lwp. after submitting the form in mysql database admin can show employee leave on that their own admin page for approval leave by admin.
My problem is that everything is ready i want to display database value on admin form and after approve the leave by admin leave should be change in database and display on employee view leave form when employee login for apply next leave. try to help me asap.
hi, Is it possible to provide me another application in which we are using 3-4 forms and one form value is display on another page with struts2 and hibernate3.0 and using mysql database. it doesn't matter that project based on leave module. i want to know how to display one form value on another form. try to help me.
Thanks.
Sir for your more knowledge i am giving you application code for employee leave.
LeavePojo.java package mypack; import com.opensymphony.xwork2.ActionSupport; public class Leavepojo extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; private int serial_no,el,cl,sl,pl,lwp,total_leave,rel,rcl,rsl,rpl,rlwp, rtotal_leave; private String emp_id,name,leave_from,to_leave,description,approved_by; private boolean status; public Leavepojo() { super(); // TODO Auto-generated constructor stub } public Leavepojo(int serialNo, int cl, int pl, int el, int sl, int lwp, int totalLeave, String empId, String name, String leaveFrom, String toLeave, String description, String approvedBy, boolean status,int rcl, int rpl, int rel, int rsl, int rlwp, int rtotalLeave) { super(); serial_no = serialNo; this.el = el; this.cl = cl; this.sl = sl; this.pl = pl; this.lwp = lwp; total_leave = totalLeave; emp_id = empId; this.name = name; leave_from = leaveFrom; to_leave = toLeave; this.description = description; approved_by = approvedBy; this.status = status; this.rcl= rcl; this.rpl= rpl; this.rel=rel; this.rlwp=rlwp; this.rsl= rsl; this.rtotal_leave= rtotal_leave; } public int getSerial_no() { return serial_no; } public void setSerial_no(int serialNo) { serial_no = serialNo; } public int getEl() { return el; } public void setEl(int el) { this.el = el; } public int getCl() { return cl; } public void setCl(int cl) { this.cl = cl; } public int getSl() { return sl; } public void setSl(int sl) { this.sl = sl; } public int getPl() { return pl; } public void setPl(int pl) { this.pl = pl; } public int getLwp() { return lwp; } public void setLwp(int lwp) { this.lwp = lwp; } public int getTotal_leave() { return total_leave; } public void setTotal_leave(int totalLeave) { total_leave = totalLeave; } public String getEmp_id() { return emp_id; } public void setEmp_id(String empId) { emp_id = empId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLeave_from() { return leave_from; } public void setLeave_from(String leaveFrom) { leave_from = leaveFrom; } public String getTo_leave() { return to_leave; } public void setTo_leave(String toLeave) { to_leave = toLeave; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getApproved_by() { return approved_by; } public void setApproved_by(String approvedBy) { approved_by = approvedBy; } public boolean isStatus() { return status; } public void setStatus(boolean status) { this.status = status; } public int getRel() { return rel; } public void setRel(int rel) { this.rel = rel; } public int getRcl() { return rcl; } public void setRcl(int rcl) { this.rcl = rcl; } public int getRsl() { return rsl; } public void setRsl(int rsl) { this.rsl = rsl; } public int getRpl() { return rpl; } public void setRpl(int rpl) { this.rpl = rpl; } public int getRlwp() { return rlwp; } public void setRlwp(int rlwp) { this.rlwp = rlwp; } public int getRtotal_leave() { return rtotal_leave; } public void setRtotal_leave(int rtotalLeave) { rtotal_leave = rtotalLeave; } public static long getSerialversionuid() { return serialVersionUID; } public String execute() { //Dao d= new Dao(); Dao.insert1(this); return "success"; } }
Dao.java
package mypack; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.QueryException;
public class Dao {
public static void insert(Signuppojo O) { Configuration cfg = new Configuration().configure(); SessionFactory f = cfg.buildSessionFactory(); Session session = f.openSession(); Transaction t = session.beginTransaction(); session.save(O); t.commit(); session.close(); } public static void insert1(Leavepojo lp) { Configuration cfg = new Configuration().configure(); SessionFactory f = cfg.buildSessionFactory(); Session session = f.openSession(); Transaction t = session.beginTransaction(); session.save(lp); t.commit(); session.close(); } /*public void save(Leavepojo emp) { // TODO Auto-generated method stub }*/ } /*public static void insert2(Rleavepojo p) { Configuration cfg = new Configuration().configure(); SessionFactory f = cfg.buildSessionFactory(); Session session = f.openSession(); Transaction t = session.beginTransaction(); List<Rleavepojo> leavelist = null; try { Query q = (Query) session .createQuery("from Rleavepojo where Emp_id= sz-12345"); //leavelist = q.list(); } catch (HibernateException e) { System.out.println(e); } t.commit(); session.close(); } public void save(Rleavepojo rleave) { // TODO Auto-generated method stub }*/
mapp.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="mypack.Signuppojo" table="newsignup"> <id name="serial_no" column="Serial_no" type="int"> <generator class="increment"></generator> </id> <property name="emp_id" column="Emp_id" type="string"></property> <property name="name" column="Name" type="string"></property> <property name="gender" column="gender" type="string"></property> <property name="email_id" column="email_id" type="string"></property> <property name="dept" column="dept" type="string"></property> <property name="designation" column="designation" type="string"></property> <property name="contact" column="Contact_No" type="string"></property> <property name="pwd" column="Password" type="string"></property> <property name="cpwd" column="Cpassword" type="string"></property> </class> <class name="mypack.Leavepojo" table="empleave"> <id name="serial_no" column="serial_no" type="int"> <generator class="increment"></generator> </id> <property name="emp_id" column="emp_id" type="string"></property> <property name="name" column="name" type="string"></property> <property name="leave_from" column="leave_from" type="string"></property> <property name="to_leave" column="Leave_to" type="string"></property> <property name="description" column="Description" type="string"></property> <property name="cl" column="CL" type="int"></property> <property name="pl" column="PL" type="int"></property> <property name="el" column="EL" type="int"></property> <property name="sl" column="SL" type="int"></property> <property name="lwp" column="Lwp" type="int"></property> <property name="total_leave" column="Total_leave" type="int"></property> <property name="status" column="Status" type="boolean"></property> <property name="approved_by" column="Approved_by" type="string"></property> <property name="rcl" column="RCL" type="int"></property> <property name="rpl" column="RPL" type="int"></property> <property name="rel" column="REL" type="int"></property> <property name="rsl" column="RSL" type="int"></property> <property name="rlwp" column="RLwp" type="int"></property> <property name="rtotal_leave" column="TotalRLeave" type="int"></property> </class> <!-- <class name ="mypack.Rleavepojo" table="empleave"> <id name="serial_no" column="serial_no" type="int"> <generator class="increment"></generator> </id> <property name="rcl" column="RCL" type="int"></property> <property name="rpl" column="RPL" type="int"></property> <property name="rel" column="REL" type="int"></property> <property name="ssl" column="RSL" type="int"></property> <property name="rlwp" column="RLwp" type="int"></property> <property name="rtotal_leave" column="TotalRLeave" type="int"></property> </class> --> </hibernate-mapping>