cancel
Showing results for 
Search instead for 
Did you mean: 

getting a controller attribute value inside a for loop.

Former Member
0 Kudos

Dear experts,

I am facing a problem in getting a string value from my component controller attribute value inside a for loop.

Outside the for loop i am able to get this value. Please help me out in this.

for (int i = 0; i < lead; i++) {

IPrivateQuote_ServiceDetailsView.IVn_ServicedetailsNodeElement ele = wdContext.nodeVn_ServicedetailsNode().getVn_ServicedetailsNodeElementAt(i);

boolean select = ele.getVa_select();

if (select == true)

{

String name1 = wdThis.getTheGroupName();

i am facing the problem in this last step. If i write the getTheGroupName() method ouside the for loop, then i am getting the value from my controller attribute.

thanks in advance,

Jithin.

Edited by: jithin james on Feb 16, 2009 6:43 AM

Edited by: jithin james on Feb 16, 2009 6:44 AM

Accepted Solutions (0)

Answers (3)

Answers (3)

nikhil_bose
Active Contributor
0 Kudos

code looks fine. try debug the current code for the following cases


for (int i = 0; i < lead; i++) { // what is lead value here? check loop is working proper

boolean select = ele.getVa_select(); // see the current value for select

plz update status

nikhil

Former Member
0 Kudos

HI James,

I feel its not because for loop. but its because If loop you are unable to call the method.

if (select == true)

{

String name1 = wdThis.getTheGroupName();

}

please first check what is the value of boolean select you are getting by priting its value.Or can you once remove the if block and try to call that method inside for loop.

Regards

Narendra

Former Member
0 Kudos

hi,

I tried to call this method before the If () condition, then also i am not able to get the value. But once if I call this method ouside the for loop, i get my value correctly.

Former Member
0 Kudos

Hi,

I can't understand the reason behind not able to retrieve the value inside the for loop.

From your method implementation I feel that your value for the method always returns the same because it returns you the currentElement value.

Thus, even if you get the value outside the for loop and store it in a local variable and then use the local variable to set the value should be OK in your case.

Regards,

Murtuza

Former Member
0 Kudos

Hi,

Could you post us the code for the getTheGroupName() method?

Regards,

Murtuza

Former Member
0 Kudos

hi,

String name = wdcontext.nodeInput.currentInputnodeElement.getVa_Name();

groupName = name;

return(groupName);

There is nothing wrong with this method, as it returns the correct value ouside the for loop.

Edited by: jithin james on Feb 16, 2009 6:50 AM