cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate collection values in the node from JavaBeanModel?

Former Member
0 Kudos

Hi All,

I am using JavaBean Model. I’ve created Jar file which contains following Java Files.

<b>1. PendingInquiryBean.java</b>

package com.demo;

public class PendingInquiryBean {

private String inquiryID = "";

private String GMCCode = "";

private String ProductionDesc = "";

public String getGMCCode() {

return GMCCode;

}

public String getInquiryID() {

return inquiryID;

}

public String getProductionDesc() {

return ProductionDesc;

}

public void setGMCCode(String string) {

GMCCode = string;

}

public void setInquiryID(String string) {

inquiryID = string;

}

public void setProductionDesc(String string) {

ProductionDesc = string;

}

}

<b>

2.PendingInquiryHelper.java</b>

package com.demo;

public class PendingInquiryHelper {

private Collection colPenInq = new ArrayList();

PendingInquiryBean objPendingInquiryBean = null;

public void storePendingInquiries()

{

for(int i =0;i<5;i++)

{

objPendingInquiryBean = new PendingInquiryBean();

objPendingInquiryBean.setInquiryID("InquiryID"+i);

objPendingInquiryBean.setGMCCode("GMCCode"+i);

objPendingInquiryBean.setProductionDesc("ProductionDesc"+i);

colPenInq.add(objPendingInquiryBean);

}

this.setPendingInquiries(colPenInq);

}

public Collection getPendingInquiries() {

return colPenInq;

}

public void setPendingInquiries(Collection collection) {

colPenInq = collection;

}

}

<b>I want to populate Collection values with out writing any code.</b>

I created JavaBeanModel which contains above two classes.

While creating JavaBeanModel I have to define some relationship How to define relationship between Collection and PendingInquiryBean.

<b>If I write this following Code : I am able to print value</b>

PendingInquiryHelper obj = new PendingInquiryHelper();

obj.storePendingInquiries();

Collection v = obj.getPendingInquiries();

Iterator i = v.iterator();

while(i.hasNext())

{

PendingInquiryBean abcd = (PendingInquiryBean)i.next();

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("GMCCode->>>>>"+abcd.getGMCCode());

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("InquiryID->>>>>>"+abcd.getInquiryID());

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("ProductionDesc->>>>>>"+abcd.getProductionDesc());

}

<b>But If I print node values coming “Zero”</b>

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("Size"+wdContext.nodePendingInquiryBean_Help().size());

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("Size2"+wdContext.nodePendingInquiryBean().size());

I followed following Blog.

/people/balaramnaidu.bankuru/blog/2006/04/23/importing-complex-javabean-model-into-webdynpro-by-creating-relationships-for-the-model-classes

Please suggest me where i am doing wrong.

Thx & Rgds

AW

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Adam,

i hope ur requirement is to pass collection of values to Java Bean from Web dynpro.

please follow the follwing steps

1.in PendingInquiryHelper.java class remove the public void storePendingInquiries()

method insted generate the setter and getter methods for the collection variable

'colPenInq'.

2 .write one more method called executePeningInquires as follows

public void xecutePeningInquires()

{

//write the code to call java Bean(Session Bean) which actually performs the business logic

}

3.in web dynpro create one to many model relation between PendingInquiryHelper.java and PendingInquiryBean(i feel this method is helper class which actually contains database columns gettter and setter methods and u are going to use this in session bean as well).u can follow my blog for creating relation.

4.in the webdynpro create a collection object and populate collection object with PendingInquiryBean objects.then call the model object's setter method to pass the collection object to PendingInquiryHelper.java class.refer my blog for further reference.

5.atlast execute model obkect's execute method to execute actual business logic

hope this helps

if u have any furhter queries,please let me know

With Regards

Balaram Naidu Bankuru

Former Member
0 Kudos

Hi Balaram,

Really Thx for your supporting.

I dont want to Pass collection of values to Java Bean from Web dynpro.

I want populate to multiple rows from Oracle database to WebDynPro table.

I've not planned to use any session beans.

I am planning to Use Helper class for Like DAO and JavaBean for setter and getters.

This is actually my requirement.

If you see clearly my above code i am able to Print values using iterating.

