cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in creating a java Bean Model

Former Member
0 Kudos

Hi All,

I am fairly new to java. I am trying to go ahead with a java bean model.

For that I need a jar file. Can any one help me how to create a jar file.

Looking forward to you.

Regards

DK

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Rightclick the Project(or from File menu) and select Export you can see the Jar format there.Select the jar and give the name.

Kind Regards

Mukesh

Former Member
0 Kudos

Hi Mukesh,

Thanks for your reply.

I Created a simple Java Bean (JavaClass) and created jar file from that project.

From Web Dynpro, i created a Java Bean Model using this jar file. When i try to make a connection between controller and Model using Apply Template, i am getting "Context Element Can't bound to model layer." Error. So i created a data link and from View to Controller also.

When i try to run this application, it is giving

java.lang.NoClassDefFoundError: com.test.TestClass

at com.accenture.practice.rrs.wdp.InternalJavaModelComp.<init>(InternalJavaModelComp.java:45)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

Regards,

Sridhar

Former Member
0 Kudos

Hi Sridhar,

are you working on the NWDI?

If this is not the case you have to add your jar file to the lib folder of your wd project.

WebDynpro Perspective -> Navigator -> lib -> paste your jar file there

Regards

Sebastian

Former Member
0 Kudos

Hi,

I am new to java, kindly explain me the detail steps for tha same.

Regards

DK

sridhar_k2
Active Contributor
0 Kudos

Hi DK,

For Java Bean Model I have Created a Bean with two fields. Follow the below procedure.

Step - 1 First create a simple java bean in NWDS in Java Perspective.


Public class TestJavaClass implements java.io.Serializable{
   int code = 10;
   String name = "SAP";
// generate Getter and Setter Methods for these fields.
}

Export this project as jar for the Java Bean Model.

Step - 2 From Web Dynpro Perspective

Importing java bean model implementation:

1) In the proj structure expand Webdynpro>Models>create model.

2) Choose the import java bean model option followed by Next.

3) Select Local Jar File Radio Button -> Add Jar -> Next -> Finish.

4) Add the Jar file to your Web Dynpro Project from Navigator View -> Lib -> Paste the jar file. -> Re Build the Project.

Step - 3 Accessing Bean Model in Web Dynpro

In the data modeller toolbar, create a data link b/w component controller and bean model. Draw a line starting from controller to the model.

Using drag and drop and drag the node of model Bean in the bean model to the root node of comp.ctrller.

Select the model node and all the model att.

Now if u expands the context tree in the following the link b/w component controller and the model is displayed graphically through the link lines.

Access Bean Property like this.

wdContext.currentTestJavaClassElement().modelObject().getCode();
(OR)
new TestJavaClass().getCode();

For more information go through this link.

/people/david.beisert/blog/2004/10/26/webdynpro-importing-java-classes-as-model

EJB’s Use in NWDS

-> Add also the ejb20.jar to the class path.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/a11ba7c8-0401...

Regards,

SK

Answers (0)