cancel
Showing results for 
Search instead for 
Did you mean: 

get the attribute value ( created dynamically )

Former Member
0 Kudos

Hello Friends,

I am creating an attribute dynamically in my wdmodify method and added it to context as follows:

IWDAttributeInfo sign = wdContext.wdGetAPI().getRootNodeInfo().addAttribute("sign"+i, "variantpack.sign");

IWDAttributeInfo option = wdContext.wdGetAPI().getRootNodeInfo().addAttribute("option"i1, "variantpack.option");

wdContext.currentContextElement().setAttributeValue("sign", wdContext.currentContextElement().node().getCurrentElement().getAttributeValue("sign"+i).toString().toUpperCase());

wdContext.currentContextElement().setAttributeValue("option", wdContext.currentContextElement().node().getCurrentElement().getAttributeValue("option"i1).toString().toUpperCase());

Now on method onActionSelect, I have to access the attributes.... how I can determine the name: e.g IF I know the name of attribute I can do something like this..

wdContext.currentContextElement().getAttributeValue("sign");

I thought to make an arraylist in wdmodify and add all attribute names and in onActionSelect method read the arraylist and get the attribute-name and then get the value..... dont know if its a good way,

ur suggestions are highly appreciated....

Regards,

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member197348
Active Contributor
0 Kudos

Hi Shah,

You can use this code

for (Iterator iter = wdContext.node<name>().getNodeInfo().iterateAttributes(); iter.hasNext();)

{

IWDAttributeInfo attInfo = (IWDAttributeInfo) iter.next();

wdContext.node<Name>().getElementAt(0).getAttributeValue(attInfo.getName());

}

regards,

Siva

Former Member
0 Kudos

Hi Sava,

<b>for (Iterator iter = wdContext.node<name>().getNodeInfo().iterateAttributes(); iter.hasNext();)</b>

<name> is the problem to know in my case.... see my coading above, i am creating new attributes and adding them to context....

Now I am thinking to create a node and add to this node the attributes name and value, ...

Any suggestion , how I can do the above otherwise...

Regards,

Former Member
0 Kudos

Hi,

Use wdContext.getNodeInfo().iterateAttributes()

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

If you would write

for (Iterator iter = wdContext.getNodeInfo().iterateAttributes(); iter.hasNext();)

This iterates directly on the context node and you get the attributes under it.

Warm Regards,

Murtuza

Former Member
0 Kudos

Okey, I have created a node (Zusr_Sel()) in context which has two attributes,

Zusr_Sel sel = new Zusr_Sel();

sel.setFieldname(fieldName);

sel.setValue("sign"+i);

sel.setFieldname(fieldName);

sel.setValue("option"i1);

Now how I can add this node in context again, so that in other method I can retrieve this node with its values ?

Regards,

Former Member
0 Kudos

Hi,

You can use this method:

wdContext.getNodeInfo().addChild()

Warm Regards,

Murtuza

Former Member
0 Kudos

Hello Murtuza,

the node Zusr_sel is already there in context, ... I have added few values to it, and want this values to be added in context too..... add child will not work as node is there already ---

Any idea how to do so `?

Regards,

Former Member
0 Kudos

you can add the element to the context simply adding this line after writing the above mentioned code by you:

wdContext.node<nodename>().addElement(sel);

Warm Regards,

Murtuza