Please could you suggest me How to aproach.

Thx & Rgds

AW.

Former Member
0 Kudos

Hi adam willams,

Where do you stuck.Have you created model of type JavaBean?.Have you created model relationship between PendingHelper.java and PendingInquiryBean?...

With regards,

Laksh.

Former Member
0 Kudos

Hi Laksh,

In the relation part i had struck.

Did you understood my Problem ? Could u tell me the step by step?

Thx & Rgds

AW

Former Member
0 Kudos

Is anybody any idea on this thread.

Thx & Rgds

AW

Former Member
0 Kudos

HI AW,

1. There will be 2 model classes after creating the model -- PendingInquiryBean and PendingInquiryHelper.

Create model relation for PendingInquiryHelper --->

RoleName - PendingInquires; Model Class - PendingInquiryBean; Cardinality - 0..n;

2. Now go for model binding and context mapping

3. Now go to Context menu of RootUIElementContainer and choose apply template --> table --> choose the node PendingInquiries and finish.

4. Here is the code to be incorporated.


 public void wdDoInit()
  {
    //@@begin wdDoInit()
    wdContext.nodePendingInquiryHelper().bind(new PendingInquiryHelper());
    //@@end
  }
  public static void wdDoModifyView(IPrivateAwdemoView wdThis, IPrivateAwdemoView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
    if(firstTime)
    {
    	wdContext.nodePendingInquiryHelper().currentPendingInquiryHelperElement().modelObject().storePendingInquiries();
    }
    //@@end
  }

5. Now deploy and run.

Note : Its displaying the 5 datas in the table.

With Regards,

Laksh.

Message was edited by:

Laksh

Former Member
0 Kudos

Hi Laksh ,

Thx for your reply.

Is role name shoud be PendingInquires or Collection Object name.

what exactly that?

Thx & Rgds

AW

Former Member
0 Kudos

Hi AW,

Role name should be PendingInquires.

1. From the blog mentioned above you can come to know:

public Collection getEmpDetailsList() {

return empDetailsList;

}

In the relation name specify Target role name as reference of the

collection that you mentioned in the EmpCommadBean. (This name must be

same as reference name). i.e., <b>"EmpDetailsList"</b>.

Have you solved your problem?.

With Regards,

Laskh.

Former Member
0 Kudos

Hi Adams,

Have you solved your problem?.

Do Award points if this is useful and close the thread.

With Regards,

Laskh.

Former Member
0 Kudos

Hello Laksh,

It's not solved. Still same problem.

Thx & Rgds

AW

Former Member
0 Kudos

Hi AW,

Send me your mailID. I will sent the working projects.

With Regards,

Laksh.

Former Member
0 Kudos

Hi Laksh

Pls send to this email id : suresh.s001@gmail.com

Thx & Rgds

AW

Former Member
0 Kudos

Hi AW,

I sent the files. let me know wether its working...

With Regards,

Laksh.

Answers (2)

Answers (2)

Former Member
0 Kudos

HI Adam,

if you observe the following thread,i have clearly mentioned how to create relation ship

between classes in web dynpro model.

<a href = "/people/balaramnaidu.bankuru/blog/2006/04/23/importing-complex-javabean-model-into-webdynpro-by-creating-relationships-for-the-model-classes

/people/balaramnaidu.bankuru/blog/2006/04/23/importing-complex-javabean-model-into-webdynpro-by-creating-relationships-for-the-model-classes

</a>

once u create a relation ship between classes in web dynpro, the remaining procedure is same as adpative rfc model.

just go throught it once,if u have any doubts please let me know

With Regards

Balaram Naidu Bankuru

Former Member
0 Kudos

Hi Balaram,

Thx for your reply.

By seeing your Blog only i got the idea and implemented.Its good Blog.

Plaese could you tell me (Step by Step) relation for my classes which i mentioned above.

I am JustHardCoding Collection Values in the helper class. I have created one bean.I want to populate those collection values in the table.

I tried many ways but no luck.Please help me out.

Your help will be appreciated.

Thx & Rgds

AW

Former Member
0 Kudos

Hello Experts,

Is anybody anyidea?

Help me out.

Thanks & Rgds

AW