• s.mafoder
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies

Hello , 

 

I need to do groupings for Data as we can do in reports like the link below :

http://www.hostingpics.net/viewer.php?id=649823GroupingDatainvisualforceandSUM.png

 

I need also to summaries data by each grouping , how can we reach this with visualforce?

i was searching for in example but i can't anything that can Help. 

 

Could you please guide me on how to reach this?

 

Many Thanks !!

Hello , 

 

Suppose I have a Salesforce Object with three fields , field1__c,field2__c,field3__c.....

I want to be able in my visualforce page to have a picklist with values field1,field2,Field3..

 

Depending on picklist selecting i update the selected field with an inputText...

 

Many thanks for your Help!!

Hello , 

I'm struggling for a while with a visualforce page. This Page should have two filters . a filter that determine how many columns to display , and another to determine data to display. 

 

I used a wrapper class to do so and a map. My problem now is that i can't update the map values from visualforce page :

 

Here is my page :

 

<apex:page controller="wrapperClassController2" action="{!init}">

    <apex:form >

    <apex:commandButton value="Filter" action="{!filter}"/>
       
        <apex:pageBlock >
             <apex:pageBlockSection columns="2" >
        <apex:selectList multiselect="true" size="5" value="{!FilterProduit}" >
                <apex:selectOptions value="{!modeles}"/>
       </apex:selectList>
       <apex:selectList value="{!Filterdealer}" size="1" id="Filterdealer">
          <apex:selectOptions value="{!Dealers}"/>
       </apex:selectList>
        </apex:pageBlockSection>
         
          
          
        </apex:pageBlock>
   
   
    <table border="1">
    <tr>
     <th>Name</th>
     <th>Email</th>
    
     <apex:repeat value="{!lstmodeles }" var="item">
       
       <th><apex:outputText value="{!item.Name}"/></th>
    
        
      </apex:repeat>
      </tr>
      <apex:repeat value="{!lignes}" var="item">
     
      <tr>
      
      <td width="20%"><apex:outputText value="{!item.con.Name}"/></td>
      <td width="20%"><apex:outputText value="{!item.con.Email}"/></td>
        <apex:repeat value="{!lstmodeles }" var="c"> 
   
      <td width="20%"><apex:inputText value="{!item.volumeparmodele[c.Id]}"/></td>   
      </apex:repeat>
     
     </tr> 
    </apex:repeat>
      
    </table>
    <apex:commandButton value="Save" action="{!save}"/>
  </apex:form>
</apex:page>

 And the controller : 

public class wrapperClassController2 
{
publi<c class Ligne
{
    public Contact con {get; set;}
    public Map <String,Integer> volumeparmodele  {get; set;}
    public Ligne(Contact c, Map <String,Integer> volumeparmodele2 )
    {
            this.con = c;
            this.volumeparmodele =volumeparmodele2  ;
    }
}

    //Our collection of the class/wrapper objects cContact 
    public List<Ligne> lignes{get; set;}
    public String FilterProduit {get; set;}
    public String FilterDealer {get; set;}
   // public List<Product2> modeles{get; set;}
    public list<SelectOption> lst {get; set;}
    public List<Product2> lstmodeles {get; set;}
    public  Set<Id> idmodeles{get; set;}
    
    public Map<String,Integer> volumeparmodele{get; set;}
    
    public void init()
    {   
        volumeparmodele=new Map<String,Integer>();
        List<Product2>lstmodelesAll=new List<Product2>(); 
        lstmodelesAll =[select Id,Name from Product2];
        for(Product2 product:lstmodelesAll )
         {
            volumeparmodele.put(product.Id,0);
         }
    
    }
    
public Pagereference filter()
{
  
  lstmodeles =new List<Product2>();
  idmodeles=new Set<Id>();
  List<String>lststring=FilterProduit.split(','); 
   for(Integer i=0;i<lststring.size();i++)
   {
   
            if(lststring[i]!='')
            { 
                String s2 = lststring[i].removeStart('[');
                String s3 = s2.removeEnd(']');
                Id myId=s3.trim();
                idmodeles.add(myId);
            }
   
   }
  
    lstmodeles =[select Id,Name from Product2 where Id IN:idmodeles];
     
        if(lignes== null)
        {
            lignes= new List<Ligne>();
            for(Contact c : [select Id, Name, Email, Phone from Contact limit 10]){
          
                
                lignes.add(new Ligne(c,volumeparmodele));
            }
        }
    
    return null;
    
    }
    public List<SelectOption> getDealers() 
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','- None -'));
        List<Contact> Lstcontacts =new List<Contact> ();
        Lstcontacts =[select Id,Name from contact];
        for(Contact contact : Lstcontacts )
        {
                   
                   
            options.add(new SelectOption(contact.Id, contact.Name));  
                    
        }
               
