cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all attributes of one node in dynamic webdynpro

Former Member
0 Kudos

Hi all.

I am customizing the WebDynpro CATS screen.

Because the table fields are dynamic generated. So there is only one node without attributes inside the context.

How can I get all attributes name and value for this node ? Because I want to add more node attributes.

I tried in debug mode, but it does not help.

anybody can give me some help ?

Accepted Solutions (1)

Accepted Solutions (1)

monalisa_biswal
Contributor
0 Kudos

U can retrieve attribute names using attribute iterator

 wdContext.nodeName().getNodeInfo().iterateAttributes();
	Iterator iter1 =  wdContext.nodeName().getNodeInfo().iterateAttributes();
//							
for (; iter1.hasNext();) {
	String tmp = iter1.next().toString();
	String	attributeName =
	tmp.split("\.")[tmp.split("\.").length- 1].split("\)")[0];
	}

Hope it helps!

Former Member
0 Kudos

What's this toString() and split-fiddling good for? Why not like this:

IWDNodeInfo nodeInfo = wdContext.node<Node>().getNodeInfo();
for (Iterator it = nodeInfo.iterateAttributes(); it.hasNext(); )
{
   IWDAttributeInfo attInfo = (IWDAttributeInfo) it.next();
   String attName = attInfo.getName();
}

Armin

Former Member
0 Kudos

Armin,

Frankly, first time I saw IWDNodeInfo API, I was wondering myself what this iterator returns: IWDAttributeInfo or just name of attribute for subsequent call to IWDNodeInfo.getAttribute(name). The documentation is ("was", at least) not clear about this.

Same is for many UME API -- it's unclear whether uniqueID or object itself is returned in many cases. The only way is to try first option and get ClassCastException

Sure, new version that is based on Java 5 (as far as next WebAS is J2EE5) will clean up these issues altogether with generics, i.e:

 Iterator<IWDAttributeInfo> IWDNodeInfo.iterateAttributes();

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Valery,

current NW04 Javadoc is clear now about it:

  /** 
   * Returns an Iterator to iterate over the attributes' IWDAttributeInfo.
   * @return an Iterator for the IWDAttributeInfo
   */
  Iterator iterateAttributes();

Armin

Answers (4)

Answers (4)

Former Member
0 Kudos

It works. thanks

Former Member
0 Kudos

It works, thanks a lot.

Your answer greatly helps me

Former Member
0 Kudos

Ok, I will try it tomorrow.

Can I use the say way to get all column fields of one dynamic table ?

lajitha_menon
Contributor
0 Kudos

I guess so, havent personally tried it..you can have a go,

cheers

lajitha_menon
Contributor
0 Kudos

Hi, Try this and let me know if it works...

	for (int i = 0; i < ValueNode.size(); i++) {
				ValueNode.setLeadSelection(i);
				//get child node name
				int NumFlds =
					ValueNode.getNodeInfo().getStructureType().getNumberOfFields();

				for (int count = 0; count <= NumFlds; count++) {
					IField Fld =
						ValueNode.getNodeInfo().getStructureType().getField(count);
					if (Fld != null) {
						FieldName = Fld.getName();
wdComponentAPI.reportSuccess("Fld" + FieldName + "Val" + ValueNode.getElementAt(i).getAttributeValue(FieldName));

					}
				}
	}