Struts2 and Hibernate

Struts2 and Hibernate

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.
View Answers

August 24, 2013 at 1:50 PM

Hi,

Can you explain me the complete functionality of the form and then we will develop example for you.

Thanks


August 24, 2013 at 2:27 PM

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.


August 24, 2013 at 3:28 PM

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.


August 24, 2013 at 4:35 PM

Sir for your more knowledge i am giving you application code for employee leave.


August 24, 2013 at 4:37 PM

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";
    }
}

August 24, 2013 at 4:38 PM

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
}*/

August 24, 2013 at 4:40 PM

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>









Related Tutorials/Questions & Answers:
Struts2 and Hibernate
Struts2 and Hibernate  how to fetch database value from one page to another page in struts2 and hibernate
Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after submitting the page it saved to the database. This was a tutorial i was trying from
Advertisements
Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after submitting the page it saved to the database. This was a tutorial i was trying from
Struts2 and Hibernate
Struts2 and Hibernate  Sir/ madam, Can we use iterator tag in struts for fetch the database value and shown on form. if yes then how
Integrate Hibernate to struts2.
Integrate Hibernate to struts2.  How to Integrate Struts Hibernate
Struts2 and Hibernate
Struts2 and Hibernate  Hello Sir, I am trying to fetch database value from one page to another page. Means i am submiting the form value... using struts2 and hibernate3.0. I need ur help try to short out this asap
Struts2 Spring Hibernate integration
Struts2 Spring Hibernate integration  How to integrate Struts2 Spring2.5 and Hibernate3 in a web application project?Could anyone give some example
Struts2 And Hibernate Configuration
Struts2 And Hibernate Configuration  Sir, I am new to struts2, I am trying to write a program using struts2 and hibernate. I want to know how.... Bachan Sahoo   Struts Hibernate Integration
struts2+hibernate - Struts
struts2+hibernate  How to use hibernate 3 with struts 2 application? kindly reply with example
struts2 with hibernate - Spring
struts2 with hibernate  hi can i use struts2 with spring i am a new user of spring please send me some tutorials of spring  Hi friend, I am sending you a link. This link will help you. Please visit for more
Hibernate criteria example using struts2
Hibernate criteria example using struts2 This hibernate criteria example using struts2 is used for defining the basics of criteria. The hibernate criteria... create query without HQL. In this hibernate criteria example using struts2, we
Online Cab Booking using Java (Struts2+Hibernate)
Online Cab Booking using Java (Struts2+Hibernate)  hi anyone send me the online cab booking(cab booking and canceling)using java+Struts2 its for my interview can u send as soon as possible.. thank u :) Surya
how to store and retrieve image using struts2 and hibernate integration
how to store and retrieve image using struts2 and hibernate integration  how to store and retrieve image using struts2 and hibernate integration? plz help !! thanks in advance
struts2
struts2  sir.... i am doing one struts2 application and i have to make pagination in struts2....how can i do
struts2
struts2  dear deepak sir plz give the struts 2 examples using applicationresources.properties file
how read excel data into database using struts2 with hibernate
how read excel data into database using struts2 with hibernate   hi friends, i am venkat i am started learning struts 2, please help me how to read excel data into database using struts2 with hibernate, please show me
Struts2 and Hibernate Fetch Data Base Value
Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am...;AdminProvideLeave>(); try { > Query q = session.createQuery("from >...;AdminLeavePojo> adlp = null; > try { Query q = > session.createQuery
Struts2 and Hibernate Fetch Data Base Value
Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am...;AdminProvideLeave>(); try { > Query q = session.createQuery("from >...;AdminLeavePojo> adlp = null; > try { Query q = > session.createQuery
struts2
struts2  hi all i am going to run struts2.x program i got this error when server started java.lang.RuntimeException...: Struts2 Tutorials
Struts2
Struts2  i want select multiple items from select list in struts2.when i did like that the two selected values must saved into databse in two diffirent rows.pls provide any one code for this i am new to Struts2
struts2
struts2   Sir when i have run my struts 2 web application,every time i get error " request resources is not available",,,what is this,,,plz help me
struts2
struts2  how to read properties file in jsp of struts2   Hi, You can use the Properties class of Java in your action class.ADS_TO_REPLACE_1 Properties pro = new Properties(); FileInputStream in = new FileInputStream(f
Struts2
Struts2  java.lang.NullPointerException org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69... exception while submitting the update form in struts2 I am using tomcat6.0 ... its
Struts2
Struts2  Hi I am using struts 2,In struts2 architecture ,I couldn't understand the purpose of ActionMapper and ActionProxy.My Question is,when the request comes into the picture,the filterdispatcher consult the ActionMapper
Struts2
Struts2  Hi, I need a solution for displaying success message in same page in struts2. how to redirect same page in struts2.Please help me.   hi friend, To know how redirect action can be done in struts 2 you can go
STRUTS2
STRUTS2  sir but my question is using ApplicationResources.properties in STRUTS 2.i cant get the values into my application.but in the exmple given at roseindia,u cant use the properties file.i use actionclass-validation.xml
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse  please help me i have to submit this soon
struts2 - Struts
Struts2 and Ajax Example  how to use struts2 and ajax
struts2 - Struts
struts2  how to pre populate the fields using struts2 from the database
struts2 excel downloads
struts2 excel downloads  hi sir, am new to the real time environment. am going to create excel sheet and setting values to excel sheet from db table dynamically by using Hibernate persistence logic.......am using struts2
Struts2 tag
Struts2 tag  function of hidden tag?   Hi Friend, <s:hidden> tag create a hidden value field.It means it stores the value but cannot be visible. For more information, visit the following link: Struts2 Tutorial
struts2 - Framework
struts2   RoseIndia i m using this code for a bean in struts2.but geting error SEVERE: Could not instantiate bean how to resolve this.thnx
struts2 - Framework
struts2  Hello, I am sathish.. I got problem in stuts2 ? Do tomcat5.5 support struts2 ? Now , currently my application running on tomcat 6... and mainly i want support with tiles(struts 2)...now which struts2 jars i have to use
New to struts2
New to struts2   Please let me know the link where to start for struts 2 beginners   Struts 2 Tutorials
struts2 - Framework
struts2  Hello, I am sathish i got one problem with struts2 framework...i want to create a jsp page in struts2 i need two buttons in tha jsp ..but these buttons are not dispaly in same row.....once if i create two buttons
Struts2 - Struts
Struts2  Hi, I am using doubleselect tag in struts2.roseindia is giving example of it with hardcoded values,i want to use it with dynamic values. Please give a example of it. Thanks
themes in struts2
themes in struts2  i want to create themes in strut2 can any one tell the step by step procedure of how to create it.with example links thanks in advance
Help in Struts2
Help in Struts2  Hi, in struts 2 how to get the values from db and show in jsp page using display tag or iterator tag thanks in advance
struts2 Autocompleter
struts2 Autocompleter  hi. I am working Auto Completer Example in rose india.net http://www.roseindia.net/struts/struts2/struts2uitags/autocompleter... struts2 2.1.8.1 Thanks venu
Struts2 Internationalization
Struts2 Internationalization  Hi How to use i18n functionality for indian languages in struts2 ? I am able to use french and english but none of the Indian languages. Pls help. Regards Vaishnavi   Please visit
struts2 filters
struts2 filters  hi i created a filter,if the session is null then it should to go error page that ur not authorized to access, nw my question is how to use means how to call filter to do the task pls help me
struts2 select tag multiple
struts2 select tag multiple  struts2 select tag multiple
struts2 tiles.xml
struts2 tiles.xml  Hi, I want to use .properties file data in tiles.xml file of struts2(2.1.8) application to display title. sample code I have used: In tiles.xml: <definition name="disastersettingsview_users" extends
struts2 - Struts
struts2  hello, am trying to create a struts 2 application that allows you to upload and download files from your server, it has been challenging for me, can some one help  Hi Friend, Please visit the following
struts.xml in struts2
struts.xml in struts2  What is the struts.xml file ? Who it is loads?   Hi Samar, The struts.xml is a XML file. Which is used to struts configuration. It divides the application in to modules. Struts use
HQL Query in execute method of Struts2
HQL Query in execute method of Struts2  I am making login page in struts2 and using hibernate . Now I wants to pull user name and password from.... Is it possible to write it at execute method of struts2
struts2 - Framework
struts2  i m beginner for struts2.i tried helloworld program from roseindia tutorial.But HelloWorld.jsp file didnt showing the current date and time. when i execute the program it showing this only Current date and time
struts2 - Framework
struts2  i m beginner for struts2.i tried helloworld program from roseindia tutorial.But HelloWorld.jsp file didnt showing the current date and time. when i execute the program it showing this only Current date and time
tags in struts2
tags in struts2  Hello I am using simple tags in struts2. Like this <%@ page language="java" contentType="text/html; charset=ISO-8859-1.../struts/struts2/struts2-login.shtml More Struts2 Tutorials
Struts2 - Struts
Struts2  S:select tag is being used in my jsp, to create a drop down list. The drop down works very well in Mozilla, but in IE7 it behaves very weird, meaning that the drop down wen clicked it just jumps out from the first row

Ads