        return options;
    
    
    }
    public List<SelectOption> getModeles()
    {
      lst = new List<SelectOption>() ;
      List<Product2> modeles=new List<Product2>();
      modeles=[select Id,Name from Product2];
      for(Product2 product:modeles)
      {
         lst.add(new SelectOption(product.Id, product.Name)) ;
      }
      return lst; 
    
    
    
    }
    
    //This method uses a simple SOQL query to return a List of Contacts
    public Pagereference save()
    {
       System.debug('#######save');
       List<CustomerOrders__c> lstcustomerorders=new List<CustomerOrders__c >();
       
       lstmodeles =[select Id,Name from Product2 where Id IN:idmodeles];

       for(Integer i=0;i<lignes.size();i++)
       {
       CustomerOrders__c customorder=new CustomerOrders__c ();
       customorder.Contact__c=lignes[i].con.Id;
       //comment insérer le volume
       customorder.Volume__c=lignes[i].volumeparmodele.get('01td0000001BDD5');
       //comment insrer le produit a partir du MAP
       customorder.Product__c='01td0000001BDD5';
       lstcustomerorders.add(customorder);
       
       
       }
       System.debug('#######lstcustomerorders'+lstcustomerorders.size());
       insert lstcustomerorders;
       return null;
    
    
    
    }


    
 
   
 
}

 So on the Save method how can i update the Map values depending on what the user enter?

 

It is very urgent and i hope you can Help me. 

 

Ti test the code , you can simply Add an object related to a contact and a product  and add a custom field named "Volume__c".

 

Many Thanks

 

 

 

Hello , 

 

I have a visualforce page that let a user select many records and then the user should click on a button to go to another page to update records selected (its like the add prodcut in an opportunity). 

 

The problem am facing , is that i'm able to get ids of elements selected , but i dont know how to pass the list of ids to the other page...

 

Here is the visualforce page : 

 

<apex:page controller="CCW_ContactPaginationController2">
 
    <script type="text/javascript">
 
        /*
        *    function to handle checkbox selection
        */
        function doCheckboxChange(cb,itemId){
 
            if(cb.checked==true){
                aSelectItem(itemId);
            }
            else{
                aDeselectItem(itemId);
            }
 
        }
 
    </script>
 
    <apex:form >
 <apex:commandbutton value="Update selected records" action="{!updateselected}"/>
        <!-- handle selected item -->
        <apex:actionFunction name="aSelectItem" action="{!doSelectItem}" rerender="mpb">
            <apex:param name="contextItem" value="" assignTo="{!contextItem}"/>
        </apex:actionFunction>
 
        <!-- handle deselected item -->
        <apex:actionFunction name="aDeselectItem" action="{!doDeselectItem}" rerender="mpb">
            <apex:param name="contextItem" value="" assignTo="{!contextItem}"/>
        </apex:actionFunction>
 
        <apex:pageBlock title="CloudClickware Pagination Sample" id="mpb">
 
            <!-- table of data -->
            <apex:pageBlockTable title="Contacts" value="{!contacts}" var="c">
                <apex:column >
                    <apex:facet name="header">Action</apex:facet>
                    <apex:inputCheckbox value="{!c.IsSelected}" onchange="doCheckboxChange(this,'{!c.tContact.Id}')"/>
                </apex:column>
                <apex:column value="{!c.tContact.FirstName}"/>
                <apex:column value="{!c.tContact.LastName}"/>
                <apex:column value="{!c.tContact.Title}"/>
                <apex:column value="{!c.tContact.Phone}"/>
                <apex:column value="{!c.tContact.Email}"/>
            </apex:pageBlockTable>
 
            <!-- count of selected items -->
            <apex:outputLabel value="[{!selectedCount} records selected]" />
 
            <br/>
 
            <!-- next, previous and page info -->
            <apex:commandLink action="{!doPrevious}" rendered="{!hasPrevious}" value="Previous" />
            <apex:outputLabel rendered="{!NOT(hasPrevious)}" value="Previous" />
 
            <apex:outputLabel value=" (page {!pageNumber} of {!totalPages}) " />
 
            <apex:commandLink action="{!doNext}" rendered="{!hasNext}" value="Next" />
            <apex:outputLabel rendered="{!NOT(hasNext)}" value="Next" />
 
        </apex:pageBlock>
 
    </apex:form>
 
