+ Start a Discussion

Display selected product in the correct section(bin) on vf page


I have a custom object Product_Serial which has a lookup field to another custom object bin.

I want to create  a list button "Check Location" on the Product Serials.

When a product serial record is selected,we are redirected to a vf page which displays all the available bins.

Now i need to display the product_serial selected in the appropriate bin that it belongs to.


I just tried to write a simple custom controller which displays all the bins.
Iam displaying these as a datalist table.Not able to map the product serial records to display under the correct bin.
How to map this two tables together?Please help.



The controller:

public class location {
public  List<Bin__c> pbin=new List<Bin__c>();
public  List<Product_serial__c> pserial=new List<Product_serial__c>();
public location(){

pbin=[select d.id, d.name  from  bin__c d limit 3 ];
pserial=[select id, name,serial_number__c from  product_serial__c where id = :ApexPages.currentPage().getParameters().get('id') ];

public List<Bin__c>getBin()
        return pbin;
public List<Product_Serial__c>getSerial()
        return pserial;   


vf page:

<apex:page  Controller="location" >

<apex:dataTable value="{!Bin}" var="a" border="1" title="Bins" width="500"  align="center"  >
<apex:column  value="{!a.name}"/>


I think you can do it through Wrapper Class. see use of Wrapper Class in Apex.


Also provide some geographical view for more reference to your question.