• Bridgetree
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 45
    Replies

Hi everyone


                I want to create a pageBlockTable such that, where in i have two fields for a custom Object. The Two fields are

1 . Lookup for Contact

2. Email.

 

Now in the pageBlockTable, i have a Add-Row functionality, upon doing this, i will have new row in the pageBlockTable.

The pageBlockTable has two fields.

        Contact Name (lookup)

        Email.

 

Now when i select the contact in the pageBlockTable, the related email should populate in the email field.

remember the pageBlockTable is refered to the Custom Object.

Please let me know the solution please.

Thanks in advance.

Hello All...

 

                       Can anyone tell me how to add a Validation to a PickList.

The Scenario is something Like this. I have a Areas fields of type Multi select Picklist and Probably 10 Values. At the time of Creation i should be able to Select a maximum of Three areas only.

 

                      How can i add the validation to the Multiselect Picklist

Hello Everyone.

 

                I was doing a Salesforce to Salesforce Migration from One Org to Another. This went fine for Accounts and Contacts. But when i tried to Transfer Contact, The related Opportunities are not getting Transferred.

I had read about Publishing Objects in the link below

 which tells us how to setup the connect.

As salesforce doesnot allow Junction Object to migrate Up, is any solution for the Problem i am facing.  I need to Transfer Contacts and related Opportunity as well.

 

Thanks and Cheers

 

 

Can anyone help me in writing a test class for my controller.

 

The controller is as follows

 

 

public class editProductController {
    private List<BC_Product__c> accounts;
    private List<BC_Product__c> pageAccounts;
    private Integer pageNumber;
    private Integer pageSize;
    private Integer totalPageNumber;
    public boolean testBool {get; set;}
    public string chkText {get; set;}
    public List<BC_Product__c> PDTS {get; set;}
    public BC_Product__c JEPS;
    public string selectedOptions {get;set;}
    BC_Product__c products;
    
    public editProductController(){    
        pageNumber = 0;
        totalPageNumber = 0;
        pageSize = 75;
        ViewData();
        JEPS = new BC_Product__c();
        PDTS = new List<BC_Product__c>();
        PDTS.add(new BC_Product__c());
        testBool = false;
    }
    
    public Integer getPageNumber(){
        return pageNumber;
    }

    public BC_Product__c getProducts(){
        if(products == null) products = new BC_Product__c();
            return products;
    }

    public List<BC_Product__c> getAccounts() {
        return pageAccounts;
    }

    public Integer getPageSize(){
        return pageSize;
    }

    public Boolean getPreviousButtonEnabled(){
        return !(pageNumber > 1);
    }

    public Boolean getNextButtonDisabled(){
        if (accounts == null) 
            return true;
        else
            return ((pageNumber * pageSize) >= accounts.size());
    }

    public Integer getTotalPageNumber(){
        if (totalPageNumber == 0 && accounts !=null) {
            totalPageNumber = accounts.size() / pageSize;
            Integer mod = accounts.size() - (totalPageNumber * pageSize);    
            if (mod > 0)
                totalPageNumber++;
        }
        return totalPageNumber;
    }

    public PageReference ViewData(){
        accounts = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }

