cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic binding attributes to inputfields

Former Member
0 Kudos

Hello,

Im trying to fill an UI dynamically. I've created a layout with mostly Inputfields with propert id'sn. Now i try in the wdDoModifyView to create a node with appropriate attributes to fill the inputfields. Im doing:


if(firstTime)
    {
	//create an APNode under which all the ap specific fields are gonna be created
	IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("APNode",null,true,true,false,false,false,true,null,null,null);
	//create a attribute invoice under apNode
	IWDAttributeInfo info = wdContext.getChildNode("APNode",IWDNode.LEAD_SELECTION).getNodeInfo().addAttribute("invoice","ddic:com.sap.dictionary.string");
	//get the field and bind it to the attribute just created
	IWDInputField field = (IWDInputField)view.getElement("invoiceInputField");
	field.bindValue(info);
	//fill the attribute with mock data
	IWDNodeElement dynEle = wdContext.getChildNode("APNode",IWDNode.LEAD_SELECTION).createElement();
	dynEle.setAttributeValue("invoice", "1234545");
    }

But the invoice number isnt shown in my invoiceInputField. There is an inputfield with and id "invoiceInputField" btw.

Can anyone tell me what im doing wrong?

much thanks,

Hugo

Accepted Solutions (1)

Accepted Solutions (1)

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

1)Create the node and attribute in the initmethod

IWDNodeInfo n= wdContext.getNodeInfo().addChild("APNode",null,true,true,true,false,true,true,null,null,null);

n.addAttribute("invoice","ddic:com.sap.String");

//getting child node

IWDNode n1= wdContext.getChildNode("APNode",0);

IWDNodeElement nel=n1.createElement();

String s1=new String("1234545");

nel.setAttributeValue("invoice",s1);

n1.addElement(nel);

2) Create inputField and bind the att.in the modify

//Get the root Container

IWDTransparentContainer trans=(IWDTransparentContainer)view.getElement("RootUIElementContainer");

//create the inputField

IWDInputField ip=(IWDInputField)view.createElement(IWDInputField.class,"input1");

ip.bindValue("APNode.invoice");

trans.addChild(ip);

Hope this helps,

Regards,

Vijayakhanna Raman

Former Member
0 Kudos

Hi Vijayakhanna,

it works now. Much thx.

Hugo

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Your addchild method adds a child with mandatoryselection = false. Later you retrieve the nodeInfo using lead_selection.

Try setting the mandatoryselection to true or try getChildNode("APNode",0).

Good luck,

Roelof