cancel
Showing results for 
Search instead for 
Did you mean: 

Display data in Web DynPro table from database via EJB

Former Member
0 Kudos

I have a JavaBeans model which has a method populateDataToTable()to retrieve data from database via Session bean (calling entity bean, returning ArrayList of data) and the data needed to be display in the Web DynPro table.

User Interface (Web DynPro) <-> JavaBeans Model <-> Busineess Logic (session bean) <-> Persistence (Entity Bean)<-> DB table.

The context bindiing and table part is ok. How do i load the data to the table ? what the coding to put in wdDoInit() ?

Any help would be appreciated.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

I am working on a small web dynpro application that stores/retrieves data to and from an EJB. In the application there is a table that displays the data from the EJB. I have a Command Bean with a method to retrieve data from the EJB as an array "items[]". The properties of each item object in the array make up the columns in the table.

How do I bind array "items[]" from the Command Bean to the table in Web Dynpro?

Former Member
0 Kudos

hi Julius,

just delcare one collection type reference in the commandbean.populate the collection with the data coming from Ejb.import the commandbean into webdynro.since u are using complex types in ur commandbean u need to creare the relation ships between ur command bean and helpclass that u are using in the ejb with cardinality 0..n.while defining the cardinality u have to takecare about the names.once u create the relations ,if u execute the javabean method thru commanbean elements in the vire are autonmatically created.i did that one.it eas working perfectly fine.

With Regards

Naidu

Former Member
0 Kudos

I'm new to Web Dynpro, that tutorial file given by Mahesh was actually what i had followed to create JavaBean model, but lack of steps to load data to table. What i get is just a table with columns, without data. I have a method, myRetrieveDataMethod() in JavaBeans model, MyCommandBean to retrieve data (in ArrayList of bean) from the table.

this code in wdDoInit() doesnt work, what should it be:

wdContext.currentMyCommandBeanElement().modelObject().myRetrieveDataMethod();

what is the coding in myRetrieveDataMethod() in MyCommandBean to enable loading of the data to the table?

Former Member
0 Kudos

Hi,

Im facing the same problem...Cant retrieve data from the database..Please help me solve it...if possible please give me a sample project or tutorial..

Thanks,

Poonam

Former Member
0 Kudos

Poonam,

SAP tutorials have sample project associated.

Probably some info is missing in <b>text</b>, but it should be available in code.

Check the sample code as well (this tutorial AFAIK duplicated in "examples" directory of NetWeaver IDE installation).

VS

Former Member
0 Kudos

in wdinit(),

Collection col = new ArrayList();

try{

MyCommandBean bean = new MyCommandBean();

col = bean.getDataFromDbViaEJB();

wdContext.nodeMyCommandBean().bind(col);

} catch (Exception ex) {

ex.printStackTrace(ex);

}

in your JavaBean model class, MyCommandBean getDatafromDbViaEJB() method:

Collection col = new ArrayList();

Collection newcol = new ArrayList();

//include your own context initialization etc...

col = local.getDataViaSessionBean(param);

// if your returned result also a bean class, reassigned it to current MyCommandBean

for (Iterator iterator = col.iterator(); iterator.hasNext();) {

MyOtherBean otherBean=(MyOtherBean)iterator.next();

MyCommmandBean bean = new MyCommandBean();

bean.attribute1 = outBean.getAttirbute1();

// get other attibutes

newcol.add(bean);

}

return newcol;

Former Member
0 Kudos

you can tell me if my query condition is put into a view,and query result is display in another view. the others is the same as u said, how can i get the corret result.

thanks

Former Member
0 Kudos

Hi,

Refer to the tutorial given below.

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20using%20ejbs%20in%20web%20dynpro%20-%2020.html">Using EJBs in Web Dynpro</a>