on 02-15-2007 4:14 PM
Hi,
As I know, javabean is not EJB. But after studying it a few days. I think the JavaBean here means EJB not pure JavaBean. Is this right ?
Hi,
Import JavaBean really does mean "Import JavaBean", and <b>not</b> "Import EJB". To create a model from an EJB does not make sense, because the Web Dynpro app would not know how to create the EJB and use it. However, there is nothing to prevent your JavaBean from using an EJB - i.e., it will be a "wrapper" for your EJB.
So, in short - you <b>cannot</b> directly use an EJB as a model.
Walter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here JavaBean is JabaBean....EJB is EJB.... no differences
Vito
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If I import a javabean, how to use the javabean function.
(1) The following is my program.
package com.sun;
import java.math.BigDecimal;
import java.sql.*;
public class EmpBean
{
public int getEmpno() {
return this.empno;
}
public void setEmpno(int inValue) {
empno = inValue;
}
public String getEname() {
return this.ename;
}
public void setEname(String inValue) {
if (inValue != null)
this.ename = inValue;
}
public String getJob() {
this.job="engineer";
return this.job;
}
public void setJob(String inValue) {
if (inValue != null)
this.job = inValue;
}
public int getMgr() {
return this.mgr;
}
public void setMgr(int inValue) {
mgr = inValue;
}
public java.sql.Date getHiredate() {
return this.hiredate;
}
public void setHiredate(java.sql.Date inValue) {
hiredate = inValue;
}
public double getSal() {
return this.sal;
}
public void setSal(double inValue) {
sal = inValue;
}
public double getComm() {
this.comm=5.0;
return this.comm;
}
public void setComm(double inValue) {
comm = inValue;
}
public int getDeptno() {
return this.deptno;
}
public void setDeptno(int inValue) {
deptno = inValue;
}
public void setAttributes(ResultSet rs)
throws SQLException {
setEmpno(rs.getInt("EMPNO"));
setEname(rs.getString("ENAME"));
setJob(rs.getString("JOB"));
setMgr(rs.getInt("MGR"));
setHiredate(rs.getDate("HIREDATE"));
setSal(rs.getDouble("SAL"));
setComm(rs.getDouble("COMM"));
setDeptno(rs.getInt("DEPTNO"));
}
public String insertStatement() {
String str = "INSERT INTO EMP (EMPNO,ENAME,JOB,MGR,SAL,COMM,DEPTNO) VALUES (?,?,?,?,?,?,?,?)";
return str;
}
public void insertDatabase(Connection conn)
throws SQLException {
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(insertStatement());
ps.setInt(1, getEmpno());
ps.setString(2, getEname());
ps.setString(3, getJob());
ps.setInt(4, getMgr());
ps.setDate(5, getHiredate());
ps.setDouble(6, getSal());
ps.setDouble(7, getComm());
ps.setInt(8, getDeptno());
ps.executeUpdate();
} finally {
if (ps != null) {
try {
ps.close();
ps = null;
} catch(SQLException e) {}
}
}
}
private int empno;
private String ename = "";
private String job = "";
private int mgr;
private java.sql.Date hiredate;
private double sal;
private double comm;
private int deptno;
}
(2) After importing this program , I get one class and 8 properties.
(3) I draft a view and put 8 input fields. How to show database data to 8 input fields through the javabean.
Hi,
If you import your bean then you can see following Modelattributes in your webdynpro model .
Empno
Ename
Job
Mgr
HireDate etc etc
insertDatabase and insertXX will be functions on the modelclass.
Idea is if you have a simple bean,,,,,I mean a class with setter/getter methods then JavaBeanImporter will consider those as modelclass attributes.
Check Blogs on JavaBeanImporter
/people/anilkumar.vippagunta2/blog/2005/09/02/java-bean-model-importer-in-web-dynpro
/people/valery.silaev/blog/2005/08/30/javabean-model-import-when-it-really-works
/people/gilles.atlan/blog/2005/09/21/at-teched-best-practices-for-using-the-javabean-model-in-web-dynpro
Regards,Anilkumar
When you import javabean one model class is created with the same name as java bean class name.
After you create model, you have to create model node in the controller using model binding in Data Modeler.
Now if you want to execute some method in javabean use following method.
wdContext.current<Model Node>Element().modelObject().<methodname>()
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.