    private void BindData(Integer newPageIndex){
        try{
            if (accounts == null)
                accounts = [select b.name,b.Validaion__c,b.Product_Description__c,b.Status__c,b.JEP__c, b.Disconnect_request_Sent_to_Vendor__c,

b.Vendor_Bill_Start_Date__c, b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,

b.Customer_Commit_Date__c,b.Vendor_CDD__c, b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,

b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,

b.Disconnect_Reason_Notes__c from BC_Product__c b 

where Account__c=:System.currentPageReference().getParameters().get('id') order by name];
            
            if(accounts == null || accounts.size() <= 0)
                accounts = [select b.name,b.Validation__c,b.Product_Description__c,b.Status__c,b.JEP__c,

b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
             b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,

b.Customer_Commit_Date__c,b.Vendor_CDD__c, b.SUP_Date__c,b.Actual_Install_Date__c,

b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,

b.Disconnect_Reason__c, b.Disconnect_Reason_Notes__c from BC_Product__c b 

where Opportunity__c=:System.currentPageReference().getParameters().get('id') order by name];
        
            pageAccounts = new List<BC_Product__c>();
            Transient Integer counter = 0;
            Transient Integer min = 0;
            Transient Integer max = 0;
            if (newPageIndex > pageNumber){
                min = pageNumber * pageSize;
                max = newPageIndex * pageSize;
            }
            else {
                max = newPageIndex * pageSize;
                min = max - pageSize;
            }
            for(BC_Product__c a : accounts){   
                counter++;
                if (counter > min && counter <= max)
                    pageAccounts.add(a);
            }
    
            pageNumber = newPageIndex;
            if (pageAccounts == null || pageAccounts.size() <= 0)
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
        }
    }

    public PageReference nextBtnClick(){
        BindData(pageNumber + 1);
        return null;
    }

    public PageReference previousBtnClick(){
        BindData(pageNumber - 1);
        return null;
    }
    
    public PageReference Save(){
        update pageAccounts;
        return ApexPages.currentPage();
    }

    public BC_Product__c getJEPS(){
       return JEPS;
    }

    public void setJEPS(BC_Product__c Value){
       JEPS = Value;
    }

    public PageReference showSelected(){    
       if (JEPS.JEP__c == null || JEPS.JEP__c == ''){
          apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Please select one or more products.'));
          return null;
       }
       // read the values into an array
       string[] regions = JEPS.JEP__c.split(',',0);
       if (regions != null && regions.size() > 0){
          Boolean addSeperater = false;
          for(String le : regions){
                if(addSeperater)
                  selectedOptions = selectedOptions + ',' + le;
                else{
                   selectedOptions = le;
                   addSeperater = true;
                }
          }
       } 
       return ApexPages.currentPage();
    }

}


Can anyone help me in writing a test class for my controller.

 

The controller is as follows

 

 

public class editProductController {
    private List<BC_Product__c> accounts;
    private List<BC_Product__c> pageAccounts;
    private Integer pageNumber;
    private Integer pageSize;
    private Integer totalPageNumber;
    public boolean testBool {get; set;}
    public string chkText {get; set;}
    public List<BC_Product__c> PDTS {get; set;}
    public BC_Product__c JEPS;
    public string selectedOptions {get;set;}
    BC_Product__c products;
    
    public editProductController(){    
        pageNumber = 0;
        totalPageNumber = 0;
        pageSize = 75;
        ViewData();
        JEPS = new BC_Product__c();
        PDTS = new List<BC_Product__c>();
        PDTS.add(new BC_Product__c());
        testBool = false;
    }
    
    public Integer getPageNumber(){
        return pageNumber;
    }

    public BC_Product__c getProducts(){
        if(products == null) products = new BC_Product__c();
            return products;
    }

    public List<BC_Product__c> getAccounts() {
        return pageAccounts;
    }

    public Integer getPageSize(){
        return pageSize;
    }

    public Boolean getPreviousButtonEnabled(){
        return !(pageNumber > 1);
    }

    public Boolean getNextButtonDisabled(){
        if (accounts == null) 
            return true;
        else
            return ((pageNumber * pageSize) >= accounts.size());
    }

    public Integer getTotalPageNumber(){
        if (totalPageNumber == 0 && accounts !=null) {
            totalPageNumber = accounts.size() / pageSize;
            Integer mod = accounts.size() - (totalPageNumber * pageSize);    
            if (mod > 0)
                totalPageNumber++;
        }
        return totalPageNumber;
    }

    public PageReference ViewData(){
        accounts = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }

