+ Start a Discussion
gopikrishnagopikrishna 

add one list data to another list

Hi all,

 

  i created related list, in that  one object data retrive to related list , this data add to another object when check box is true and   Add button click.  and return that data visible to same pageblock . 

 

my vf page:

 

<apex:page tabStyle="Container__c" standardController="Container__c" extensions="Container">
<apex:form >
<apex:detail relatedList="false" title="true"/>
<apex:pageBlock title="Container Line Items">
<center> <apex:commandButton value="ADD" action="{!save}"/></center>
<apex:outputPanel rendered="{!new1}">
<table>
<tr>
<th width="100">check</th>
<th width="150"><b>PPI Line item number </b></th>
<th width="100"><b>Order Quantity</b></th>
&nbsp;&nbsp;<th width="200"><b>PPI</b></th>
<th width="100"><b>Products</b></th>
<th width="100"><b>Shipped Quantity</b></th>
<th width="200"><b>Balance Quantity</b></th>
</tr>
<apex:repeat value="{!polist}" var="e" >
<!---<apex:outputPanel rendered="{!data}">--->
<tr>
<td><apex:inputCheckbox value="{!ch}">
<!--<apex:actionSupport event="onclick" />-->
</apex:inputCheckbox></td>
<td><apex:outputfield value="{!e.name}"/></td>
<td><apex:outputField value="{!e.Order_Quantity__c}"/></td>
<td><apex:outputField value="{!e.PPI__c}"/></td>
<td><apex:outputField value="{!e.Products__c}"/></td>
<td><apex:outputfield value="{!e.Shipped_Quantity__c}"/></td>
<td><apex:outputfield value="{!e.Balance_Quantity__c}"/></td>
</tr>
</apex:repeat>
<apex:repeat value="{!slist}" var="ee">
<apex:outputPanel rendered="{!new2}">
<tr>
<td></td>
<td><apex:outputfield value="{!ee.name}"/></td>
<td><apex:outputField value="{!ee.Order_Quantity__c}"/></td>
<td><apex:outputField value="{!ee.PPI__c}"/></td>
<td><apex:outputField value="{!ee.Products__c}"/></td>
<td><apex:outputfield value="{!ee.Shipped_Quantity__c}"/></td>
<td><apex:outputfield value="{!ee.Balance_Quantity__c}"/></td>
</tr>
</apex:outputPanel>
</apex:repeat>
</table>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller :

 

public class Container {
public Id poid{set;get;}
public boolean ch{set;get;}
public Container__c con{set;get;}
public boolean new1{set;get;}
public boolean new2{set;get;}
public map<id,Container_Lineitems__c> polmap{set;get;}
//public list<wrappo> pplist{set;get;}
public Container_Lineitems__c edu{set;get;}

public Container(ApexPages.StandardController controller) {
PoId=Apexpages.currentpage().getParameters().get('id');

polmap=new map<id,Container_Lineitems__c>();
//PPlist=new list<wrappo>();
new1=true;

general();
}
list<PPI_Line_items__c> polist = new list<PPI_Line_items__c>();

public void general()
{
con = [select id, PPI_No__c from Container__c where id=:PoId];

for(PPI_Line_items__c pp:[select id,Name,Order_Quantity__c,PPI__c,Products__c,Shipped_Quantity__c,Balance_Quantity__c from PPI_Line_items__c where PPI__c =:con.PPI_No__c])
{
polist.add(pp);
}
new1=true;
//new2=false;
//system.debug('new2!!!!!!!!'+ new2);
}
public list<Container_Lineitems__c> getslist()
{
return slist;
}
public list<PPI_Line_items__c> getpolist()
{
return polist;
}


list<Container_Lineitems__c> slist = new list<Container_Lineitems__c>();
list<PPI_Line_items__c> tempvalues = new list<PPI_Line_items__c>();
public void save()
{
for(PPI_Line_items__c p : tempvalues )
{
if(ch=true)
{

Container_Lineitems__c ss = new Container_Lineitems__c();
//ss.name = p.name;
ss.Order_Quantity__c = p.Order_Quantity__c;
ss.PPI__c =p.PPI__c;
ss.Products1__c = p.Products__c;
ss.Shipped_Quantity__c = p.Shipped_Quantity__c;
ss.Balance_Quantity__c =p.Balance_Quantity__c;

slist.add(ss);
insert slist;
system.debug('@@@@@@@@@'+ slist);
new2=true;
new1=false;
}
}

}
}

 

 

Thank you.

 

Srinu@dreamsSrinu@dreams

For adding one list to another list you should use 'addall' method.

 

Example:

list1.addall(list2);