</apex:page>

 And the controler class :

 

 

public with sharing class CCW_ContactPaginationController2 {
 
    /*
    *   item in context from the page
    */
    public String contextItem{get;set;}
 
    /*
    *   set controller
    */
    private ApexPages.StandardSetController setCon;
 
    /*
    *   the contact ids selected by the user
    */
    private Set<Id> selectedContactIds;
 
    /*
    *   constructor
    */
    public CCW_ContactPaginationController2 ()
    {
        //init variable
        this.selectedContactIds= new Set<Id>();
 
        //gather data set
        this.setCon= new ApexPages.StandardSetController( [SELECT Id, FirstName, LastName, Title, Phone, Email FROM Contact] );
        this.setCon.setpageNumber(1);
        this.setCon.setPageSize(10);
 
    }
 
    /*
    *   handle item selected
    */
    public void doSelectItem(){
 
        this.selectedContactIds.add(this.contextItem);
 
    }
 
    /*
    *   handle item deselected
    */
    public void doDeselectItem(){
 
        this.selectedContactIds.remove(this.contextItem);
 
    }
 
    /*
    *   return count of selected items
    */
    public Integer getSelectedCount(){
 
        return this.selectedContactIds.size();
 
    }
    public Pagereference updateselected()
    {
    
       return null;
    
    }
 
    /*
    *   advance to next page
    */
    public void doNext(){
 
        if(this.setCon.getHasNext())
            this.setCon.next();
 
    }
 
    /*
    *   advance to previous page
    */
    public void doPrevious(){
 
        if(this.setCon.getHasPrevious())
            this.setCon.previous();
 
    }
 
    /*
    *   return current page of groups
    */
    public List<CCWRowItem> getContacts(){
 
        List<CCWRowItem> rows = new List<CCWRowItem>();
 
        for(sObject r : this.setCon.getRecords()){
            Contact c = (Contact)r;
 
            CCWRowItem row = new CCWRowItem(c,false);
            if(this.selectedContactIds.contains(c.Id)){
                row.IsSelected=true;
            }
            else{
                row.IsSelected=false;
            }
            rows.add(row);
        }
 
        return rows;
 
    }
 
    /*
    *   return whether previous page exists
    */
    public Boolean getHasPrevious(){
 
        return this.setCon.getHasPrevious();
 
    }
 
    /*
    *   return whether next page exists
    */
    public Boolean getHasNext(){
 
        return this.setCon.getHasNext();
 
    }
 
    /*
    *   return page number
    */
    public Integer getPageNumber(){
 
        return this.setCon.getPageNumber();
 
    }
 
    /*
    *    return total pages
    */
    Public Integer getTotalPages(){
 
        Decimal totalSize = this.setCon.getResultSize();
        Decimal pageSize = this.setCon.getPageSize();
 
        Decimal pages = totalSize/pageSize;
 
        return (Integer)pages.round(System.RoundingMode.CEILING);
    }
 
    /*
    *   helper class that represents a row
    */
    public with sharing class CCWRowItem{
 
        public Contact tContact{get;set;}
        public Boolean IsSelected{get;set;}
 
        public CCWRowItem(Contact c, Boolean s){
            this.tContact=c;
            this.IsSelected=s;
        }
 
    }
}

 