    private void BindData(Integer newPageIndex){
        try{
            if (accounts == null)
                accounts = [select b.name,b.Validation__c,b.Product_Description__c,b.Status__c,b.JEP__c,b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
                b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,b.Customer_Commit_Date__c,b.Vendor_CDD__c,
                b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,
                b.Disconnect_Reason_Notes__c from BC_Product__c b where Account__c=:System.currentPageReference().getParameters().get('id') order by name];
            
            if(accounts == null || accounts.size() <= 0)
                accounts = [select b.name,b.Validation__c,b.Product_Description__c,b.Status__c,b.JEP__c,b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
                b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,b.Customer_Commit_Date__c,b.Vendor_CDD__c,
                b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,
                b.Disconnect_Reason_Notes__c from BC_Product__c b where Opportunity__c=:System.currentPageReference().getParameters().get('id') order by name];
        
            pageAccounts = new List<BC_Product__c>();
            Transient Integer counter = 0;
            Transient Integer min = 0;
            Transient Integer max = 0;
            if (newPageIndex > pageNumber){
                min = pageNumber * pageSize;
                max = newPageIndex * pageSize;
            }
            else {
                max = newPageIndex * pageSize;
                min = max - pageSize;
            }
            for(BC_Product__c a : accounts){   
                counter++;
                if (counter > min && counter <= max)
                    pageAccounts.add(a);
            }
    
            pageNumber = newPageIndex;
            if (pageAccounts == null || pageAccounts.size() <= 0)
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
        }
    }

    public PageReference nextBtnClick(){
        BindData(pageNumber + 1);
        return null;
    }

    public PageReference previousBtnClick(){
        BindData(pageNumber - 1);
        return null;
    }
    
    public PageReference Save(){
        update pageAccounts;
        return ApexPages.currentPage();
    }

    public BC_Product__c getJEPS(){
       return JEPS;
    }

    public void setJEPS(BC_Product__c Value){
       JEPS = Value;
    }

    public PageReference showSelected(){    
       if (JEPS.JEP__c == null || JEPS.JEP__c == ''){
          apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Please select one or more products.'));
          return null;
       }
       // read the values into an array
       string[] regions = JEPS.JEP__c.split(',',0);
       if (regions != null && regions.size() > 0){
          Boolean addSeperater = false;
          for(String le : regions){
                if(addSeperater)
                  selectedOptions = selectedOptions + ',' + le;
                else{
                   selectedOptions = le;
                   addSeperater = true;
                }
          }
       } 
       return ApexPages.currentPage();
    }

}

Can anyone help me out in writing the test class for the following class??

I am new to this!!!

 

public class MyPagingController {
    private List<BC_Products__c> accounts;
    private List<BC_Products__c> pageAccounts;
    private Integer pageNumber;
    private Integer pageSize;
    private Integer totalPageNumber;
    public boolean testBool {get; set;}
    public string chkText {get; set;}
    public List<BC_Products__c> PDTS {get; set;}
    public BC_Products__c JEPS;
    public string selectedOptions {get;set;}
    BC_Products__c products;
   
    public Integer getPageNumber()
    {
        return pageNumber;
    }

    public BC_Products__c getProducts()
    {
        if(products == null) products = new BC_Products__c();
        return products;
    }

    public List<BC_Products__c> getAccounts()
    {
        return pageAccounts;
    }

    public Integer getPageSize()
    {
        return pageSize;
    }

    public Boolean getPreviousButtonEnabled()
    {
        return !(pageNumber > 1);
    }

    public Boolean getNextButtonDisabled()
    {
        if (accounts == null)
            return true;
        else
            return ((pageNumber * pageSize) >= accounts.size());
    }

    public Integer getTotalPageNumber()
    {
        if (totalPageNumber == 0 && accounts !=null)
        {
            totalPageNumber = accounts.size() / pageSize;
            Integer mod = accounts.size() - (totalPageNumber * pageSize);   
            if (mod > 0)
                totalPageNumber++;
        }
        return totalPageNumber;

    }

    public MyPagingController()
    {   
        pageNumber = 0;
        totalPageNumber = 0;
        pageSize = 75;
        ViewData();
        JEPS = new BC_Products__c();
        PDTS = new List<BC_Products__c>();
        PDTS.add(new BC_Products__c());
        testBool = false;
    }

