+ Start a Discussion
benkurianbenkurian 

Passing a list of ids from one controller to another

Hi All,

 

I have a code with passing id  to apex class via visualforce page URL methode and that id i need to pass to another class.i will past the code for the same but its not working.Thanks in advance.

 

page one:

<apex:commandLink value="{!applicant.Deal_Name__c}"
                            action="/apex/Deal_Items?id={!applicant.Deal_Name__c}"> //by passing url to another page
                            <apex:param name="id" value="{!applicant.Deal_Name__c}" />

                        </apex:commandLink>

 

page two

{

//getting the id here but its not to getting page two Component controlle

 

}

 

page two controller:

public class pagetwocontroller{
 public String selectedName {get;set;}  
 public pagetwocontroller()  
 {  
   selectedName = ApexPages.currentPage().getParameters().get('id');  
 }

// some codes  

}

 

page two Component controller: 

{

 

how to get page-two-controller id  to this controller.

 

}

 

 

 

 

 

Subramani_SFDCSubramani_SFDC

Use page reference for passing id

 

public PageReference Go() {
     selectedName  = System.currentPageReference().getParameters().get('id');
      PageReference nextpage = new PageReference('/apex/CustomTeam?id='+selectedName );
                return nextpage;
    }
  

 

<apex:commandLink action="{!Go}">
                               {!applicant.Deal_Name__c.name}<apex:param name="id" value="{!t.selectedName }"/>
                            </apex:commandLink>

 

 

In the second controller u get the id by following way....

 

Id id=ApexPages.currentpage().getParameters().get('id');

Satyendra RawatSatyendra Rawat

Hi,

 

write the page action method in page two and then get the Id;

 and page whrer you adding component 

<c:myComponent dealName="{!selectedName}" />

or

<c:myComponent dealName="{!id}" />

 

in component controller you can access the value like

 

public Componentcontroller()

{

   strName = ApexPages.currentPage().getParameters().get('dealName');  

}

 

 

public void pageTwoAction()

{

  selectedName = ApexPages.currentPage().getParameters().get('id');  

}

benkurianbenkurian

Hi sathya,

Thanks for the replay...i  did the concept what u gave but its not working...i will post my code here

 

*i have a main page with below code when i click particular item(master item) it will moves into the next page showing detailed page with child items  plus that particular items whole fileds are showing there...but for showing child items am using java script ie editable grid is using with CRUD functionality and its is put at in visualforce component .In detailed page its showing the detailed view of particular master items but the child items are not showing.i need to pass particular master item id into visualforce component.How to do it  and  i will post the code for that.Actually am new to apex so please help me.

master page:

<apex:commandLink value="{!applicant.Deal_Name__c}"
                            action="/apex/Deal_Items?id={!applicant.Deal_Name__c}">
                            <apex:param name="id" value="{!applicant.Deal_Name__c}" />//for selecting particular master item and it will moves into deatiled page.

 

Deatailed Page controller:

public class DealItems_controller{
 public String selectedName {get;set;}  
 public TP_Deal_Headers__c sbook;  
 public DealItems_controller()  
 {  

     selectedName = ApexPages.currentPage().getParameters().get('id');  //getting the id from main page to detailed page
 }   

public TP_Deal_Headers__c getSbook()  
 {  
      sbook=[SELECT Vendor_Name__c,Deal_Name__c,Deal_Type__c,Deal_Start_Date__c,Deal_End_Date__c,Status__c,UPC_Code__c,Deal_Order_Date__c,Deal_Submitted_Date__c from TP_Deal_Headers__c where Deal_Name__c=:selectedName]; 
      
      return sbook;  
}
//its showing the detailed view of master item
}

UPTO THIS MUCH IS CORRECT

 

Detailed page:

<c:extjsdatagrid object="TP_Deal_Headers__c"
                    fields="Id,Deal_Name__c,Deal_Type__c,Deal_Start_Date__c" rows="18"
                    value="{!selectValue}" /> // calling th editable grid  to detailed page.

 

Component:

<apex:attribute name="value" assignTo="{!selectValue}" required="true"
        type="String" description="A merge feld that references" />// callling id  from page to component controller

 

Component controller:

Public Componetcontroller{

public static String selectValue{get;set;}//getting the value to controller

 

public Componentcontroller()

{

   strName = ApexPages.currentPage().getParameters().get('selectValue');  

}

// i did this manner its not working.

QueryObj{//declaring some values

}

 

@RemoteAction

public static queryresponse query(QueryObj qobj) {

 String qstr =  'SELECT ' + qobj.fields + ' FROM ' + qobj.sobjname+  ' where Deal_Name__c = \'' + strName +'\'';

Database.query(qstr)

 

}

 

}

 

 

 

 

 

Satyendra RawatSatyendra Rawat

Hi,

 

used the two way you can get the value

1. write one getter and setter for asignto value;

 

<apex:attribute name="value" assignTo="{!selectValue}" required="true"
        type="String" description="A merge feld that references" />

public string selectValue{get; set;}

 

2.

public Componentcontroller()

{

  // strName = ApexPages.currentPage().getParameters().get('selectValue');  

strName = ApexPages.currentPage().getParameters().get('value');

}