cancel
Showing results for 
Search instead for 
Did you mean: 

where to initialize the java objects

Former Member
0 Kudos

HI All,

when I run webdynpro application first time thejava objects are not instatiating (java objects may be have database operation) .I am instatiating the java objects in the following section

/*

  • The following code section can be used for any Java code that is

  • not to be visible to other controllers/views or that contains constructs

  • currently not supported directly by Web Dynpro (such as inner classes or

  • member variables etc.). </p>

*

  • Note: The content of this section is in no way managed/controlled

  • by the Web Dynpro Designtime or the Web Dynpro Runtime.

*/

//@@begin others

com.sap.service.dao.UserDAO userdao = new com.sap.service.dao.impl.UserDAOImpl();

//@@end

The problem is if I run application first time not getting any data from java classes.If I refresh or click on other application link or action then only java objects are instatiating.

where actully we have to instantiate the Java Object in WDInit() method or java section of webdynpro.

please help.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mohammad,

Initialize your Java objects inside view's init method if those objects are only useful to that view. But, if you want to initialize thse objects before any view calls then you have to initialize your objects in Component controller's init method.

Regards,

Bhavik

Former Member
0 Kudos

Hi Mohammad,

You can initialize your java object too in your wdDoIniti() method.

Declare your object in the others section like

com.sap.service.dao.UserDAO userdao = null;

Then inside your wdDoInit() you can instantiate it like

userDAO = new com.sap.service.dao.UserDAO();

Hope this helps,

Best Regards,

Nibu.