So how can i implement this in that method :

 

    public Pagereference updateselected()
    {
    
       return null;
    
    }

So i can pass selected ids in Page2

Hello , 

 

I have a trigger which purpose is when updating an account owner with an inactive user , we should activate this user first , update the account and then deactivate the user . 

 

I used in my before trigger on account 2 methods , on that activate the user , and an other methode (annoted with @future) to update the account , But I still get the DML exception : 

 

Here is the code of the trigger : 

 

trigger AccountBeforeInser on Account (before update) 
{
	  
	
	
	//TR001 :
	//whene inserting an Account by dataloader batch the trigger fill lookup fields
	
	   
	       
	       Set<Id> UsersIds = new Set<Id>();
	       Set<Id> AccIds = new Set<Id>();
	      
	       for(Account account : Trigger.new)
	       {
	             
	                  UsersIds.add(account.OwnerId);
	                  AccIds.add(account.Id);
	                
	                  
	       }
	       
	       if(UsersIds.size()>0)
	       {
	       		
	          
	           TR001Account.FillLookupFields(UsersIds);
	           TR001Account.updateAccounts(AccIds);
	          
	       
	       }
	       


}

 And the class TR001Account : 

 

public with sharing class TR001Account 
{
	  public static void FillLookupFields(Set<Id> UsersIds)
	  {
	  	List<User> users=[select Id,IsActive from User where Id IN :UsersIds];
	  	
	 
	   
	    for(User user:users)
	    {
	    	if(user.IsActive==false)
	    	user.IsActive=true;
	    	
	    	
	    	
	   
	    	
	    	
	    }
	  	
	  	update users;
  
	  	
	  }
	  @future
	  public static void updateAccounts(Set<ID> accountIds)
	  {
	  	
			  List<Account> accountsToUpdate =	[Select Name from Account where Id IN : accountIds];
			  for(Account acc :accountsToUpdate)
			  {
			  	acc.Name='true future';
			  }
			  update accountsToUpdate;
	  	
	  }
	  
	  
	  
	  
	  
	  

}

 I really rely on your Help !!

Hi Everyone,

I am new to Salesforce coding and learning to integrate with Salesforce. I am facing issue as mentioned below.

Scenario - I am integrating two Salesforce instance using APEX Callout and REST API. In the source SFDC instance I have created a trigger on the Account Object that calls a class with @future annotation. This class sends out a HTTP Request to the other SFDC instance using Web Server Authentication Flow.

Issue Description - Per the defined steps in 'Getting Started with the Force.com REST API' guide, I create a Connected App record in the Destination SFDC instance. But when the APEX code is requesting the Salesforce Authorization Endpoint with the relevant parameters (response_type, client_id, redirect_uri), I am not able to retrieve the Authorization Code (Code) that comes along with the Callback URL.
Though, I am successfully redirected to the callback URL (appended with the code) when I am using a browser. See below the request and the redirected response I get when I do it in a browser - 
HTTP Request:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=[client_id taken from the Connected App record]&redirect_uri=https://localhost:8443/RestTest/oauth/_callback&immediate=true
HTTP Response:
http://localhost:8443/RestTest/oauth/_callback?code=[aPrxg.........]%3D%3D

Problem Statements - 
1. On the first place, is it possible to programmatically extract the code from the HTTP response?

2. If the answer to the above question is 'Yes', then please suggest, how? What are the relevant methods to extract this information.

Thanks
Anupam

Hello , 

 

I need to do groupings for Data as we can do in reports like the link below :

http://www.hostingpics.net/viewer.php?id=649823GroupingDatainvisualforceandSUM.png

 

I need also to summaries data by each grouping , how can we reach this with visualforce?

i was searching for in example but i can't anything that can Help. 

 

Could you please guide me on how to reach this?

 

Many Thanks !!

Hello , 

 

Suppose I have a Salesforce Object with three fields , field1__c,field2__c,field3__c.....

I want to be able in my visualforce page to have a picklist with values field1,field2,Field3..

 

Depending on picklist selecting i update the selected field with an inputText...

 

Many thanks for your Help!!

