cancel
Showing results for 
Search instead for 
Did you mean: 

Interface Controller Issue

Former Member
0 Kudos

Hi,

My scenario is that i am passing data between 2 components of an application via Context Nodes (Not via Plugs).

I have done all the required steps, but somehow keep on getting Null Pointer Exception.

After doing createComponent() in Comp1, i have to set the value of the elements of the context node of component controller which has been mapped to the context node of interface controller(inputElement = true).

I get null pointer, when i use current<><Node>Element().set<>

I checked out the forum and found some posts, some said that this is a bug in Web Dynpro and in some cases i could not find the solution working in my benefit.

Please let me know.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

It may be that there is no current selection. In that case there is no current element.

Try to set the lead selection (eg setLeadSelection(0)) of the node that contains the element first.

If that solves the problem, this is probably the cause.

Good luck,

Roelof

Former Member
0 Kudos

Thank you for your prompt reply guyz, but i guess my issue was not clear enough.

I am passign data between 2 components via Inetrface Controllers/Interface Views.

As we know, this requires a ComponentUsage of the used component to be instantiated in the using component.

I instantiated that with usage.createComponent().

Now, i need to access my node to set the value its elements. This node has been defined in Interface Controller with isInputElement property as TRUE.

When i say wdThis.wdGet<Controller>.wdGetContext().

currentNodeElement().setvalue()

it says NULL POinter Exception

and when i try to use

wdThis.wdGet<Controller>.wdGetContext().createNodeElement()

it says "No mapping defined yet" although all the mappings have been defined....

sridhar_k2
Active Contributor
0 Kudos

Hi Bharati,

Communication Between Components is working for me. I could assign values to them, even i can get the values from those fields also.

I followed in this way.

I Created Two Components Comp1,Comp2.

In the Comp2 -> Context I Created a Node -> a Attribute.

Create a link between Interface Controller and Comp2 Controller and required Attributes.

In Comp1 -> In the Used Web Dynpro Components -> Embed Compnent -> Selected the Comp2.

From Comp1 (View / Controler)-> Make a link to Added interface Controller and required Nodes (TestNode - TestStr ).

Setting Value (From View -> Comp1)

ITestNodeElement app = wdThis.wdGetComp1().wdGetContext().createTestNodeElement();

app.setTestStr("Hello");

Getting Value

app.getTestStr();

Hope this lengthy solution solved your problem.

Regards,

Sridhar

Former Member
0 Kudos

Hi Shridhar,

Can you zip your application and send me at:

dbharti AT gmail DOT com

It will ne helpful as i have done the same thing but it keeps on thrwoing exception to me.

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

Can u set the cardinality of the node to 1:n

and then write the code.

Regards,

Vijayakhanna Raman

Former Member
0 Kudos

Vijay,

Same exception occurs...

sridhar_k2
Active Contributor
0 Kudos

Hi,

I have one doubt in your code. Have u created NodeElement? You are directly accessing NodeElement.

"currentNodeElement().setvalue()"

Try to replace with this code.

ITestNodeElement app = wdThis.wdGetComp1().wdGetContext().currentNodeElement();

app.setValue("Hello");

Can you please check that peice of code??

Regards,

Sridhar

Former Member
0 Kudos

Devashish,

To summarize:

1. Ensure that node cardinality is 1..1 or 1..n or there is a supply function that populates node automatically.

2. Ensure that selection cardinality is 1..1, 1..n or initializeLeadSelection=true.

If nothing helps, do the following trick:

1. In child component interface controller create empty method, say "void init(){}"

2. In parent component first call wdThis.wdGet<InterfaceUsageName>.init()

3. Only then access context of child component.

If this works, I can explain "why" later.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi,

I solved the issue...

You all were right and i had folowed the same sequence..

The issue was that i had used "Manual" while creating component usage... when i changed it to "Create on Demand" and commented out the ComponentUsage Portion, it worked perfectly well....

I don't know how come this happened, as in all the PDFs i referred, "Create on Demand" was never used....

Anyway, thnx to all

Former Member
0 Kudos

Hi devashish

Just for check please find out if you are creating an element of that element and then try setting values to the current element.

Thanks and regards

Kapil S Kamble