cancel
Showing results for 
Search instead for 
Did you mean: 

Problems working with context

Former Member
0 Kudos

Hello!! I'm creating some views, but I'm getting the following message:

java.lang.NullPointerException

at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter.isLoadOnDemand(AbstractAdapter.java:1038)

at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.DropDownByKeyAdapter.getCOMBOBOXBEFORELISTLOADEvent(DropDownByKeyAdapter.java:651)

at com.sap.tc.ur.renderer.ie6.ComboBoxRenderer.renderComboBoxFragment(ComboBoxRenderer.java:475)

at com.sap.tc.ur.renderer.ie6.ComboBoxRenderer.render(ComboBoxRenderer.java:97)

I'm using webdynpro components for java. And as SAP help suggested, I created a data component. This is the mapped context that i'm using in the view fileds.

Another problem that I get is that the context (with cardinality 1..1) doesn't initialize, leading to another null pointer exception

In other hand, if I don't use the data component context, then the application works fine!!

At first I thought the problem could have as origin a wrong use of components' create on demand option. But is not that, because I have others views that work fine.

I'd really apretiate any help!!

Thanks a lot

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Ok, I solved the problem... as I was thinking I missed somenthing during the componentization.

The thing is that I wasn'r sharing the data node. At least not to the same instance of the component I was trying to access the attribute from.

The solution was to add the sharing code in the init of the parent component and that was it!!

Thanks a lot for your anwsers...

Anyway, the way I was thinking it was ok, you don't need to initialize any 1..1 context node!! and you can map a dropdown key to an attribute inside that 1..1 node with no problems at all, even if has no values for it!!

Thanks again!! I'll give some point for the anwser anyway!!

Former Member
0 Kudos

Yes... you are completly right! At first the attribute is null. That's my question, why should I initialize any attributes if they're below 1..1 cardinalities nodes??

Moreover, if I don't mapp the attribute in my view to the data component, it works fine!! I'm working with a non mapped version now and trying all, but I will need to map it.

I have other nodes in other components that are mapped to the data and they're working fine... I think i could've missed somenthig, but I checked many times, so I don't know what the problem could be.

Now I'm thinking that it has something to do with the edition of the context mapping, but it should work if the option exists doesn't it?

Former Member
0 Kudos

Hello Alejando,

the attribute is below 1..1 cardinality node but the value of the attribute is null. Node cardinality 1..1 means the node has one element, but the value of the attributes of the element has "their own default values".

For example, imagine one table with one row. Table is not empty becouse it has one row, but the fields of the row are null the first time.

Normally there is no problem with this (only remember to check not null before try to access to some method) but, for dropdowns, if you have mapped them to a context node or attribute "standard coding doesn't check if the attribute is null" so it crash when it tries to get the values for fill the dropdown.

As I see you should assing some value to the attribute in the wdInit() method or map the dropdown to a node 0..N.

Regards

Former Member
0 Kudos

Hello Alejandro,

I'm getting a litle bit lost. As I know a DropDownByIndex should be mapped to a context node or an enumerated attribute.

At first time your DestinoPais is null so DropDwonByIndex is can't be initialized.

Try with a enumerated attribute for testing or just initialize the attribute to some value in the wdInit() method.

When you get your model working use a context node for DropDown (you can fill DestinoPais value with the corresponding element selected of the "dropdown node").

Hope it helps

Former Member
0 Kudos

The problem is not with the dropdown list... the ettribute bounded is string and i'm not populating it with data yet.

If i don't map the attribute to the data component, the problem is solved and i don't have any problem. But i need it connected to the data of course!! and that's when the problem shows up.

It not only happens with the dropdown list, but with all the attributes.

Former Member
0 Kudos

It is not a model node, because of the way I'm implementing it.

In the future, I'll create the model context nodes and copy the data into the nodes i'm working with.

There's no data yet... that's why I think is a problem with the context mapping or something like that

Thanks for the anwser by now

Former Member
0 Kudos

Actually, there's still no data to populate the drop down list

the context mapping is as follows:

DataComponent:

Context

....|- DatosGeneralesViaje (node 1..1)

........|- DatosSolicitud (node 1..1)

............|- OtrosDestinos (node 0..n)

............|- DestinoPais (attribute) <-- This is the one bounded to the ui element

I have a similar structure in the interface of the component and the components that uses the data component.

the mapping would be:

DataComponent <- DataComponentInterface <- DatosGeneralesComponent <- DatosGeneralesView

the problem occurs when i try to map the context between: DataComponentInterface and DatosGeneralesComponent

I also have some others fields, but they're with the same caracteristics and problem.

Moreover, I also have some input fields that depend on attributes at the same level and they're disabled because they're null. When in my code i try to set some of those attributes, it says that the parent context node is null... and i could be able to check it running the debugger, is somenthing missing??

monalisa_biswal
Contributor
0 Kudos

Is this node a model node?

If it is a model node then you have to bind model node to model class instance.

Former Member
0 Kudos

As you are using a DropDownByKey element: what is the data type of the context attribute "DestinoPais"? Does it have a value set?

Armin

Former Member
0 Kudos

Please post the structure of the context (incl. mapping), how you have bound the dropdown list and how the context is populated with data.

Armin