on 11-12-2004 4:10 PM
Hi, I'm presently migrating a old application to webdynpro.
In that application, I have a FieldDescriptor, which has the information of which table to search in order to find the info to be displayed.
Concretely I have:
A class called BapiInfoField. This class has an attribute which is the name of a table. I need to retrieve the node associated to that table.
To resolve this, I thought about making a mapping between the old table name and the new one compatible to webdynpro.
On the other hand, I don't know how to fetch an node at runtime in webdynpro. The only way I do usually, is by using the "wdContect.node*" way. I know how to fetch elements in a node dynamically, but not the node itself.
I also found a function called "getChildNode(String arg0, int arg1)" in the wdContext class. Unfortunately, the function is undocumented.
If there's no appropriate getter function in webdynpro for my problem, I'll resolve by making a mapping between the string of the old table name, and a Method Object linked to the proper "node*" method.
Anyone has any suggestions?
Thanks in advance,
Alexis
Brrr...
I do not understand your requirements completely, but can provide some hints regarding getting nodes information at runtime.
First, you are misinformed: getChildNode is documented. First parameter is node name, second is index of parent element of subnode (i.e. index within "this" node).
Next, there are 2 different situations: you need only meta-information or you need physical data.
For first case:
void traverse(final IWDNodeInfo parent)
{
for (final Iterator i = parent.iterateChildren(); i.hasNext(); )
{
final IWDNodeInfo child = (IWDNodeInfo)i.next();
traverse( child );
}
}
traverse( wdContext.getNodeInfo() );
For second case:
void traverse(final IWDNodeElement parent)
{
final IWDNode nParent = parent.node();
final IWDNodeInfo niParent = nParent.getNodeInfo();
final int idxParent = parent.index();
for (final Iterator i = niParent.iterateChildren(); i.hasNext(); )
{
final IWDNodeInfo child = (IWDNodeInfo)i.next();
traverse( nParent.getChildNode( child.getName(), idxParent ) );
}
}
void traverse(final IWDNode parent)
{
for (int i = parent.size() - 1; i>= 0; i--)
{
final IWDNodeElement element = parent.getElementAt( i );
/* Workaround for singleton nodes */
/* parent.setLeadSelection( i ) */
traverse( element );
}
}
traverse( wdContext.currentContextElement() );
Second case is quite "interesting": first, it will fails for singleton nodes with cardinality 0..n or 1..n (see commented workaround); second, it quite resource-consuming, namely, invokes all supply functions and populating all elements during traverse.
Hope this will serve you as good starting point
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes, I guess I talked too rapidly. I found the documentation of the getChildNode method before seeing your reply.
Thanks anyway for the traverse example, though I found a solution on my own.
I use:
wdContext.getChildNode( "TheNodeName", Node.LEAD_SELECTION );
Since my node is a singleton table, I guess this is fine.
Alexis
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.