on 02-20-2008 5:01 AM
Hi Experts
I would like to clean up the following code by putting it in a loop. Could someone show me how to dynamically reference the name of an attribute by substituting i for 1,2,3 and 4.
claimDetail.setAmount01(wdContext.currentDetailtabElement().getZz_Betrg_01());
claimDetail.setAmount02(wdContext.currentDetailtabElement().getZz_Betrg_02());
claimDetail.setAmount03(wdContext.currentDetailtabElement().getZz_Betrg_03());
claimDetail.setAmount04(wdContext.currentDetailtabElement().getZz_Betrg_04());
something like this
for (int i = 1; i <= 4; i++)
{
claimDetail.???
}
thanks in advance
Anton Kruse
almost.
I did it like this:
claimDetail = wdContext.nodeClaimDetail().createClaimDetailElement();
claimDetail.setAmount((BigDecimal)wdContext.currentDetailtabElement().getAttributeValue("Zz_Betrg_0" + i));
wdContext.nodeClaimDetail().addElement(claimDetail);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anton,
Simply use
for( int i=1; i<= 4; i++)
{
// claimDetail.setAmount01(wdContext.currentDetailtabElement().getZz_Betrg_01());
claimDetail.setAttributeValue("Amount0" + i, wdContext.currentDetailtabElement().getAttributeValue("Zz_Betrg_0" + i) );
}
xxxxxxxxxxxxxxxxxx
Regards
Deepak
Edited by: Armin Reichert on Feb 20, 2008 8:03 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think this is what you are looking for
IWDNodeElement nodeElement;
List attributes = wdContext.getNodeInfo().getAttributes();
for(int x=0; x < attributes.size(); x++)
nodeElement.setAttributeValue(attributes.get(x), value);
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what i am looking for:
instead of writing
claimDetail = wdContext.nodeClaimDetail().createClaimDetailElement();
claimDetail.setAmount((BigDecimal)wdContext.currentDetailtabElement().getZz_Betrg_01());
wdContext.nodeClaimDetail().addElement(claimDetail);
claimDetail = wdContext.nodeClaimDetail().createClaimDetailElement();
claimDetail.setAmount((BigDecimal)wdContext.currentDetailtabElement().getZz_Betrg_02());
wdContext.nodeClaimDetail().addElement(claimDetail);
claimDetail = wdContext.nodeClaimDetail().createClaimDetailElement();
claimDetail.setAmount((BigDecimal)wdContext.currentDetailtabElement().getZz_Betrg_03());
wdContext.nodeClaimDetail().addElement(claimDetail);
I want to replace the '01', '02', '03' after getZz_Betrg with 'x'.
something like this:
for (int x = 1; x < 4; x++)
{
claimDetail = wdContext.nodeClaimDetail().createClaimDetailElement();
claimDetail.setAmount((BigDecimal)wdContext.currentDetailtabElement().*getZz_Betrg_0 + "x" +());*
wdContext.nodeClaimDetail().addElement(claimDetail);
}
Hi,
use as follows
for (int x = 1; x < 4; x++)
{
claimDetail = wdContext.nodeClaimDetail().createClaimDetailElement();
//wdContext.currentContextElement().getAttributeValue(attributeName);
claimDetail.setAmount((BigDecimal)wdContext.currentDetailtabElement().getAttributeValue(getZz_Betrg_0 + "x" );
wdContext.nodeClaimDetail().addElement(claimDetail);
}
Regards
Ayyapparaj
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.