Hello , 

I'm struggling for a while with a visualforce page. This Page should have two filters . a filter that determine how many columns to display , and another to determine data to display. 

 

I used a wrapper class to do so and a map. My problem now is that i can't update the map values from visualforce page :

 

Here is my page :

 

<apex:page controller="wrapperClassController2" action="{!init}">

    <apex:form >

    <apex:commandButton value="Filter" action="{!filter}"/>
       
        <apex:pageBlock >
             <apex:pageBlockSection columns="2" >
        <apex:selectList multiselect="true" size="5" value="{!FilterProduit}" >
                <apex:selectOptions value="{!modeles}"/>
       </apex:selectList>
       <apex:selectList value="{!Filterdealer}" size="1" id="Filterdealer">
          <apex:selectOptions value="{!Dealers}"/>
       </apex:selectList>
        </apex:pageBlockSection>
         
          
          
        </apex:pageBlock>
   
   
    <table border="1">
    <tr>
     <th>Name</th>
     <th>Email</th>
    
     <apex:repeat value="{!lstmodeles }" var="item">
       
       <th><apex:outputText value="{!item.Name}"/></th>
    
        
      </apex:repeat>
      </tr>
      <apex:repeat value="{!lignes}" var="item">
     
      <tr>
      
      <td width="20%"><apex:outputText value="{!item.con.Name}"/></td>
      <td width="20%"><apex:outputText value="{!item.con.Email}"/></td>
        <apex:repeat value="{!lstmodeles }" var="c"> 
   
      <td width="20%"><apex:inputText value="{!item.volumeparmodele[c.Id]}"/></td>   
      </apex:repeat>
     
     </tr> 
    </apex:repeat>
      
    </table>
    <apex:commandButton value="Save" action="{!save}"/>
  </apex:form>
</apex:page>

 And the controller : 

public class wrapperClassController2 
{
publi<c class Ligne
{
    public Contact con {get; set;}
    public Map <String,Integer> volumeparmodele  {get; set;}
    public Ligne(Contact c, Map <String,Integer> volumeparmodele2 )
    {
            this.con = c;
            this.volumeparmodele =volumeparmodele2  ;
    }
}

    //Our collection of the class/wrapper objects cContact 
    public List<Ligne> lignes{get; set;}
    public String FilterProduit {get; set;}
    public String FilterDealer {get; set;}
   // public List<Product2> modeles{get; set;}
    public list<SelectOption> lst {get; set;}
    public List<Product2> lstmodeles {get; set;}
    public  Set<Id> idmodeles{get; set;}
    
    public Map<String,Integer> volumeparmodele{get; set;}
    
    public void init()
    {   
        volumeparmodele=new Map<String,Integer>();
        List<Product2>lstmodelesAll=new List<Product2>(); 
        lstmodelesAll =[select Id,Name from Product2];
        for(Product2 product:lstmodelesAll )
         {
            volumeparmodele.put(product.Id,0);
         }
    
    }
    
public Pagereference filter()
{
  
  lstmodeles =new List<Product2>();
  idmodeles=new Set<Id>();
  List<String>lststring=FilterProduit.split(','); 
   for(Integer i=0;i<lststring.size();i++)
   {
   
            if(lststring[i]!='')
            { 
                String s2 = lststring[i].removeStart('[');
                String s3 = s2.removeEnd(']');
                Id myId=s3.trim();
                idmodeles.add(myId);
            }
   
   }
  
    lstmodeles =[select Id,Name from Product2 where Id IN:idmodeles];
     
        if(lignes== null)
        {
            lignes= new List<Ligne>();
            for(Contact c : [select Id, Name, Email, Phone from Contact limit 10]){
          
                
                lignes.add(new Ligne(c,volumeparmodele));
            }
        }
    
    return null;
    
    }
    public List<SelectOption> getDealers() 
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','- None -'));
        List<Contact> Lstcontacts =new List<Contact> ();
        Lstcontacts =[select Id,Name from contact];
        for(Contact contact : Lstcontacts )
        {
                   
                   
            options.add(new SelectOption(contact.Id, contact.Name));  
                    
        }
               
