cancel
Showing results for 
Search instead for 
Did you mean: 

How to do Dynamic attribute binding.

konchada_saikrishna
Active Participant
0 Kudos

Hello Experts,

I struck up with a small Issue, can any one help me.

My scenario is ..

In a View I am creating attributes and text boxs dynamically in the do modify method, also same fields in component controller dynamically.

I need to access these fields in component controller.

for which I need to bind view attributes to the component controller attributes dynamically, how to do this.

Help me please,

Thanks in advance,

Sai.k.k

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hai

dynamically creating context node and attributes

// you can write this code in wddoinit

IWDNodeInfo node=wdContext.getNodeInfo().addChild("DynamicNode",null,true,true,false,false,false,true,null,null,null);

node.addAttribute("Name","com.sap.dictionary.string");

bind it to ui eelement

//done in wddomodify() method only

IWDInputField field1=(IWDInputField)view.createElement(IWDInputField.class,"InputField1");

field1.bindValue("DynamicNode.Name");

Regards,

Naga

konchada_saikrishna
Active Participant
0 Kudos

Hi Naga raju,

Actually I done ui element binding,

I need to bind / map this attribute to the dynamically created component controller's value attribute in a node.

Regards,

Sai.k.k

Former Member
0 Kudos

Hai,

IWDNodeInfo NodeInfo = wdContext.getNodeInfo().addMappedChild("NewNode",null,true,true,false,null,false,true);

IWDNodeInfo nodeInfo = wdThis.XXController().wdGetContext().getNodeInfo().getChild("DynamicNode");

NodeInfo.setMapping(nodeInfo ,true);

see this

Regards,

Naga

konchada_saikrishna
Active Participant
0 Kudos

Hi Naga raju,

here is my code, still getting error.

<b>

IWDNodeInfo ccparent = wdThis.Employee_ComponentController().wdGetContext().nodeEmployee().getNodeInfo(); // Component Controller's

WDNodeInfo parent = wdContext.getNodeInfo().addMappedChild("Employee",null,true,true,false,null,false,true); //view controller's

IWDAttributeInfo ccchild = ccparent.addAttribute(resourceHandler.getString("FIELD"i"_FIELDNAME"),"com.sap.dictionary."resourceHandler.getString("FIELD"i+"_DATATYPE"));

IWDAttributeInfo child = parent.addMappedAttribute(resourceHandler.getString("FIELD"i"_FIELDNAME"),".Employee_Component.Employee."resourceHandler.getString("FIELD"i+"_FIELDNAME"));

</b>

This is the error I am getting :

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(Employee_TabsView.Employee.Name): must not modify the datatype of a mapped attribute

Is this is due to that I am using EVS to the fields in view.

Regards,

Sai.k.k.

Answers (2)

Answers (2)

konchada_saikrishna
Active Participant
0 Kudos

Thanks for all your helpful replies.

Former Member
0 Kudos

Konchada,

1. Create attributes dynamically in component controller

2. Create <u>mapped</u> attributes dynamically in view controller. Map them to attributes in component controller.

3. Add text boxes in wdDoModify, bind them to mapped attributes.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

konchada_saikrishna
Active Participant
0 Kudos

Hi Valery,

1 have done.

3 have done it.

2 nd, how to create a mapped attribute.

note : I am creating dynamic attributes for component controller in view controller's modify method.

Regards,

Sai.k.k

Former Member
0 Kudos

Hi ,


public IWDNodeInfo addMappedChild(String name,
                                  Class elementClass,
                                  boolean singleton,
                                  boolean mandatorySelection,
                                  boolean multipleSelection,
                                  String mappedPath,
                                  boolean selectionMapped,
                                  boolean initializeLeadSelection)

//mappedPath - componentname.name of the parent node
//elementClass - null

Regards

Bharathwaj

Message was edited by:

Bharathwaj

Former Member
0 Kudos

See reply from Naga: