cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a "hardcoded" value in a value attribute ?

diegohs
Active Participant
0 Kudos

Hi,

After a couple of days, I'm stucked.. =(

I create a value node in my controller context, then a value attribute inside my new node. I need to set the value to my new attribute but I always receive null error.

What could be wrong ? I'm practically new on this, I dont know if I need to "create" a instance, or modify a property or what.. =(

I appreciate your help, any clue is welcome..

Regards from Mexico.

Diego

Accepted Solutions (1)

Accepted Solutions (1)

diegohs
Active Participant
0 Kudos

I forgot to include some code:

Value Node: myNode

Value Attribute: myAttribute

I put this code in a custom method (not in doInit method):

wdContext.currentMyNodeElement().setMyAttribute("blah.");

Former Member
0 Kudos

Diego,

It seems that your node contains no elements, so call to wdContext.currentMyNodeElement() leads to NullPointerException. If it is the case, the do one of the following:

1. Set node cardinality to 1..1 (in case you need one element, not sure how 1..n works)

2. Create element(s) yourself:


final I<ControllerName>.IMyNodeElement element = wdContext.myNode().createMyNodeElement();
/* You may set attribute here */
element.setMyAttribute("blah."); 
wdContext.myNode().addElement(element);
/* You may set attribute as you do it now */
wdContext.currentMyNodeElement().setMyAttribute("blah.");

VS

diegohs
Active Participant
0 Kudos

Hi Valery,

Thanks a lot for your help, it solved my problem !! 😃

10 well obtained points... )

Regards,

Diego

Answers (0)