    public PageReference ViewData()
    {
        accounts = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }

    private void BindData(Integer newPageIndex)
    {
        try
        {
        if (accounts == null)
            accounts = [select b.name,b.Product_Description__c,b.Status__c,b.JEP__c,b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
            b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioing__c,b.CR_Install_Date__c,b.Customer_Commit_Date__c,b.Vendor_CDD__c,
            b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,b.Disconnect_Reason_Notes__c from BC_Products__c b where AccountName__c=:System.currentPageReference().getParameters().get('id') order by name];
       
            pageAccounts = new List<BC_Products__c>();
            Transient Integer counter = 0;
            Transient Integer min = 0;
            Transient Integer max = 0;
            if (newPageIndex > pageNumber)
            {
                min = pageNumber * pageSize;
                max = newPageIndex * pageSize;
            }
            else
            {
                max = newPageIndex * pageSize;
                min = max - pageSize;
            }
            for(BC_Products__c a : accounts)
            {  
                counter++;
                if (counter > min && counter <= max)
                    pageAccounts.add(a);
            }
   
            pageNumber = newPageIndex;
            if (pageAccounts == null || pageAccounts.size() <= 0)
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
        }catch(Exception ex)
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
        }
    }

    public PageReference nextBtnClick()
    {
        BindData(pageNumber + 1);
        return null;
    }

    public PageReference previousBtnClick()
    {
        BindData(pageNumber - 1);
        return null;
    }
   
    public PageReference Save()
    {
        update pageAccounts;
        return ApexPages.currentPage();
    }

    public BC_Products__c getJEPS()
    {
       return JEPS;
    }

    public void setJEPS(BC_Products__c Value)
    {
       JEPS = Value;
    }

    public PageReference showSelected()
    {   
       if (JEPS.JEP__c == null || JEPS.JEP__c == '')
       {
          apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Please select one or more products.'));
          return null;
       }
       // read the values into an array
       string[] regions = JEPS.JEP__c.split(',',0);
       if (regions != null && regions.size() > 0)
       {
          Boolean addSeperater = false;
          for(String le : regions)
            {
                if(addSeperater)
                  selectedOptions = selectedOptions + ',' + le;
                else
                  {
                   selectedOptions = le;
                   addSeperater = true;
                  }
            }
       }
       return ApexPages.currentPage();
   }
}

 

 

 

 

Thanks in advance!!!!

BridgeTree

Hi... Hope everyone is doing well.

Well i was doing some inbound project and the UI wanted from client id really something worry.


There is a Custom Object in which i have the Product Look up relationship.

 

He wants a page block table in which he has two fields.

 

Product Name which is a lookup in this custom object. and other is the Product Code which is in Product standard object.

When the product name is selected, after its selection, it has to display its code.

I know this has to be done using Wrapper classes. Tried but not working. Can you give me some sort of lines to achieve it.

There are two fields as mentioned. I should be able to add row to the table. On adding again same procedure should work on.

Phaniraj N



Hi... Hope everyone is doing well.

Well i was doing some inbound project and the UI wanted from client id really something worry.


There is a Custom Object in which i have the Product Look up relationship.

 

He wants a page block table in which he has two fields.

 

Product Name which is a lookup in this custom object. and other is the Product Code which is in Product standard object.

When the product name is selected, after its selection, it has to display its code.

I know this has to be done using Wrapper classes. Tried but not working. Can you give me some sort of lines to achieve it.

There are two fields as mentioned. I should be able to add row to the table. On adding again same procedure should work on.

Phaniraj N

Hey i have one small problem...

 

          i have  a picklist. I want to get the selected values in a textbox delimited by a ' , ' 

   Please suggest some code... 

 

tried using all javascript.. not working... Stuck in middle...

 

Pls save...

I have set of records that is Selected from a Custom object for a particular Account.

These records are put in pageBlockTable. Now i am editing the records.

I have put a save button. On clicking the records should be updated..

 

Can anyone help me out...

 

