cancel
Showing results for 
Search instead for 
Did you mean: 

add a row to a table

Former Member
0 Kudos

Hi ,

i am unable to set values to a row dynamically .....

here is my code...

ArrayList al=new ArrayList();

for (int i = 0; i < node.size(); i++)

{

IRowsElement row = wdContext.nodeRows().createRowsElement();

row.setTest("in test"+i);

al.add(row);

}

wdContext.nodeRows().bind(al);

But in the o/p all the rows are sets with "in test 0" value ....

but i want values "in test 1 ", in test 2"......

plz help me.

Thanks,

Sunitha

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Are you check the node.size() value.It will be 0.

otherwise assign i<10 or something.

Kind Regards

Mukesh

Former Member
0 Kudos

Try

for (int i = 0; i < node.size(); i++)

{

IRowsElement row = wdContext.nodeRows().createRowsElement();

row.setTest("in test"+i);

wdContext.nodeRows().addElement(row);

}

Regards, Anilkumar

Former Member
0 Kudos

Try

for (int i = 0; i < node.size(); i++)

{

IRowsElement row = wdContext.nodeRows().createRowsElement();

row.setTest("in test"+i);

wdContext.nodeRows().addElement(row);

}

above code also giving me the same o/p ...

Thanks,

Sunitha

Former Member
0 Kudos

Hi Mukesh ,

The node size is 6 here ....

if i give i < 10 also it is giving me the same o/p.

Thanks,

Sunitha

former_member186016
Active Contributor
0 Kudos

Hi Sunita,

Can you please post the code where you are initializing the variable "node".

Regards,

Ashwani

Former Member
0 Kudos

Hi ,

here is my code....

ArrayList al=new ArrayList();

for (int i = 0; i < wdContext.nodeI_Zmlst1_out().size(); i++)

{

IRowsElement row = wdContext.nodeRows().createRowsElement();

String s = wdContext.nodeI_Zmlst1_out().getElementAt(i).getAttributeAsText("Zdt_Comp");

int i1 ;

if(s.equals("Y"))

i1 = 0 ;

else if(s.equals("N"))

i1 = 1;

else

i1 = 2;

switch(i1)

{

case 0 : row.setSignal("S_S_LEDG.gif");

row.setTest("in green"+i);

wdComponentAPI.getMessageManager().reportSuccess(" green");

break;

case 1: row.setSignal("S_S_LEDR.gif");

row.setTest("in red"+i);

wdComponentAPI.getMessageManager().reportSuccess(" red");

break;

case 2: row.setSignal("S_S_LEDI.gif");

break;

}

wdContext.nodeRows().addElement(row);

}

here if the value is "Y" , i have set one image and if the value is "N" i have to set the other one.

but here it is always giving only one image, either "S_S_LEDG.gif " or "S_S_LEDR.gif".

Thanks,

Sunitha

former_member186016
Active Contributor
0 Kudos

Hi Sunitha,

Thanks for the code.

Can you check the size of node Row before and after this iteration (loop).

Regards,

Ashwani

Former Member
0 Kudos

Why you are using "i" instead of "i1" in switch statement ??

switch(i1)

{

case 0 : row.setSignal("S_S_LEDG.gif");

row.setTest("in green"+i1);

wdComponentAPI.getMessageManager().reportSuccess(" green");

break;

case 1: row.setSignal("S_S_LEDR.gif");

row.setTest("in red"+i1);

wdComponentAPI.getMessageManager().reportSuccess(" red");

break;

case 2: row.setSignal("S_S_LEDI.gif");

break;

}

Regards, ANilkumar

Message was edited by:

Anilkumar Vippagunta

Former Member
0 Kudos

Hi ,

i1 is the condition i am using for swith case ,

i is the variable i used for For loop ....

context node size is 6 and in switch case it is going into case 0 and also case 1 , but table is always having either "S_S_LEDG.gif" or

"S_S_LEDR.gif" as o/p .

Thanks,

Sunitha.

Former Member
0 Kudos

Hi Sunitha,

The ouput dependes upon the value returned by the statement

wdContext.nodeI_Zmlst1_out().getElementAt(i).getAttributeAsText("Zdt_Comp");

I think its returning either "Y" or "N".Thats why it is displaying "S_S_LEDG.gif" or

"S_S_LEDR.gif".

Please check the values returned by the output node.

Regards, Anilkumar

Former Member
0 Kudos

Hi ,

If the o/p is "Y" i have to dispaly "S_S_LEDG.gif" image and if the o/p is "N"

