cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the value of dynamically generated inputfield

Former Member
0 Kudos

Hi all,

I generated dynamic inputfields on clicking of the button. Now after generating I want to get the value of dynamically generated input field and I want to store it in database also. If any one knows Plz tell me.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Krishnaveni,

For getting the value of this input field you have get the get teh value of the attribute which you must have binded with this inputfield.

I hope you must have binded some attribute to this input field. If not then do that. Since you are creating the inputfield dynamically so you have to the attribute binding also dynamically.

Use the following code:

1) Create a objet of a input field, say:

IWDInputField idk = ((IWDInputField)view.createElement(IWDInputField.class, "input");

2) Now use this object to bind the attribute to this field:

idk.bindValue(wdContext.getNodeInfo().getAttribute(input_Variable));

<i>(Where: <b>input_Variable</b>, is the attribute in the context node)</i>

Now for getting the value of this input field use this code:

String value = wdContext.currentContextElement().getAttributeValue(input_Variable).toString();

This value is the value of the synamically generated inputfield

I hope this helps you.

Regards

Pravesh

PS: Please consider rewarding points if helpful and solved

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

With help of all your answers I solved the problem. thanks for all your inputs. By the way i rewarded points to all.

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

1)Create context for the inputfield dynamically in init method.

IWDAttributeInfo a=wdContext.getNodeInfo().addAttribute("val1","ddic:com.sap.String");

2)Create the inputfield andd bind to this context

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

ip.bindValue("val1");

3)Get the value from the inputfiels like this

String s=( String)wdContext.currentContextElement().getAttributeValue("val1");

Get the connection to the database and insert the value to it.

try{

InitialContext initialContext = new InitialContext();

DataSource dataSource = (DataSource)initialContext.lookup("AlaisName");

java.sql.Connection conn = dataSource.getConnection();

//Do Others

}catch(Exception e){

e.printStackTrace();

}

Regards,

Vijayakhanna Raman

Message was edited by: Vijayakhanna Raman

Former Member
0 Kudos

Hi

You can get the values from the same screen which is dynamically created.

IWDNode node1 =wdContext.node<Dynamicnode>().getChildNode("<NodeName>");

String values ="";

if(node1.getCurrentElement().getAttributeValue("<Name>")!=null){

values=(String) node1.getCurrentElement().getAttributeValue("<Name>");

}else{

values = "";

}

Kind Regards

Mukesh

Former Member
0 Kudos

Hi

use the followig Steps for only Retreving the data from dynamic input field.

IWDNode node =wdContext.currentContextElement().node().getChildNode(<Node Name>,0);

IWDNodeElement nodeElement = node.getCurrentElement();

Object <ans> =nodeElement.getAttributeValue(String.valueOf(<Node Name>);

finally you will get the inputFiled data in the

<ans> variable.

Regards

Dhinakar