cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to set values in a model node with cardiniality 0..1

Former Member
0 Kudos

Hi

I have mapped my model node onto my view controller. When I trying to set the values in the attribute of the model node I am not able to do it.

My model node context is like this:

NodeA

|-NodeB

|-NodeC

|-Item1

|-Item2

|-Item3

The properties for Context Node A are:

Cardinality : 0...n

Collection Type: list

initialleadselection:true

selection:0..1

singleton: true

typedaccessrequired: true

The properties of Node B are:

Cardinality : 0...1

Collection Type: list

initialleadselection:true

singleton: true

selection:0..1

typedaccessrequired: true

The properties of Node C are:

Cardinality : 0...n

Collection Type: list

initialleadselection:true

singleton: true

selection:0..1

typedaccessrequired: true

This is the code I am using in my View controller to set the attribute for the model node.

IPrivate<name>View.I<nodeC>Element element = wdContext.create<nodeC)Element(new ComplexType_nodeB());

element.setItem1("test");

element.setItem2("0001");

wdContext.node<nodeC>().addElement(element);

Can any body please let me know where I am going wrong ? Its kind of urgent!!!

Thanks & Regards

--Vishal

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

I am having the same problem. The web service I am calling is the BI Query webservice

http://<bisystem>/sap/bw/xml/soap/queryview?wsdl

The web service returns complex types. I have confirmed that the data is successfully returned in the SOAP message, but the 6th node deep in the structure has a size of 0, but it should have a size>0. (This context node is mapped to the Item Model (class RrwsSxTuple).)

I have tried instantiating all of the classes in the hierarchy, but I still see that the size of the Item node (6 levels deep) is 0.

I have tried:

-Instantiating the classes

-Setting the child class to the parent class

Questions:

1. Should I ever have to bind a lower level model object to the context node (or is the bind of the request object sufficient)?

2. Should I ever have to invalidate at a lower level than the Response?

3. Do you have any other suggestions for troubleshooting?

Thanks!

Deb Kreider

Former Member
0 Kudos

HI,

Follow Maksim Rashchynski's suggestion.

this problem usually comes when we have nested nodes with complex types.

With out instantiating the parent nodes u cannot set value of thier child nodes.

i,e if u want to set values to node B, first instantiate node A.

Regards,

Satya.

former_member193726
Active Participant
0 Kudos

Hi Vishal,

As per my understanding you are trying to populate values for attributes under your model node.

Vishal, can you try this simple code for me in your view's wdDoInit() method?. I am sure it works.

String[] sport = new String[]{"Atheletics", "Marathon", "Hockey", "Cricket"};

List sports = new ArrayList();

for(int i = 0; i < sport.length; ++i) {

IPrivate<<ViewName>>.INodeAElement nodeA = wdContext.createNodeAlement();

nodeA.setItem1(sport<i>);

sports.add(nodeA);

}

wdContext.nodeNodeA().bind(sports);

Hope this helps.

Regards,

Rekha Malavathu

Former Member
0 Kudos

Hi All

Can any one , tell me wats the final conclusion for the above discussed issue,

Since , currently iam facing the similar problem , where from WSDL i mapped the context element.....

as my inner node cardinality is on 0...N , i am not able to set the value to attributes

the ERRROR, i get on setting the Value attribute was :java.lang.NullPointerException

it would be really great ,if some one can point out the conclusion of the above discussion.

My Node Struture

CONTEXT

--Request__SubmitRequest

-


===RequestDetails [modelnode]

-


===Roles [modelnode] cardinality : 0..n

-


===+++++ RoleId [Model Attribute]

-


===+++++ SysId [Model Attribute]

i tried following ways to set the value:
	wdContext.nodeRequest__SubmitRequest().nodeRequestDetails().nodeRoles().
		currentRolesElement().setRoleId("BASIC");
	wdContext.nodeRequest__SubmitRequest().nodeRequestDetails().nodeRoles().
		currentRolesElement().setSysId("R3_220");

Former Member
0 Kudos

HI,

yes, u will get a null pointer exception as the parent node has not been instantiated and u are using 'currenElement'.

we cannot change the cardinality of the subnodes so, instantiate explicitly

Follow Maksim Rashchynski's suggestion.

Regards,

Satya.

Former Member
0 Kudos

Hi Vishal,

The Cardinality for the input Field is 1..1 or 0..1. Please make the change and bind the values like

wdContext.currentNodeCElement.setItem1("test");

wdContext.currentNodeCElement.setItem2("0001");

//execute

kind Regards

Mukehs

Former Member
0 Kudos

Hi,

The context node of the view controller is a model node. It has been mapped from the model to the view controller.

I really don't know whether we change the cardinality of a model node because that comes from the Web services.

If there is a way can anybody please let me know how to do it?

--Vishal

former_member182372
Active Contributor
0 Kudos

Vishal, did you try my suggestion?

Former Member
0 Kudos

Hi Maksim,

I tried going through your suggestion, but can you provide me some more detail for it?

--Vishal

Former Member
0 Kudos

Hi,

You shouldn't change the cardinality of the model node(from WebService). you have to change the node which is mapped to the model node during the template selection process (Relate Context Attributes).

set cardinality :1..1

but using this value you cannot set values for atributes like,

IPrivate<name>View.I<nodeC>Element element = wdContext.create<nodeC>Element(new ComplexType_nodeB());

element.setItem1("test");

element.setItem2("0001");

you can use the following,

wdContext.current<nodeC>Element.setItem1("test");

wdContext.current<nodeC>Element.setItem2("0001");

Best regards,

Former Member
0 Kudos

Hi Vishal,

Try This

IPrivateTestComp.ICNode node=wdContext.nodeC();

IPrivateTestComp.ICElement element=wdContext.createCElement();

element.setItem1("item1");

element.setItem2("item2");

node.addElement(element);

Kind Regards

Mukesh

former_member182372
Active Contributor
0 Kudos

Hi Vishal,

As you said, you have mapped the model to your model node context

NodeA

|-NodeB

|-NodeC

|-Item1

|-Item2

|-Item3

So, you have model class for NodeA (lets say ClassA), for NodeB (ClassB), for NodeC (ClassC).

So, you have to do following:

ClassA classa = new ClassA();

ClassB classb = new ClassB();

ClassC classc = new ClassC();

classa.setClassB(classb);

classa.setClassC(classc);

wdContext.nodeNodeA().bind(classa);

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hai ,

Try to change the property of node b and node c , singleton=false;

regards,

naga raju

Former Member
0 Kudos

Hi Vishal,

set the properties of Node C like

Cardinality : 1..1

selection:0..1

Hope this will help you.

regards

karthik

former_member182372
Active Contributor
0 Kudos

Hi Vishal,

You should do following:

1) create instance of model wuch is bound to NodeA

2) create instance of model wuch is bound to NodeC and add it to first created instance

3) call wdContext.node<nodeA>().bind(instance from p.1)

Best regards, Maksim Rashchynski.