cancel
Showing results for 
Search instead for 
Did you mean: 

How to add new values in the elements in the context node

Former Member
0 Kudos

Hi,

i have to add new values through UI i.e giving input through views.

I have a context node CAR having sub node engine and owner.

Engine node consist of Rpm,Bhp as value attribute

Owner node consist of name,phnno as value attribute

Now i have to take input from some view and store that values in the node and sub node.

pls guide

Thanks & Regards

Pravin Jha

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

HI

make the cardinality of the nodes to 1..n

and write this piece of code

String carName=wdContext.nodeCar().currentCarElement().getCarname();

String carNumber=wdContext.nodeCar().currentCarElement().getCarnum();

String Rpm=wdContext.nodeEngine().currentEngineElement().getRpm();

String Bpm=wdContext.nodeEngine().currentEngineElement().getBpm();

String name=wdContext.nodeOwner().currentOwnerElement().getName();

String phoneNumber=wdContext.nodeOwner().currentOwnerElement().getPhoneno();

IPrivateDemoGraphCompView.ICarElement carElement=wdContext.nodeCar().createCarElement();

carElement.setCarname(carName);

carElement.setCarnum(carNumber);

wdContext.nodeCar().addElement(carElement);

IPrivateDemoGraphCompView.IEngineElement engine =wdContext.nodeEngine().createEngineElement();

engine.setBpm(Rpm);

engine.setRpm(Bpm);

wdContext.nodeEngine().addElement(engine);

IPrivateDemoGraphCompView.IOwnerElement owner =wdContext.nodeOwner().createOwnerElement();

owner.setName(name);

owner.setPhoneno(phoneNumber);

wdContext.nodeOwner().addElement(owner);

gill367
Active Contributor
0 Kudos

Hi Parveen,

To add new elements from the input fields to the attributes of the desired nodes, use the following code.

this code is written in the eventhandler of a click event of the button.

public void onActionSubmitDetails(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionSubmitDetails(ServerEvent)
    String Name = wdContext.currentContextElement().getNameInput(); // bind these attributes to the input fields
	String PhoneNo = wdContext.currentContextElement().getPhoneNoInput();// bind these attributes to the input fields
	String Bhp = wdContext.currentContextElement().getBhpInput();// bind these attributes to the input fields
	String Rpm = wdContext.currentContextElement().getRpmInput();// bind these attributes to the input fields
	
	IPrivateTableTestView.ICARElement Car_el = wdContext.createCARElement();
	wdContext.nodeCAR().addElement(Car_el);
	
	IPrivateTableTestView.IOwnerElement ownerElement = wdContext.createOwnerElement();
	ownerElement.setName(Name);
	ownerElement.setPhoneNo(PhoneNo);
	wdContext.nodeOwner().addElement(ownerElement);
	
	IPrivateTableTestView.IEngineElement engineElement = wdContext.createEngineElement();
	engineElement.setBhp(Bhp);
	engineElement.setRpm(Rpm);
	wdContext.nodeEngine().addElement(engineElement);
	
	
    //@@end
  }

let me know if you still have any issue.

Sarbjeet Singh.

Former Member
0 Kudos

Please post the exact context structure, including cardinalities and singleton-properties.

Armin

Former Member
0 Kudos

Hi Pravin Jha,

Try this code.

IPrivate<View name>.IN_LabelElement ele = wdContext.createN_LabelElement();

ele.setA_label("Label Name");

wdContext.nodeN_Label().addElement(ele);

IPrivate<View name>.IEngineElement engineEle = wdContext.createEngineElement();

engineEle.setBhp("BHP value");

engineEle.setRpm("RPM value");

IPrivate<View name>.IOwnerElement ownerEle = wdContext.createOwnerElement();

ownerEle.setName("Owner name");

ownerEle.setPhnno("Owner Phone no");

wdContext.nodeEngine().addElement(engineEle);

wdContext.nodeOwner().addElement(ownerEle);

Let me know if you need any clarification

Regards,

Jaya.