cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind dynamically created attributes

Former Member
0 Kudos

Hi all,

i hv created an appl where all the attributes hv been created dynamically..

wdContext.getNodeInfo().addAttribute("From","ddic:com.sap.dictionary.string");

wdContext.getNodeInfo().addAttribute("To","ddic:com.sap.dictionary.string");

wdContext.getNodeInfo().addAttribute("Subject","ddic:com.sap.dictionary.string");

wdContext.getNodeInfo().addAttribute("Message","ddic:com.sap.dictionary.string");

bt nw i am nt able to retrieve those.

For ex: if i hv to set the from field to null ,hw to do so?

( As we used to get it:

wdcontext.currentContextElement().setFrom(" ");

)

Plz help.

Thanks and Regards,

Ankita

Edited by: Ankita Padhi on Jul 14, 2008 8:48 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

Sample code for dynamic generation code

IWDInputField inputfield = (IWDInputField)view.

createElement(IWDInputField.class,"InputField1");

IWDAttributeInfo test =wdContext.getNodeInfo().

addAttribute("AttributeA","ddic:com.sap.dictionary.string");

wdContext.currentContextElement().setAttributeValue("AttributeA", "Hello World!!!");// set the value of attribute

inputfield.bindValue(test);//bind the newly created attribute to inputfield

try like this and let me know

thanks,

Tulasi.Palnati

Former Member
0 Kudos

thanks all,

i hv bound all my input fiels and text areas....

i can get its value and check....

bt i am nt able to set its value..

As on a button action i hv to set all those fields to blank....

Regards,

Ankita

PradeepBondla
Active Contributor
0 Kudos

Hi,

you have to set value as

wdContext.currentContextElement().setAttributeValue("From", ""); you can set blank like this.

not like wdContext.currentContextElement().setFrom(" "); it wont be like this.

you are doing it in button Action? it is also dynamic? if yes, you have to create Action in design time that is manually you can not create it dynamically and do following code in runtime

// Creating a button
IWDButton objButton = (IWDButton)view.createElement(IWDButton.class, u201CbutSubmit");


// Setting tooltip and text to the button
objButton.setTooltip(op.getTooltip()); 
objButton.setText(op.getDisplayText());



// Create an action and assign the same to the button.
IWDAction theAction = wdThis.wdCreateAction(IPrivateDynamicView.WDActionEventHandler
					.GENERIC_ACTION,""); // here GENERIC_ACTION is the action created manually
objButton.setOnAction(theAction);

am I right?\

\

regards,

Pradeep

Former Member
0 Kudos

Thanks Pradeep...

It solved my problem..

Regards,

Ankita

Answers (2)

Answers (2)

PradeepBondla
Active Contributor
0 Kudos

Hi,

Here is the right flow...

//Creating an attribute
wdContext.getNodeInfo().
	addAttribute("nameValue","ddic:com.sap.dictionary.string");




//Creating Input Field or any other UI element
IWDInputField ifName = 
	(IWDInputField)view.createElement(IWDInputField.class,"ifName");

//Binding the attribute with InputField
ifName.bindValue("nameValue");

regards,

Pradeep

Former Member
0 Kudos

Hi,

here i m giving code for your reference of a dynamic checkbox:

IWDCheckBox checkBox =

(IWDCheckBox) view.createElement(IWDCheckBox.class,

"checkBox" + count);

IWDMatrixHeadData checkHeadData =

(IWDMatrixHeadData) checkBox.createLayoutData(

IWDMatrixHeadData.class);

IWDAttributeInfo attrInfo;

info= wdContext.nodeCheckBox().getNodeInfo().addAttribute(

"Check" + count, "ddic:com.sap.dictionary.boolean");

checkHeadData.setVAlign(WDCellVAlign.TOP);

checkHeadData.setWidth("6%");

checkHeadData.setColSpan(1);

this line used to bind the context to the element:-

checkBox.bindChecked(info);

checkBox.setEnabled(true);

TitleRow.addChild(checkBox);

Hope this may help you.

Regards,

Deepak

Edited by: Deepak Arora on Jul 14, 2008 9:09 AM