i have to dispaly "S_S_LEDR.gif" image.

Thanks,

Sunitha.

former_member186016
Active Contributor
0 Kudos

In Ur previous post :

<i>Hi ,

here is my code....

ArrayList al=new ArrayList();

for (int i = 0; i < wdContext.nodeI_Zmlst1_out().size(); i++)

{

IRowsElement row = wdContext.nodeRows().createRowsElement();

String s = wdContext.nodeI_Zmlst1_out().getElementAt(i).getAttributeAsText("Zdt_Comp");

int i1 ;

if(s.equals("Y"))

i1 = 0 ;

else if(s.equals("N"))

i1 = 1;

else

i1 = 2;

switch(i1)

{

case 0 : row.setSignal("S_S_LEDG.gif");

row.setTest("in green"+i);

wdComponentAPI.getMessageManager().reportSuccess(" green");

break;

case 1: row.setSignal("S_S_LEDR.gif");

row.setTest("in red"+i);

wdComponentAPI.getMessageManager().reportSuccess(" red");

break;

case 2: row.setSignal("S_S_LEDI.gif");

break;

}

wdContext.nodeRows().addElement(row);

}

here if the value is "Y" , i have set one image and if the value is "N" i have to set the other one.

but here it is always giving only one image, either "S_S_LEDG.gif " or "S_S_LEDR.gif".

Thanks,

Sunitha

</i>

Do you want to say :

<i>

but here it is always giving only <b>"multiple"</b> image<b>s,which are</b> either "S_S_LEDG.gif " or "S_S_LEDR.gif".

</i>

Former Member
0 Kudos

If the first condition is "Y" then it is setting all the rows with "S_S_LEDG.gif " image, if it is "N" then "S_S_LEDR.gif " image.

Former Member
0 Kudos

<b>but here it is always giving only "multiple" images,which are either "S_S_LEDG.gif " or "S_S_LEDR.gif".</b>

Yes i am getting "Multiple images" either "S_S_LEDG.gif " or "S_S_LEDR.gif"

Thanks,

Sunitha

former_member186016
Active Contributor
0 Kudos

Do you mean :

If you put


int i1 ;
if(s.equals("Y")) {
i1 = 0 ;
}
else if(s.equals("N"))  {
i1 = 1;
}
else {
i1 = 2;
} 

You get every row as green and if you put


int i1 ;
if(s.equals("N")) {
i1 = 0 ;
} else if(s.equals("Y"))  {
i1 = 1;
} else { 
i1 = 2; 
}

All the images are red ?

Can you paranthesis to write your if else statements.

Please check the data also. May have a trace of data in the node.

Former Member
0 Kudos

Hi ,

String s = wdContext.nodeI_Zmlst1_out().getElementAt(i).getAttributeAsText("Zdt_Comp");

if the String value i am getting from back end for getElementAt(i), for i = 0 equal to "Y", then o/p is green image.

if the String value is "N" then o/p is red images.

My question is how will i set different images , to a row depending on the condition.

former_member186016
Active Contributor
0 Kudos

Hi Sunitha,

Can you try this:


for (int i = 0; i < wdContext.nodeI_Zmlst1_out().size(); i++)
{
IRowsElement row = wdContext.nodeRows().createRowsElement();
String s = wdContext.nodeI_Zmlst1_out().getElementAt(i).getAttributeAsText("Zdt_Comp");

int i1 ;
if(s.equals("Y")) {
  row.setSignal("S_S_LEDG.gif");
  row.setTest("in green"+i);
  wdComponentAPI.getMessageManager().reportSuccess(s+" green");
} else if(s.equals("N"){
  row.setSignal("S_S_LEDG.gif");
  row.setTest("in green"+i);
  wdComponentAPI.getMessageManager().reportSuccess(s+" red");
} else {
  row.setSignal("S_S_LEDI.gif");
  row.setTest("No Y or N "+i);
  wdComponentAPI.getMessageManager().reportSuccess(" No Y or N");
}
wdContext.nodeRows().addElement(row);
}

Regards,

Ashwani

Former Member
0 Kudos

Hi ,

I solved the problem ,

The table in which i am adding this table , it's data source is bound to a model node.

i created another table binded it's datasource to the value node(Rows) i created it is working fine now.

but i want to dispaly the images row with the table which is bound to the modelnode.

Former Member
0 Kudos

In that case ModelAttribute should have imagename as the value.

Regards, ANilkumar