public List<BC_Products__c> getAccount() { 

 

      List<BC_Products__c> products= [select Name,Product_Description__c,Status__c

                                where AccountName__c = :ApexPages.currentPage().getParameters().get('id')];                   

      return products;   

 

}

 

public PageReference save()

{

What code has to be here????

}

I have pageblock table having contents of one object. i have cretaed another custom object

with similar fields of table. I want to create instance of the pageBlocktable with the table of

the custom object fields.

 

How can i do it..

 

 

Any suggestion with code????

 

nadi

I have a pageBlockTable in which value refers to a Wrapper class refering to one object. I am adding some products and its details. Suppose now i have 5 rows, each of data fetched in from wrapper class. Now i want each of these column data in each row to be copied to fields of another object.

 

someone can really think of it.

 

Thanks in advance

Raaaaj

 

 

I have a custom object. I have created a VFP for the same in which i'm inserting some product line items in pageBlockTable using wrapper class and doing some calculations. now at the time i save this record, i want this pageBlockTable to appear in the particular VIEW record also. I know i have to write a VFP and controller for it. 

 

Some one please give me a hint in the form of coing on how to do it.

I am in most urgent.

 

Thanks in advance

Raaj...

Hiiiiiiii

 

         I have a pageBlockTable and a addRow function. Everything is working fine. But There is a lookup field in row. Once the field is filled up with data i have written a prog to get its other details and fill in other column of the table. Now if i create a row again, The lookup field is automatically filled which i donn't want to happen. 

 

Can anyone suggest how to do that

 

Thanks in advance.

Hi........

 

      I have a table in visualforce refering to some custom object extending to a controller. In the coloumn i have a lookup for product. I have a custom field called 'make' in prodcuts table. 

 

Now current requirement is that, once i select a product using the lookup, it has to render me the make of the product in the other column.

 

please help me.

 

Thanks in advance !!!!

 

 

Hi all....

 

 

               I have a Dynamic data table in which i will have a value in each row. Now i want to perform the addition of these values.

 

The values of row are brought from object of a class.

Description is like this.

I have a table and columns like this

Product name

clean value

No of items

Total

 

So after the total is calculated for each row,

i want to calculate the sum of values in Column.

 

Pls suggest a way for this. I want to display the value.

 

 

 

Hi all...

 

 Small Requirement. Pls get me thru.

 

I have franchisee name lookup field (Account) in a Franchisee custom object. I will be adding few products to each of the franchisee in this page.

 

Current req is in my lead visualforce page. I have  a franchisee field (lookup coming from account) here also.

When i enter the data, i will be clicking a button Find Products.

Soon a data list has to be filled with product and its details based on the data in the lookup field above.

It means i need to pass this lookup field value as param value in  button.

 

Pls suggest any help.

 

Thanks in advance

HI allll...

 

 

             I am trying to write a query in which for the where cluase i would like to check with a lookup field.

 

How this can be done. Please suggest.

 

ex: Select Product_name__c from Franchisee__c where Franchisee_name__c=

 

Here Franchisee_name__c is a lookup field refering to accounts.

 

 

Please suggest I am New to this Envi

 

 

Thanks in advance

hi all...

 

        I am stuck up with a small requirement. Pls help me..

 

i have a custom object fanchisee in which i will be storing some products on single franchisee name.

 

Now in lead page (visualforce page) i have a lookup field called Franchisee Name. Once after i enter a data to it,

 

i will click a button "Add Products" . Soon after this i should get the list of products that the Franchisee Name in the

 

above field entered.

 

 

Pls save me...

 

Thanks in advance.

Hi alll...

 

         I am in a big problem pls solve this for me.. My requirement is.

 

I have a lookup field in Lead coming from accounts. Now i should get the product list based on the value of the lookup

field. I have made a object in which some products are stored in the account name.

 

So in simple terms.

step 1: I have one field. I enter a data.

step 2: Then i click a button Add products.

step 3: Soon after it get the list of product and its detail based on the value in step 1. I have made a page called Franchisee

in which i will be saving some products for each account.

 

 

