0

I have a VF Page where I'm displaying list of Contacts as a command link. Once i click on any contact, it redirects me to a new page which displays some data (coming from another object which has a lookup on Contact) of all contacts (This is done). My requirement is once i click on any contact, in the second page, it should only display the data related to selected contact. Thanks in advance.

First Page (List of Contacts)
<apex:form >
    <apex:pageBlock title="Portfolio Services">
        <apex:pageBlockTable value="{!Conlst}" var="C">
        <apex:commandLink action="{!ViewData}">{!C.Name}</apex:commandLink>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>

Second Page

<apex:form >  
<tr>
<td style="padding-left: 30px"><b><apex:outputText value="Portfolio Details of {!lstContact}"/></b></td>
                    <td></td>

                <tr>

                    <td colspan="2" width="70%">
                       <br/> 
                        <table width="35%">
                            <tr>
                                <td >
                            <apex:commandButton action="{!display}" value="Activity Detail" reRender="ActivityDetailBlock" status="status"/>
                                </td>
                                <td align="right">
                                </td>
                            </tr>
                     <apex:outputPanel id="ActivityDetailBlock" style="width:100%">
                      <apex:pageBlock rendered="{!displayBlock}" id="theBlock">
                        <apex:pageBlockSection title="Activity Details" >
                        <apex:pageBlockSectionItem >
                        <apex:pageBlockTable value="{!listTransaction}" var="trans">
                         <apex:column value="{!trans.Product__c}" width="20%" />
                        <apex:column value="{!trans.Quantity__c}" width="20%"/>
                        <apex:column value="{!trans.Product__r.Price__c}" width="20%"/>
                        <apex:column value="{!trans.Order_Type__c}" width="20%"/>
                        <apex:column value="{!trans.Transaction_Date__c}" width="20%"/>                           
                        </apex:pageBlockTable>
                        </apex:pageBlockSectionItem>
                        </apex:pageBlockSection>
                        </apex:pageBlock>
                        </apex:outputPanel>
                         </td>
                        </tr>
                    </tr>
                 </apex:form> 

Controller

public class Transactionrecordnew { 
public Boolean displayBlock{ get; set; }

public string ClientId{get;set;}
Public String selectedName {get;set;}
public string ProductId{get;set;}    
public List<Contact> lstContact {get; set;}

 public list<Transaction__c >listTransaction{get;set;}
 public list<Transaction__c >listTransaction1{get;set;}
  public Transactionrecordnew()
   {
      getTransaction();
      displayBlock = false;
      Conlst = [select Id,Name, Group__c  from Contact where Group__c='Client'];
     assets=null;
    }
   public void getTransaction()
     {
      listTransaction=new list<Transaction__c >([select name, Account__c, Amount__c,Category__c, Client_ID__c, CMP__c, Gain_Loss__c, Order_Type__c, Product__c,Product_Code__c, Product__r.Price__c, Quantity__c, Transaction_Date__c, Yield__c from Transaction__c]);
   }

     public PageReference display() {
        displayBlock = true;
        return null;
      }

     public PageReference TaxInfo(){


     PageReference reRend = new PageReference('/015/o');
     return reRend;
    }

     public void showTransactions(){
     listTransaction1 =  [Select name, Account__c, Amount__c, Category__c,Client_ID__c,CMP__c, Gain_Loss__c, Order_Type__c, Product__c, Product_Code__c,Product__r.Price__c, Quantity__c, Transaction_Date__c, Yield__c from Transaction__c where Client_ID__c != NULL AND Product__c=: ProductId];  
    }  

   public class cContact{
    public Contact con{get; set;}
    public Boolean selected{get;set;}

    public cContact(Contact c){
        con = c;
        selected = false;
        System.debug('con'+con);
        System.debug('selected'+selected);
       }
    }


public string recid{get;set;}
 public string Client {get;set;}

 public string row{ get; set;}
public list<Contact> Conlst{get;set;}
 Public Contact C;

 public List<Asset> assets {get; set;}

  pagereference ref =new pagereference('/apex/customtable');
 ref.setredirect(true);
 return ref;

}

public PageReference ViewData() {
pagereference ref =new pagereference('/apex/PortfolioDetails');
 ref.setredirect(true);
  return ref;
  }

public void setupAssets()
{
  assets=[select id, Asset_Class__c, Name from Asset where ContactId=:recId];
    }

   public PageReference displayTable() {
    return null;
   }
   }

1 Answer 1

1

From what I am reading, you are loading the second page without any reference from the first page.

public PageReference ViewData() {
pagereference ref =new pagereference('/apex/PortfolioDetails');
 ref.setredirect(true);
  return ref;
  }

you probably want to append ?id=XXXXXXXXXXX to the page reference so the controller can read for an ID and look up the contact's transactions that way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .