You need to sign in to do that
Don't have an account?
how to display nested list values
Hi, I want to display values inthis format
ex-i have 5names
name1,name2,name3,name4,name5
format is:
name1
name2 name3
name4 name5
name2
name1 name3
name4 name5
name3
name1 name2
name4name5
so on
I tried many ways but i didnt
my ocde is here:
public class statuslist{
public string statusName{get;set;}
public list<string> statussubmenu{get;set;}
public list<statuslist> parentlist = new list<statuslist>();
public list<statuslist> getparentlist()
{
return parentlist;
}
public void updatestatusop()
{
statusop = true;
List<Status_Option__c> statop = new List<Status_Option__c>([select Name,Current_Build_Status__c,Next_Build_Status__c
from Status_Option__c
where Product_Group__c = :productId ]);
system.debug('list size is:'+statop.size());
for(integer i=0;i<statop.size();i++)
{
statuslist tmp =new statuslist();
system.debug('status name is'+statop.get(i).Name);
tmp.statusName = statop.get(i).Name;
for(integer j=0;j<statop.size();j++)
{
if(i==j)
continue;
else
tmp.statussubmenu.add(statop.get(j).Name);
}
parentlist.add(tmp);
}
}
but iam getting nummobject refernce error.can anybody help me
You aren't initialising the statussubmenu member of your statuslist class, so it will be null. When you execute the following line of code:
you will receive an error as you are attempting to dereference the null value and execute its 'add' method.
yes,you are right and i changed my code as:
public class sublist
{
public boolean chklist{get;set;}
public string submenu{get;set;}
}
public class statuslist{
public string statusName{get;set;}
public list<sublist> statussubmenu = new list<sublist>();
public list<sublist> getstatussubmenu()
{
return statussubmenu;
}
public list<statuslist> parentlist = new list<statuslist>();
public list<statuslist> getparentlist()
{
return parentlist;
}
public void updatestatusop()
{
statusop = true;
List<Status_Option__c> statop = new List<Status_Option__c>([select Name,Current_Build_Status__c,Next_Build_Status__c
from Status_Option__c
where Product_Group__c = :productId ]);
system.debug('list size is:'+statop.size());
for(integer i=0;i<statop.size();i++)
{
statuslist tmp =new statuslist();
system.debug('status name is'+statop.get(i).Name);
tmp.statusName = statop.get(i).Name;
system.debug('values in statusoption are:'+tmp.statusName);
for(integer j=0;j<statop.size();j++)
{
sublist tmp1 = new sublist();
if(i==j)
{
system.debug('$$$$$$$$$$$ we are in if statment$$$$$$$$$$$$$$$');
continue;
}
else
{
tmp1.chklist = false;
tmp1.submenu = statop.get(j).Name;
tmp.statussubmenu.add(tmp1);
system.debug('*****we are in else*************************');
//tmp1.statussubmenu.add(statop.get(j).Name);
system.debug('status name in inner loop is is'+tmp);
}
}
parentlist.add(tmp);
}
}
my visualforce page is:
<apex:pageblock title="STATUS OPTIONS" rendered="{!statusop}">
<apex:outputpanel >
<table>
<apex:repeat value="{!parentlist}" var="p1">
<tr>
<td>
<h1><b> {!p1.statusName} </b></h1>
<apex:param name="statusopname" assignTo="{!newstatusname}" value="{!p1.statusName}"/>
</td>
</tr>
<tr><td>
<h5> <b> Next Status Option</b> </h5>
</td></tr>
<tr> <apex:repeat value="{!p1.statussubmenu}" var="p12" >
<td colspan='2'><apex:inputcheckbox value="{!p12.chklist}">{!p12.submenu}
</td>
</apex:repeat></tr>
</apex:repeat>
the o/p is
value1
chbox vale2 chkboc value3
chkbox value4 chkbox value5
value2
chbox value1 chkbox value3
chbox value4 chbox value5
...
now ,if i click chkboxes the correspondong value should bo store in custom object
if i click value2 and value3 under value1 then assign value1 to status_c. name=value1
status.nextstatusname=vallu2 value3
how can we do this
any suggestion?