Pls help me in finding the solution.

Hi everyone


                I want to create a pageBlockTable such that, where in i have two fields for a custom Object. The Two fields are

1 . Lookup for Contact

2. Email.

 

Now in the pageBlockTable, i have a Add-Row functionality, upon doing this, i will have new row in the pageBlockTable.

The pageBlockTable has two fields.

        Contact Name (lookup)

        Email.

 

Now when i select the contact in the pageBlockTable, the related email should populate in the email field.

remember the pageBlockTable is refered to the Custom Object.

Please let me know the solution please.

Thanks in advance.

Hello All...

 

                       Can anyone tell me how to add a Validation to a PickList.

The Scenario is something Like this. I have a Areas fields of type Multi select Picklist and Probably 10 Values. At the time of Creation i should be able to Select a maximum of Three areas only.

 

                      How can i add the validation to the Multiselect Picklist

Hello Everyone.

 

                I was doing a Salesforce to Salesforce Migration from One Org to Another. This went fine for Accounts and Contacts. But when i tried to Transfer Contact, The related Opportunities are not getting Transferred.

I had read about Publishing Objects in the link below

 which tells us how to setup the connect.

As salesforce doesnot allow Junction Object to migrate Up, is any solution for the Problem i am facing.  I need to Transfer Contacts and related Opportunity as well.

 

Thanks and Cheers

 

 

Can anyone help me in writing a test class for my controller.

 

The controller is as follows

 

 

public class editProductController {
    private List<BC_Product__c> accounts;
    private List<BC_Product__c> pageAccounts;
    private Integer pageNumber;
    private Integer pageSize;
    private Integer totalPageNumber;
    public boolean testBool {get; set;}
    public string chkText {get; set;}
    public List<BC_Product__c> PDTS {get; set;}
    public BC_Product__c JEPS;
    public string selectedOptions {get;set;}
    BC_Product__c products;
    
    public editProductController(){    
        pageNumber = 0;
        totalPageNumber = 0;
        pageSize = 75;
        ViewData();
        JEPS = new BC_Product__c();
        PDTS = new List<BC_Product__c>();
        PDTS.add(new BC_Product__c());
        testBool = false;
    }
    
    public Integer getPageNumber(){
        return pageNumber;
    }

    public BC_Product__c getProducts(){
        if(products == null) products = new BC_Product__c();
            return products;
    }

    public List<BC_Product__c> getAccounts() {
        return pageAccounts;
    }

    public Integer getPageSize(){
        return pageSize;
    }

    public Boolean getPreviousButtonEnabled(){
        return !(pageNumber > 1);
    }

    public Boolean getNextButtonDisabled(){
        if (accounts == null) 
            return true;
        else
            return ((pageNumber * pageSize) >= accounts.size());
    }

    public Integer getTotalPageNumber(){
        if (totalPageNumber == 0 && accounts !=null) {
            totalPageNumber = accounts.size() / pageSize;
            Integer mod = accounts.size() - (totalPageNumber * pageSize);    
            if (mod > 0)
                totalPageNumber++;
        }
        return totalPageNumber;
    }

    public PageReference ViewData(){
        accounts = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }

