cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic UI Binding Problem

Former Member
0 Kudos

Hi ,

In my application I need to generate Dynamic TextView. I am having node Details and its attribute Name of type String.

Node > Details (Cardinality 0-n)

-


Name (type String Value Attribute)

I want to generate textview dynamically for number of time as size of Node Details. I have written following code to generate TextView , but i am not getting how to bind Name attribute to Dynamically genarated TextView. Can any one plz help me writing code for binding???

Thnx in advance.

Kavita

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

for(int i=0;i<wdcontext.nodeDetails().size();i++)

{

IWDInputField inputfield = (IWDInputField)view.createElement(IWDInputField.class, "InputField"+i);

// Binding ??????

container.addChild(inputfield);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Do you want to get TextViews or InputFields? Anyway, you cannot bind either against individual node elements. To achieve what you want you have to use a Table or RowRepeater and bind the embedded editor to the "Name" attribute, or you have to create separate context attributes Name1, ..., NameN and bind individual UI elements against these attributes.

Armin

Former Member
0 Kudos

Hi Armin Reichert

Actually i am developing quiz application , where i need to show question text and number of options(RadioButtons). What i have posted in this thread is similar to my actual quiz application. The number of question is going to be decided at run time so i want to use dynamic UI generation. As you said i can use table and bind nodes to table , but how can i insert number of radio buttons for option in one single row of table for each question????

Kavita

Former Member
0 Kudos

You can't put a radio button group inside a table cell. Maybe you have to choose my second proposal, namely creating the context attributes / nodes programmatically and binding individual UI elements to them.

Armin

Former Member
0 Kudos

That means i have to create node for each question dynamically??? 10 Nodes for 10 Questions????

Former Member
0 Kudos

Hi,

here is a sample tutorial which discuss about a quiz app

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4a417a90-0201-0010-f499-8d41fc78...

may be of use for you.

Regards

Ayyapparaj

Former Member
0 Kudos

Thnx. your solution solved my problem. I m creating attributes dynamically for options of each questions. Thnk u very much

Kavita

Answers (4)

Answers (4)

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Kavita,

Check out this link for dynamic UI element creation[Link|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/business_packages/a1-8-4/17tutwd_dynamic.zip]

Regards, Suresh KB

Former Member
0 Kudos

Hi Kavitha,

//Iterate to get the attributes

Iterator itr1 = wdContext.nodeDetails().getNodeInfo().iterateAttributes();

IWDTransparentContainer container = (IWDTransparentContainer)view.getElement("<Your Root Container>");

while(itr1.hasNext())

{

// Input Field for each attribute

IWDInputField input= (IWDInputField)view.createElement(IWDInputField.class,null);

IWDAttributeInfo iWDInfo = (IWDAttributeInfo) itr1.next();

input.bindValue("Details."+iWDInfo.getName());

//Add to the container

container.addChild(input);

}

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapparaj ,

The code which you gave me is iterating number of attributes under Node Details , so only one textView is getting generated dynamically not as size of Details Node

Ragards

Kavita

Former Member
0 Kudos

Hi,

Modifying your code:

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

for(int i=0;i<wdcontext.nodeDetails().size();i++)
{
  IWDInputField inputfield = (IWDInputField)view.createElement(IWDInputField.class, "InputField"+i);

   // Binding
   inputfield.bindValue("Details.Name");

   container.addChild(inputfield);
}

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit

I have tried your code , but its repeating last value of Name attribute for all textviews.

Regards

Kavita

Former Member
0 Kudos

Hi,

That's normal for stand-alone Inputfields. If you want different values for the different inputfields based on the same node attribute then put the Inputfields in a table, or bind them to different attributes.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

Plz check following code

IWDNodeInfo soNi = wdContext.getChildNode("SalesOrders",0).

getNodeInfo();

for(Iterator it = soNi.iterateAttributes(); it.hasNext();)

{

IWDAttributeInfo thisAttr = (IWDAttributeInfo)it.next();

IWDInputField inFld = (IWDInputField)view.createElement(

IWDInputField.class,thisAttr.getName() + "Input");

// Bind the input field to the relevant context attribute

inFld.bindValue(thisAttr);

}