cancel
Showing results for 
Search instead for 
Did you mean: 

Exception thrown at modifyView

Former Member
0 Kudos

Hi Experts,

I am getting the following exception

java.lang.NullPointerException

when i try to execute the following code:

int i = wdContext.nodeOutput().currentOutputElement().getO_Text().length();

Can anybody please help me solve this

Regards,

Abdullah

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

answered

former_member189631
Active Contributor
0 Kudos

Abdulla,

Please check these,

  • Ensure that your node/attribute is null

  • You can write the code inside the exception block.

Regards,

<b>Ramganesan K</b>

Former Member
0 Kudos

are you sure that that the RFC is not returning any values?

Did you print that and check?

AM

Former Member
0 Kudos

if ur RFC is not returning the values.., that is the reason

Former Member
0 Kudos

Hi Anoop

In the backend it is returning values.

The code in my controller is


 public void Bapi_GetList( )
  {
    //@@begin Bapi_GetList()
	try
		{
		//	   Calls remote function module
		wdContext.currentBapi_Birthday_Getlist_InputElement().modelObject().execute();
		wdContext.nodeOutput().invalidate();
		}
	catch (Exception ex)
		{
		//	   If an exception is thrown, then the stack trace will be printed
		ex.printStackTrace();
		}
    //@@end
  }

i am even binding the input in the doInit of the Controller. This method Bapi_Execute is being called from my view.

Regards

Abdullah

abhijeet_mukkawar
Active Contributor
0 Kudos

re-import models and restart J2EE server.

regards

Former Member
0 Kudos

Thanks Abhijeet,

will restart and check. Thats gonna take some time.

Regards

Abdullah

Former Member
0 Kudos

Hi ,

Maybe there is an error or some mandatory parameter not set..

catch (Exception ex)
		{
		//	   printstacktrace would not give you the output in ur browser console.. so //.. use this
		wdComponentAPI.getMessageManager().reportWarning(e.getCause());
		}

See if its error free.. If there is still no data.. Maybe u r input does not produce any result as per the RFC..

So you need to check.. if

i

f(wdContext.node<nodename>().size() > 0 )
//then access the current element.. other wise skip it.. 

Regards

Bharathwaj..

Former Member
0 Kudos

Hi,

Why do you invalidate the 'Output' node after executing the model?

That's the reason for the NullPointerException. Invalidate before executing the model.

Hope it helps.

Regards,

M.Subathra

Former Member
0 Kudos

put all the code in domodify view in try catch..

put a print statement before int i = wdContext.nodeOutput().currentOutputElement().getO_Text().length();

like wdThis,wdgetapi.getcomponet.getmessagemanager.reportsuccess()wdContext.nodeOutput().currentOutputElement().getO_Text());

and check teh value that u are getting...

AM

abhijeet_mukkawar
Active Contributor
0 Kudos

Abdullah,

here ,

<i>

int i = wdContext.nodeOutput().currentOutputElement().getO_Text().length();</i>

only one thing can be ,

The Output element must not be created , better thing is make the cardinality to 1.1 or 1.n.

and why are you writing this code in WdDoModify(), it is certainly not preferable

hope it helps

regards

Former Member
0 Kudos

Hi,

nodeOutput().currentOutputElement(). is a node element that u get after executing one RFC.

Might be doModifyview is been called befor eyou execute the RFC and store all the information in the particular noew..

Yoy try to exceute the method in doint itself so that you dont get this error

Thanks

AM

Former Member
0 Kudos

Hi Anoop,

the rfc is called before this method is being called and

according to Abhijeets suggestion,

The cardinality is 1..n

I debugged again and saw that the BAPI is not returning values. I had recently made changes in the BAPI. Can that have caused this to happen?

Although the input and output structure remains same

Regards

Abdullah

Message was edited by:

Abdullah Ismail

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

after changing bapi , if it is not returning the values then that is a cause.

okay, have you re-imported models and restarted J2EE server?

do it

hope it helps

regards

Former Member
0 Kudos

Hi ,

Ensure that the Output element is created before accessing it as current element.

Or make the cardinality as 1..n and work on it.

You are trying to access the leadselected element .. but there is none created in the node. so it returns a null and hence a nullpointer exception..

And do search forum for similar queries.. !

Regards

Bharathwaj