    private void BindData(Integer newPageIndex){
        try{
            if (accounts == null)
                accounts = [select b.name,b.Validaion__c,b.Product_Description__c,b.Status__c,b.JEP__c, b.Disconnect_request_Sent_to_Vendor__c,

b.Vendor_Bill_Start_Date__c, b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,

b.Customer_Commit_Date__c,b.Vendor_CDD__c, b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,

b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,

b.Disconnect_Reason_Notes__c from BC_Product__c b 

where Account__c=:System.currentPageReference().getParameters().get('id') order by name];
            
            if(accounts == null || accounts.size() <= 0)
                accounts = [select b.name,b.Validation__c,b.Product_Description__c,b.Status__c,b.JEP__c,

b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
             b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,

b.Customer_Commit_Date__c,b.Vendor_CDD__c, b.SUP_Date__c,b.Actual_Install_Date__c,

b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,

b.Disconnect_Reason__c, b.Disconnect_Reason_Notes__c from BC_Product__c b 

where Opportunity__c=:System.currentPageReference().getParameters().get('id') order by name];
        
            pageAccounts = new List<BC_Product__c>();
            Transient Integer counter = 0;
            Transient Integer min = 0;
            Transient Integer max = 0;
            if (newPageIndex > pageNumber){
                min = pageNumber * pageSize;
                max = newPageIndex * pageSize;
            }
            else {
                max = newPageIndex * pageSize;
                min = max - pageSize;
            }
            for(BC_Product__c a : accounts){   
                counter++;
                if (counter > min && counter <= max)
                    pageAccounts.add(a);
            }
    
            pageNumber = newPageIndex;
            if (pageAccounts == null || pageAccounts.size() <= 0)
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
        }
    }

    public PageReference nextBtnClick(){
        BindData(pageNumber + 1);
        return null;
    }

    public PageReference previousBtnClick(){
        BindData(pageNumber - 1);
        return null;
    }
    
    public PageReference Save(){
        update pageAccounts;
        return ApexPages.currentPage();
    }

    public BC_Product__c getJEPS(){
       return JEPS;
    }

    public void setJEPS(BC_Product__c Value){
       JEPS = Value;
    }

    public PageReference showSelected(){    
       if (JEPS.JEP__c == null || JEPS.JEP__c == ''){
          apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Please select one or more products.'));
          return null;
       }
       // read the values into an array
       string[] regions = JEPS.JEP__c.split(',',0);
       if (regions != null && regions.size() > 0){
          Boolean addSeperater = false;
          for(String le : regions){
                if(addSeperater)
                  selectedOptions = selectedOptions + ',' + le;
                else{
                   selectedOptions = le;
                   addSeperater = true;
                }
          }
       } 
       return ApexPages.currentPage();
    }

}


Can anyone help me in writing a test class for my controller.

 

The controller is as follows

 

 

public class editProductController {
    private List<BC_Product__c> accounts;
    private List<BC_Product__c> pageAccounts;
    private Integer pageNumber;
    private Integer pageSize;
    private Integer totalPageNumber;
    public boolean testBool {get; set;}
    public string chkText {get; set;}
    public List<BC_Product__c> PDTS {get; set;}
    public BC_Product__c JEPS;
    public string selectedOptions {get;set;}
    BC_Product__c products;
    
    public editProductController(){    
        pageNumber = 0;
        totalPageNumber = 0;
        pageSize = 75;
        ViewData();
        JEPS = new BC_Product__c();
        PDTS = new List<BC_Product__c>();
        PDTS.add(new BC_Product__c());
        testBool = false;
    }
    
    public Integer getPageNumber(){
        return pageNumber;
    }

    public BC_Product__c getProducts(){
        if(products == null) products = new BC_Product__c();
            return products;
    }

    public List<BC_Product__c> getAccounts() {
        return pageAccounts;
    }

    public Integer getPageSize(){
        return pageSize;
    }

    public Boolean getPreviousButtonEnabled(){
        return !(pageNumber > 1);
    }

    public Boolean getNextButtonDisabled(){
        if (accounts == null) 
            return true;
        else
            return ((pageNumber * pageSize) >= accounts.size());
    }

    public Integer getTotalPageNumber(){
        if (totalPageNumber == 0 && accounts !=null) {
            totalPageNumber = accounts.size() / pageSize;
            Integer mod = accounts.size() - (totalPageNumber * pageSize);    
            if (mod > 0)
                totalPageNumber++;
        }
        return totalPageNumber;
    }

    public PageReference ViewData(){
        accounts = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }

    private void BindData(Integer newPageIndex){
        try{
            if (accounts == null)
                accounts = [select b.name,b.Validation__c,b.Product_Description__c,b.Status__c,b.JEP__c,b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
                b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,b.Customer_Commit_Date__c,b.Vendor_CDD__c,
                b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,
                b.Disconnect_Reason_Notes__c from BC_Product__c b where Account__c=:System.currentPageReference().getParameters().get('id') order by name];
            
            if(accounts == null || accounts.size() <= 0)
                accounts = [select b.name,b.Validation__c,b.Product_Description__c,b.Status__c,b.JEP__c,b.Disconnect_request_Sent_to_Vendor__c,b.Vendor_Bill_Start_Date__c,
                b.Actual_Disconnect_Date__c,b.Date_Entered_Provisioning__c,b.CR_Install_Date__c,b.Customer_Commit_Date__c,b.Vendor_CDD__c,
                b.SUP_Date__c,b.Actual_Install_Date__c,b.Cancel_Request_Recieved__c,b.CR_Disconnect_Date__c,b.Disconnect_Date__c,b.Disconnect_Reason__c,
                b.Disconnect_Reason_Notes__c from BC_Product__c b where Opportunity__c=:System.currentPageReference().getParameters().get('id') order by name];
        
            pageAccounts = new List<BC_Product__c>();
            Transient Integer counter = 0;
            Transient Integer min = 0;
            Transient Integer max = 0;
            if (newPageIndex > pageNumber){
                min = pageNumber * pageSize;
                max = newPageIndex * pageSize;
            }
            else {
                max = newPageIndex * pageSize;
                min = max - pageSize;
            }
            for(BC_Product__c a : accounts){   
                counter++;
                if (counter > min && counter <= max)
                    pageAccounts.add(a);
            }
    
            pageNumber = newPageIndex;
            if (pageAccounts == null || pageAccounts.size() <= 0)
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
        }
    }

    public PageReference nextBtnClick(){
        BindData(pageNumber + 1);
        return null;
    }

    public PageReference previousBtnClick(){
        BindData(pageNumber - 1);
        return null;
    }
    
    public PageReference Save(){
        update pageAccounts;
        return ApexPages.currentPage();
    }

    public BC_Product__c getJEPS(){
       return JEPS;
    }

    public void setJEPS(BC_Product__c Value){
       JEPS = Value;
    }

    public PageReference showSelected(){    
       if (JEPS.JEP__c == null || JEPS.JEP__c == ''){
          apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Please select one or more products.'));
          return null;
       }
       // read the values into an array
       string[] regions = JEPS.JEP__c.split(',',0);
       if (regions != null && regions.size() > 0){
          Boolean addSeperater = false;
          for(String le : regions){
                if(addSeperater)
                  selectedOptions = selectedOptions + ',' + le;
                else{
                   selectedOptions = le;
                   addSeperater = true;
                }
          }
       } 
       return ApexPages.currentPage();
    }

}

Hi... Hope everyone is doing well.

Well i was doing some inbound project and the UI wanted from client id really something worry.


There is a Custom Object in which i have the Product Look up relationship.

 

He wants a page block table in which he has two fields.

 

Product Name which is a lookup in this custom object. and other is the Product Code which is in Product standard object.

When the product name is selected, after its selection, it has to display its code.

I know this has to be done using Wrapper classes. Tried but not working. Can you give me some sort of lines to achieve it.

There are two fields as mentioned. I should be able to add row to the table. On adding again same procedure should work on.

Phaniraj N



Hi... Hope everyone is doing well.

Well i was doing some inbound project and the UI wanted from client id really something worry.


There is a Custom Object in which i have the Product Look up relationship.

 

He wants a page block table in which he has two fields.

 

Product Name which is a lookup in this custom object. and other is the Product Code which is in Product standard object.

When the product name is selected, after its selection, it has to display its code.

I know this has to be done using Wrapper classes. Tried but not working. Can you give me some sort of lines to achieve it.

There are two fields as mentioned. I should be able to add row to the table. On adding again same procedure should work on.

Phaniraj N

Hey i have one small problem...

 

          i have  a picklist. I want to get the selected values in a textbox delimited by a ' , ' 

   Please suggest some code... 

 

tried using all javascript.. not working... Stuck in middle...

 

Pls save...