        return options;
    
    
    }
    public List<SelectOption> getModeles()
    {
      lst = new List<SelectOption>() ;
      List<Product2> modeles=new List<Product2>();
      modeles=[select Id,Name from Product2];
      for(Product2 product:modeles)
      {
         lst.add(new SelectOption(product.Id, product.Name)) ;
      }
      return lst; 
    
    
    
    }
    
    //This method uses a simple SOQL query to return a List of Contacts
    public Pagereference save()
    {
       System.debug('#######save');
       List<CustomerOrders__c> lstcustomerorders=new List<CustomerOrders__c >();
       
       lstmodeles =[select Id,Name from Product2 where Id IN:idmodeles];

       for(Integer i=0;i<lignes.size();i++)
       {
       CustomerOrders__c customorder=new CustomerOrders__c ();
       customorder.Contact__c=lignes[i].con.Id;
       //comment insérer le volume
       customorder.Volume__c=lignes[i].volumeparmodele.get('01td0000001BDD5');
       //comment insrer le produit a partir du MAP
       customorder.Product__c='01td0000001BDD5';
       lstcustomerorders.add(customorder);
       
       
       }
       System.debug('#######lstcustomerorders'+lstcustomerorders.size());
       insert lstcustomerorders;
       return null;
    
    
    
    }


    
 
   
 
}

 So on the Save method how can i update the Map values depending on what the user enter?

 

It is very urgent and i hope you can Help me. 

 

Ti test the code , you can simply Add an object related to a contact and a product  and add a custom field named "Volume__c".

 

Many Thanks

 

 

 

Hello , 

 

I have a visualforce page that let a user select many records and then the user should click on a button to go to another page to update records selected (its like the add prodcut in an opportunity). 

 

The problem am facing , is that i'm able to get ids of elements selected , but i dont know how to pass the list of ids to the other page...

 

Here is the visualforce page : 

 

<apex:page controller="CCW_ContactPaginationController2">
 
    <script type="text/javascript">
 
        /*
        *    function to handle checkbox selection
        */
        function doCheckboxChange(cb,itemId){
 
            if(cb.checked==true){
                aSelectItem(itemId);
            }
            else{
                aDeselectItem(itemId);
            }
 
        }
 
    </script>
 
    <apex:form >
 <apex:commandbutton value="Update selected records" action="{!updateselected}"/>
        <!-- handle selected item -->
        <apex:actionFunction name="aSelectItem" action="{!doSelectItem}" rerender="mpb">
            <apex:param name="contextItem" value="" assignTo="{!contextItem}"/>
        </apex:actionFunction>
 
        <!-- handle deselected item -->
        <apex:actionFunction name="aDeselectItem" action="{!doDeselectItem}" rerender="mpb">
            <apex:param name="contextItem" value="" assignTo="{!contextItem}"/>
        </apex:actionFunction>
 
        <apex:pageBlock title="CloudClickware Pagination Sample" id="mpb">
 
            <!-- table of data -->
            <apex:pageBlockTable title="Contacts" value="{!contacts}" var="c">
                <apex:column >
                    <apex:facet name="header">Action</apex:facet>
                    <apex:inputCheckbox value="{!c.IsSelected}" onchange="doCheckboxChange(this,'{!c.tContact.Id}')"/>
                </apex:column>
                <apex:column value="{!c.tContact.FirstName}"/>
                <apex:column value="{!c.tContact.LastName}"/>
                <apex:column value="{!c.tContact.Title}"/>
                <apex:column value="{!c.tContact.Phone}"/>
                <apex:column value="{!c.tContact.Email}"/>
            </apex:pageBlockTable>
 
            <!-- count of selected items -->
            <apex:outputLabel value="[{!selectedCount} records selected]" />
 
            <br/>
 
            <!-- next, previous and page info -->
            <apex:commandLink action="{!doPrevious}" rendered="{!hasPrevious}" value="Previous" />
            <apex:outputLabel rendered="{!NOT(hasPrevious)}" value="Previous" />
 
            <apex:outputLabel value=" (page {!pageNumber} of {!totalPages}) " />
 
            <apex:commandLink action="{!doNext}" rendered="{!hasNext}" value="Next" />
            <apex:outputLabel rendered="{!NOT(hasNext)}" value="Next" />
 
        </apex:pageBlock>
 
    </apex:form>
 
