cancel
Showing results for 
Search instead for 
Did you mean: 

Error.( java.lang.NullPointerException )

Former Member
0 Kudos

Hi

Experts

My code is


IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI.getComponentInfo().findInWindows("AddressbookWindow");

// create the “AddressbookWindow”
IWDWindow window = wdComponentAPI.getWindowManager().createWindow(windowInfo,true);

// set the WindowPosition on the screen
 window.setWindowPosition(300,150);
// and show the window
try{
wdContext.currentPopupElement().setWindowInstance(window);
}
catch(Exception E){
wdComponentAPI.getMessageManager().reportException(E.toString(),false);
}
window.open();

when trying to store window i am getting

java.lang.NullPointerException

error in catch.

Please Help Me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Sunny,

Check the name of the window. Its case sensitive.

Regards,

Rajit

Former Member
0 Kudos

Hi

Rajit

Error is not there.

I checked all the statements.

Error is in sentance which in try{} block.

Thanks.

Former Member
0 Kudos

Sunny,

Is the problem resolved then? Make sure there's atleast one element in the PopupNode or create an element and add it to the node.

Regards,

Rajit

Former Member
0 Kudos

Hi,

Can you describe your context structure wherein you are storing you window instance.

Regards,

Murtuza

Former Member
0 Kudos

Hi

Rajit & Murtuza.

there is already one element created in the PopupNode.

Structure of my context is

In context

one value node name is <b>Popup</b>

In this value node another value attribute <b>WindowInstance</b>.

type of it is com.sap.tc.webdynpro.services.session.api.IWDWindow.

Thanking you

Sunny.

Former Member
0 Kudos

Hi Sunny,

As you said that you have already instantiated an element of popup node so it should ideally not give an error.

But just to get a default element being provided by framework just change the cardinality of the popup node to 1:n instead of 0:n

Hope you added element to popup node like this:

IPrivate<viewname>.IPopupElement ele = wdContext.nodePopup().createPopupElement();

ele.setWindowInstance(<window instance>);

wdContext.nodePopup().addElement(ele);

Regards,

Murtuza

Former Member
0 Kudos

Hi kelly & murtuza

I just try and reply u.

At present what i do is i write window variable like

//@@begin others

IWDWindow window;

//@@end

Actually what happens is it finds the addressbook window from repository

but when coming back to original window it just display blank screen.

I make one mail window and one addressbook window.

If someone clink on addressbook on to option of mail window,

one small adressbook window get opend.

and when on adressbook window anyone click on button

it fires one event that is in component controller.

and i make it's event handler in the email window.

But problem is that at returning time it just give me blank screen.

Thanking you.

Sunny.

Answers (1)

Answers (1)

Former Member
0 Kudos

A general practice for building robust applications is to check the return values of methods that return null reference values before attempting to dereference. If the method returns null, it is much better practice to issue a warning rather than letting the application croak with a null pointer exception.

For example:

I

WDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI.getComponentInfo().findInWindows("AddressbookWindow");

if (windowInfo == null)  {
   wdComponentAPI.getMessageManager().reportWarning("Failed to get window info for AddressbookWindow");
}
else { << dereference windowInfo, etc. >> }

The javadoc I have for findInWindows unfortunately does not document its return values but I would assume it returns null if the specified window is not found.

Also, if you would post the stack trace, or the top part of it, we could better help you.

Regards,

Kelly