cancel
Showing results for 
Search instead for 
Did you mean: 

Null Pointer exception in Dropdownbyindex

Former Member
0 Kudos

Dear Forum,

I am using a dropdownbyindex to populate values from R/3.

My requiremnt is initially the dropdown will show emply field. The user will select a value and submit. But if the user does not select and submits, the UI is throwing a Nullpointer exception.

I can avoid the null value in dropdown by setting the selection as 1...1 ; but this is not serving the purpose of blank value initially.

Please help me asap.

Thanks and regards,

Mickey.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

This is because you have binded the DDB Index to a context attribute and you are accessing it in your code.

So please use this statement in your code

if(wdContext.currentContextElemem.getAttr1()!=null){

// your code

}

else {

wdComponentAPI.getMessageManager().reportException("Plesae select a value in the drop down");

}

Hope this helps,

Jithin

Edited by: jithin james on Mar 23, 2009 9:17 AM

Former Member
0 Kudos

Jithin,

Thanks for your reply. But before this code is executed, Null pointer exception is thrown.Also i have used model node to map data.

Do you need any more inputs from my side?

With Regards,

Mickey.

91-9830122905.

Former Member
0 Kudos

Hi,

Can u please post the code portion where you are getting this error.

jithin

Edited by: jithin james on Mar 23, 2009 9:38 AM

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

You can add empty row in your r/3 table. it is possible i have done it previously. For R/3 nodes the cardinality is 0..n initially. You need to do instantisate the node in component controller. please change the model node cardinality by 0..n & instansitiate the node in your component controller. your problem will be solved.

Best Regards

Ravi

Former Member
0 Kudos

Hello Everybody,

Thanks a lot for your suggestions. I solved the issue.

I made the UI property "setInitialized" to true which allowed the blank entry (provided by framework) to get displayed. Then I kept a check on null pointer exception where in it is mandatory for the user to enter a value to dropdown before submitting the form.

Thanks again,

Best regards,

Mickey.

Former Member
0 Kudos

Hi Mickey,

You can achive it by setting the selection as 1...1 and then before taking the data from R3 and adding it to dropdown what you can do is.

Create a String string blank ="";

and now assign this value to the node element. and now assign the vlaue from R3 to this node.

This will solve your problem.

Hope this will help

Regards

Narendra

Former Member
0 Kudos

Hi ..

you have to create VALUE NODE in component Context...and mapping Into VIEW context through open navigator model..

inputdrop----is the attribute name

SearchCriteria--Value node

In component implemation you have to put some code..in appropriaate method...

IWDAttributeInfo attrinfo=wdContext.nodeSearchCriteria().getNodeInfo().getAttribute("inputdrop");

ISimpleTypeModifiable msType=attrinfo.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet3=msType.getSVServices().getModifiableSimpleValueSet();

valueSet3.put("Plese choose");

for(int i=0;i< model node size;i++)

{

valueSet3.put(wdContext.node<model>().get<model>ElementAt(i).getAttributeAsText("your value in model as key",wdContext.node<model>().get<model>ElementAt(i).getAttributeAsText("your value in model as description")

}

wdContext.currentSearchCriteriaElement().setInputdrop("Please choose");

thanks..

sudhira

Edited by: sudhir kumar on Mar 23, 2009 10:44 AM

Former Member
0 Kudos

Hi,

Which line you exactly get the Null Pointer?

Regards,

Daniel

Former Member
0 Kudos

Hi,

Please post the trace of the error

Check in your code for a call to the metthod "currentContextElement" of the respective node and make sure that you check for the null before calling this method.

Ex:


if(!wdContext.nodeEmployees().isEmpty()) // Employee is the node Name
		  id = wdContext.currentEmployeesElement().getEmpID()

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Mickey,

Please check the value of the dropdown field & if it is not null then call the code in onAction method of Submit button.

Kind Regards,

Nitin

PS: I feel your application logic should handle it in a more efficient manner than to check for null values.

You may enable the submit button only if the dropdown is filled (associate a label & mark it as mandatory), and in onSelect method of dropdown, make the submit button enabled.

Edited by: Nitin Jain on Mar 23, 2009 9:19 AM

former_member185086
Active Contributor
0 Kudos

Hi

Just it require a null check then only retrieve the value from dropdown

if(Wdcontext.currentContextElemem.getValue !=null)
{

//code 

}

Other solution is populate the value form R/3 in Dropdown (only if it is less than 50), else use EVS for better functionality(Default filter is there for large body data say 100-150),

Best Regards

Satish Kumar