</apex:page>

 And the controler class :

 

 

public with sharing class CCW_ContactPaginationController2 {
 
    /*
    *   item in context from the page
    */
    public String contextItem{get;set;}
 
    /*
    *   set controller
    */
    private ApexPages.StandardSetController setCon;
 
    /*
    *   the contact ids selected by the user
    */
    private Set<Id> selectedContactIds;
 
    /*
    *   constructor
    */
    public CCW_ContactPaginationController2 ()
    {
        //init variable
        this.selectedContactIds= new Set<Id>();
 
        //gather data set
        this.setCon= new ApexPages.StandardSetController( [SELECT Id, FirstName, LastName, Title, Phone, Email FROM Contact] );
        this.setCon.setpageNumber(1);
        this.setCon.setPageSize(10);
 
    }
 
    /*
    *   handle item selected
    */
    public void doSelectItem(){
 
        this.selectedContactIds.add(this.contextItem);
 
    }
 
    /*
    *   handle item deselected
    */
    public void doDeselectItem(){
 
        this.selectedContactIds.remove(this.contextItem);
 
    }
 
    /*
    *   return count of selected items
    */
    public Integer getSelectedCount(){
 
        return this.selectedContactIds.size();
 
    }
    public Pagereference updateselected()
    {
    
       return null;
    
    }
 
    /*
    *   advance to next page
    */
    public void doNext(){
 
        if(this.setCon.getHasNext())
            this.setCon.next();
 
    }
 
    /*
    *   advance to previous page
    */
    public void doPrevious(){
 
        if(this.setCon.getHasPrevious())
            this.setCon.previous();
 
    }
 
    /*
    *   return current page of groups
    */
    public List<CCWRowItem> getContacts(){
 
        List<CCWRowItem> rows = new List<CCWRowItem>();
 
        for(sObject r : this.setCon.getRecords()){
            Contact c = (Contact)r;
 
            CCWRowItem row = new CCWRowItem(c,false);
            if(this.selectedContactIds.contains(c.Id)){
                row.IsSelected=true;
            }
            else{
                row.IsSelected=false;
            }
            rows.add(row);
        }
 
        return rows;
 
    }
 
    /*
    *   return whether previous page exists
    */
    public Boolean getHasPrevious(){
 
        return this.setCon.getHasPrevious();
 
    }
 
    /*
    *   return whether next page exists
    */
    public Boolean getHasNext(){
 
        return this.setCon.getHasNext();
 
    }
 
    /*
    *   return page number
    */
    public Integer getPageNumber(){
 
        return this.setCon.getPageNumber();
 
    }
 
    /*
    *    return total pages
    */
    Public Integer getTotalPages(){
 
        Decimal totalSize = this.setCon.getResultSize();
        Decimal pageSize = this.setCon.getPageSize();
 
        Decimal pages = totalSize/pageSize;
 
        return (Integer)pages.round(System.RoundingMode.CEILING);
    }
 
    /*
    *   helper class that represents a row
    */
    public with sharing class CCWRowItem{
 
        public Contact tContact{get;set;}
        public Boolean IsSelected{get;set;}
 
        public CCWRowItem(Contact c, Boolean s){
            this.tContact=c;
            this.IsSelected=s;
        }
 
    }
}

 

So how can i implement this in that method :

 

    public Pagereference updateselected()
    {
    
       return null;
    
    }

So i can pass selected ids in Page2

Hi everyone,

 

    I am a newbie to FDC (so please correct me if I am wrong anywhere) . I have gone thorugh Apex REST API and found that we can create our custom web services in Apex and expose them as REST services using Apex REST. But in most of the references it is given that we can use any programming language of our choice ( i.e. from outside FDC) to invoke this custom WS via REST API. But I want to invoke the same using Apex code (i.e., from inside FDC) via REST API.

 

Any help is highly appreciated

  • August 25, 2011
  • Like
  • 0