on 04-01-2009 5:26 PM
Hi All,
I get a null pointer exception when trying to run my web dynpro app, here are the details:
java.lang.NullPointerException
at com.sap.tc.webdynpro.progmodel.context.MappedNodeElement.wdGetObject(MappedNodeElement.java:350)
at com.sap.tc.webdynpro.progmodel.context.NodeElement.getAttributeAsText(NodeElement.java:888)
Here is the code in component controller
public void wdDoInit()
{
//@@begin wdDoInit()
subjAreaInput = new Zep_Get_Infoprovider_Status_Input();
wdContext.nodeZep_Get_Infoprovider_Status_Input().bind(subjAreaInput);
executeSubjAreaInput();
//@@end
}
public void executeSubjAreaInput( )
{
//@@begin executeSubjAreaInput()
try
{
subjAreaInput.execute();
wdContext.nodeOutputSubjArea().invalidate();
}
catch(Exception e)
{
e.printStackTrace();
}
//@@end
}
Here is the line where the code fails:
public void setDescriptions( )
{
//@@begin setDescriptions()
int elemCount = wdContext.nodeZep_Ent_Subj_Status().size();
if( elemCount > 0 ) //elemCount is 7, I have verified this
{
for( int i=0; i<elemCount; i++)
{
// code fails at this line with the above exception
String compare = wdContext.nodeZep_Ent_Subj_Status().getElementAt(i).getAttributeAsText("SUBJECT_AREA");
}
}
}
Please help!! I've been trying to debug for 2 days now!!
Thanks
TM
I figured it out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i think your executing the model and your invalidating the output node so that when your trying to get the value from the node or sub node available under the output will return nothing right because it is already invalidated, i thnnk you need to write this line before executing the model right. wdContext.nodeOutputSubjArea().invalidate();
try
{
subjAreaInput.execute();
wdContext.nodeOutputSubjArea().invalidate();
}
if you varified that node size, then there may be problem with this line
String compare = wdContext.nodeZep_Ent_Subj_Status().getElementAt(i).getAttributeAsText("SUBJECT_AREA");
it means nothing, i think you are trying to get the value of a field at a ith position row right
please use this code insted of your's
String compare = wdContext.nodeZep_Ent_Subj_Status().getElementAt(i).getAttributeValue("SUBJECT_AREA");
may be it help you
Cheers,
Appu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Apparao,
You always call the invalidate method after calling the execute method. The invalidate method synchronises the context model nodes with what is in the actual model itself.
Secondly, I cannot use the method getAttributeValue as the return type for this method is an Object and not a string. getAttributeAsText returns the desired String object.
Any other suggestions? Anyone?
As a test, I quickly created a Table UI and mapped it to the outputNode nodeZep_Ent_Subj_Status.
All the values returned show up in the table fine. This is what is making it so difficult to narrow the null pointer exception.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.