cancel
Showing results for 
Search instead for 
Did you mean: 

Models - Create Model --> Import JavaBean Model means EJB not pure javabean

Former Member
0 Kudos

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 ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Here JavaBean is JabaBean....EJB is EJB.... no differences

Vito

Former Member
0 Kudos

So you means here JavaBean = EJB ?

Former Member
0 Kudos

No

Former Member
0 Kudos

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.

Former Member
0 Kudos

Sorry,

I think that Models - Create Model --> Import JavaBean works if you import an EJB, I mean in this way it make sense!

Vi.

Former Member
0 Kudos

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

monalisa_biswal
Contributor
0 Kudos

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>()