cancel
Showing results for 
Search instead for 
Did you mean: 

Getting attributes of a node dynamically

Former Member
0 Kudos

I was trying to get the attributes of a value node dynamically. I'v used the code below.

But I didnt get the attributes. I am getting nullpointer exception.

can anybody tell me what is wrong with my code?

Thanks in advance...

final IWDNodeInfo tabNode = wdContext.nodeName().getNodeInfo();

final IStructure structure = tabNode.getStructureType();

int NoOfFlds = 0;

if (null != structure)

NoOfFlds = structure.getNumberOfFields();

else

for (final Iterator i = tabNode.iterateAttributes(); i.hasNext(); i.next() )

NoOfFlds++;

for(int count=0;count<NoOfFlds;count++)

{

String fieldName = tabNode.getStructureType().getField(count).getName();

}

Indu

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182294
Active Contributor
0 Kudos

Hi Indu,

If you want to use Attributes...

final IWDNodeInfo tabNode = wdContext.nodeName().getNodeInfo();

final IStructure structure = tabNode.getStructureType();

int NoOfFlds = 0;

if (null != structure)

NoOfFlds = structure.getNumberOfFields();

else

for (final Iterator i = tabNode.iterateAttributes(); i.hasNext(); )

{

NoOfFlds++;

IWDAttributeInfo attribInfo = (IWDAttributeInfo)i.next();

if( attribInfo != null)

{

String attribName = attribInfo.getName();

}

}

Regards

Abhilash

Former Member
0 Kudos

Now I am able to acees attributes. Can u tell me how can I assign caption to columns and how to add input fieds to a column? I'v tried using the code

IWDCaption Cap=(IWDCaption)view.createElement(IWDCaption.class,fieldName[count]);

Cap.setText(fieldName[count]);

tabColumn.setHeader((IWDCaption)Cap);

IWDInputField nameText=(IWDInputField)view.createElement(IWDInputField.class,fieldName[count]);

nameText.bindValue(fieldName[count]);

I got one exception like

"com.sap.tc.webdynpro.services.exceptions.CreationFailedException: Cannot create view element implementation com.sap.tc.webdynpro.clientserver.uielib.standard.impl.Caption "

Can u please tell me the reason?

Indu

Former Member
0 Kudos

Check the posting for dynamic table creation.

Regards, Anilkumar

monalisa_biswal
Contributor
0 Kudos

1.U have to iterate over attributes of contextnode using iterateAttribute() method.

2.Inside the loop create and add column to the table reference.

3.Create Caption and inputfield elements.

IDs of Caption and inputfield elements should be different.U have passed same value in createElement() method of these elements (fieldName[count])

4.Input field's value attribute should be binded to attributeinfo of the value attribute.

5.Use setHeader() and setTableCellEditor() methods to set caption as header and inputfield as tablecell editor of the table column.

Former Member
0 Kudos

Ex :

Iterator it= wdContext.getChildNode("<<NodeName>>",0).getNodeInfo().iterateAttributes();;

while(it.hasNext()){

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

aInfo.getName();

}

Regards, Anilkumar