Maximo Wire - The IBM Maximo Help & Discussion Forum
May 24, 2012, 12:24:57 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to Maximo Wire, the IBM Maximo help forum. Feel free to register and ask any Maximo related questions you like.
 
  Home Help Search Login Register  
*
Pages: [1]   Go Down
  Print  
Author Topic: To Set a value to an attribute of child object from parent class file  (Read 585 times)
0 Members and 2 Guests are viewing this topic.
Dileep Kumar
Newbie
*

Karma: 0
Posts: 26


View Profile Email
« on: January 24, 2012, 05:06:07 am »

Hai all

1) I am trying to set a value to my attribute of child object from parent class file . but it is throwing a message that null pointer exception i want to know the reason for this .

The below code is throwing an error

1) MboSetRemote mboset=getMboSet("$req","tablename","id=:id");
2) mboRemote mbo=mboset.getMbo();
3) mbo.setValue("name","mynewvalue",11L);

But the below  code is working fine .. i want the difference between two


1) MboSetRemote mboset=getMboSet("$req","tablename","id=:id");
2) mboRemote mbo=mboset.add();     // why we need to call add() method ? 
3) mbo.setValue("name","mynewvalue",11L);
Logged
kvnaresh
Newbie
*

Karma: 0
Posts: 11


View Profile
« Reply #1 on: January 29, 2012, 11:10:31 pm »

hi dileep,
                MboSet is a result set, so it has more that one record in it. while fetching the Mbo we should specify which record we want. Generally if we know that there's only one record in the mboset (generally from child mbo there will be only one parent mbo) we use
         mboset.getMbo(0);
     
        In your first piece of code you are saying
          mboset.getMbo(); //which record should it fetch ??
        no record is being fetched, so it gives null pointer exception.

       In your second peice of code you are add() will always returns a new record, so it works fine.

         
Logged
Dileep Kumar
Newbie
*

Karma: 0
Posts: 26


View Profile Email
« Reply #2 on: January 30, 2012, 09:31:36 am »

thank you naresh
Logged
reyonireyoni
Newbie
*

Karma: 0
Posts: 1


save trees


View Profile Email
« Reply #3 on: January 31, 2012, 10:28:56 am »

this could be possible through constructor and it is initiated automatically whenever object is created.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Recent

TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!