cancel
Showing results for 
Search instead for 
Did you mean: 

dynamically created attribute not bound

Former Member
0 Kudos

hi ,

I hv an application where the attributes are accessed from a backend java file.

i hv created a new attribute :

#----


//create a label

IWDLabel hp= (IWDLabel)view.createElement(IWDLabel.class,"hpage");

hp.setText("HOME PAGE");

theGroup.addChild(hp);

//create an input field

IWDInputField homepage= (IWDInputField)view.createElement(IWDInputField.class,"hp");

IWDAttributeInfo attr=(IWDAttributeInfo)wdContext.getNodeInfo().getAttribute("HomePage");

homepage.bindValue(attr.getName());

theGroup.addChild(homepage);

-


#

and i hv bound it as:

#----


public void wdDoInit()

{

IWDNodeInfo node =wdContext.getNodeInfo().addChild(

"DynamicNode", null,true, true,false,false, false,true,null,null,null);

//“Create“ backend connection to SomeBackEnd.java

SomeBackEnd theBackend = new SomeBackEnd()

// loop through all fields of the Object[] fields containing the

// FieldDescriptors

for (int index = 0; index < theBackend.getNumberFields(); index++) {

// ... and simply create the required context attribute

SomeBackEnd.FieldDescriptor fld = theBackend.getField(index);

node.addAttribute(fld.getName(), fld.getType());

}

  • wdContext.getNodeInfo().addAttribute("HomePage","com.sap.dictionary.string");*

wdContext.currentContextElement().setVisible(WDVisibility.NONE);

}

-


#

bt when i click on save btn iget the following output:

HOME PAGE:DataAttributeInfo(DynamicView.HomePage)

even if i leave it blank or enter some data.

i hv written the following code in save btn:

#----


Object obj=wdContext.getNodeInfo().getAttribute("HomePage");

if(obj==null)

obj="<NULL>";

result = "Your data was successfully saved:" + "\n\r";

result = result + "HOME PAGE" + " :" + obj.toString()+"\n";

#----


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

try printing

wdComponentAPI.getMessageManager().reportSuccess(String.valueOf(wdContext().currentContextElement().getHomePage());

Regards

Ayyapparaj

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ankita,

The purpose of using a backend java file is to make use of the concept of one change at one place. Like in your instance I believe that if you create a inputfield in the backend java file in the following manner

"new FieldDescriptor("InputField","homePage","com.sap.dictionary.string","Home Page","Enter your homepage url here",""),

it should suffice. There is no need to explicitly call the attribute as you are trying to do. Try this. With reference to your code I believe that the application will create the attributes and when you are printing your result it will display the value in your inputfield.

Regards,

Pinac