cancel
Showing results for 
Search instead for 
Did you mean: 

create and add element to Context Node of Component Controller

Former Member
0 Kudos

Hello,

in Component Controller I have the following Context Node:

RequestFindPerson

---ResponseFindPerson

------returnFindPerson

----


name

----


firstName

It's a Model Binding (EJB).

Now I want to create returnFindPerson-Node in a method of a View:

IReturnFindPersonElement returnFindPersonElement = wdThis.wdGetIncRecJcoCompController().wdGetContext().nodeReturnFindPerson().createAndAddReturnFindPersonElement();

But I get this exception

com.sap.tc.webdynpro.progmodel.context.ContextException: ModelElementList(IncRecJcoComp/IncRecJcoComp.RequestFindPerson.ResponseFindPerson.returnFindPerson): ModelObjectManager returned an unrelated object

How can I create a returnFindPerson-Node in the Component Controller Context?

Regards,

Armin

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Just open the context of your component controller and confirm that your returnFindPerson node type is mapped to a model class. If it is not mapped then try providing that mapping.

Regards,

Murtuza

Former Member
0 Kudos

If the view controller context is mapped to the component controller context, then just create the element in the view context. It will in fact be created in the mapping origin. Mapping does not copy elements but references them.

Armin

Former Member
0 Kudos

Hi Armin,

as I write above I have the following Context Node in Component Controller.

RequestFindPerson

---ResponseFindPerson

------returnFindPerson

----


name

----


firstName

This I mapped to my view and create an element:

IReturnFindPersonElement returnFindPersonElement = wdContext.nodeReturnFindPerson().createAndAddReturnFindPersonElement();

But I get this exception:

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(IncRecJcoComp/SelectedPersonsView.RequestFindPerson.ResponseFindPerson.returnFindPerson, class=de.td.increcjcoweb.increcjcoapp.comp.wdp.IPrivateSelectedPersonsView$IReturnFindPersonNode): cannot bind or add elements because the node has no valid parent

Regards,

Armin

Former Member
0 Kudos

Hi,

What is the cardinality of the parent node of ReturnFindPerson?

Does the parent exists?

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapparaj,

after I set the Collection Cardinality of the parent node to 1..1 I get this exception:

com.sap.tc.webdynpro.progmodel.context.ContextException: ModelElementList(IncRecJcoComp/IncRecJcoComp.RequestFindPerson.ResponseFindPerson.returnFindPerson): ModelObjectManager returned an unrelated object

Regards,

Armin

Former Member
0 Kudos

Hi,

For model object this should be filled by executing the model

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapparaj,

yes I do this first. But after that depending on the user actions I want to remove and add elements.

Removing is no problem. But how can I add elements?

Or is it better to execute the model and copy the elements in an extra node and work with this?

Regards,

Armin

Former Member
0 Kudos

Can you please tell if one of the parent nodes of "returnFindPerson" has singleton=false?

Armin

Former Member
0 Kudos

Hi Armin,

no alle parent nodes have singleton=true.

Regards,

Armin

Former Member
0 Kudos

Hi Armin,

Create Element for ReponseFindPerson like

Iprivate<View>.IResponseFindPersonElement ele = wdContext.createResponseFindPersonElement();

wdContext.nodeResponseFindPerson().addElement(ele);

Then, create element for your returnFindPerson and then add your elements so that you will not get any errors and the values will be added to the returnFindPerson node.

Iprivate<View>.IreturnFindPersonElement ele1 = wdContext.createreturnFindPersonElement();

ele1.setname("Name");

wdContext.nodereturnFindPerson().addElement(ele1);

Hope this helps,

Regards,

Nagarajan

Former Member
0 Kudos

Hello Nagarajan,

there are only these methods to create an IResponseFindPersonElement element:

IResponseFindPersonElement createResponseFindPersonElement(Response_IncRecImplLocal_findPerson model) and

IResponseFindPersonElement createAndAddResponseFindPersonElement()

To create an IReturnFindPersonElement element there are:

createReturnFindPersonElement(Person model)

and

IReturnFindPersonElement createAndAddReturnFindPersonElement()

My method actually looks like this:

public void onActionRemovePersonButtonPressed(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.sap.tc.webdynpro.progmodel.api.IWDNodeElement nodeElement )

{

//@@begin onActionRemovePersonButtonPressed(ServerEvent)

IInjuredPersonsElement injuredPersonsElement = (IInjuredPersonsElement) nodeElement;

IReturnFindPersonElement returnFindPersonElement = wdContext.nodeReturnFindPerson().createAndAddReturnFindPersonElement();

WDCopyService.copyCorresponding(injuredPersonsElement, returnFindPersonElement);

wdContext.nodeInjuredPersons().removeElement(injuredPersonsElement);

//@@end

}

Regards,

Armin

Former Member
0 Kudos

I added an other context node which I fill with the elements of the model object. Now I'm able to add elements.