• sudh shukla
  • NEWBIE
  • 45 Points
  • Member since 2015

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

I want to display try catch block exception in a Popup window.
How can i Achieve these.If anybody know the solution plese let me know

Thanks
public with sharing class controller_for_page {
    
    public List<accountWrapper> display_list {get; set;} //list for all Account records and a row counter
    public List<String> current_list = new List<String>(); //list for holding many record Ids
    public List<String> next_list = new List<String>(); //list for holding record Ids that are after the current records
    public List<String> previous_list = new List<String>(); //list for holding record Ids that are before the current records
    Integer list_size = 50; //number of records to display on the page
    
    //initiates the controller and displays some initial data when the page loads
    public controller_for_page() {
        Integer record_counter = 0; //counter
        for (Account a : [SELECT Id FROM Account ORDER BY Name LIMIT 10000]) { //for a bunch of accounts
            if (record_counter < list_size) { //if we have not yet reached our maximum list size
                current_list.add(a.Id); //add the Id of the record to our current list
            } else { //otherwise, we reached our list size maximum
                next_list.add(a.Id); //add the Id to our next_list
            }
            record_counter++;
        }
    }
    
    public List<accountWrapper> getRecordsToDisplay() {
        Set<String> record_ids = new Set<String>(); //set for holding distinct Ids
        Boolean records_added = record_ids.addAll(current_list); //add all the records from our current_list list
        display_list = new List<accountWrapper>(); //set the display_list object to a new accountWrapper List
        Integer counter = 1; //row counter variable
        for (Account a : [SELECT AccountNumber, Id, Name, OwnerId, Phone, Site, Type FROM Account WHERE Id in : record_ids ORDER BY Name]) { //query for the details of the records you want to display
            display_list.add(new accountWrapper(a, counter)); //add the account and counter to our list
            counter++; //increment the counter
        }
        return display_list; //return the list of full records plus their row counter
    }
    
    public class accountWrapper {
        public Account act {get; set;} //Account object
        public Integer numberOfRow {get; set;} //row counter variable
        
        public accountWrapper(Account a, Integer rowCounter) {
            this.act = a; //assign account
            this.numberOfRow = rowCounter; //assign row counter
        }
    }
    
    public Integer getCurrentSize() {
        return current_list.size(); //number of record in current_list
    }
    
    public Integer getPrevSize() {
        return previous_list.size(); //number of record in previous_list
    }
    
    public Integer getNextSize() {
        return next_list.size(); //number of record in next_list
    }

}
Here is my class:
public class dependcustompicklist {

    public String selectcity { get; set; }

    public String selectcountry { get; set; }
    
    public Boolean test {get;set;}
    
    public dependcustompicklist(){
    }
    
    public void testFunction(){
        test = true;
    }
    
    public list <SelectOption> getcountry()
    {
        list <SelectOption> opt = new list <SelectOption> ();
        opt.add(new SelectOption ('','Select'));
        opt.add(new SelectOption ('India','India'));
        opt.add(new SelectOption ('US','US'));
        opt.add(new SelectOption ('UK','UK'));
        return opt;
    }
    
        public list <SelectOption> getcity()
    {
        list <SelectOption> opt1 = new list <SelectOption> ();
        if(selectcountry != null && test != false)
            {
                if(selectcountry == 'India')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('Kanpur','Kanpur',true));
                opt1.add(new SelectOption ('Ghaziabad','Ghaziabad'));
                opt1.add(new SelectOption ('Noida','Noida'));
                }
                if(selectcountry == 'US')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('Washington DC','Washington DC'));
                opt1.add(new SelectOption ('New York','New York'));
                opt1.add(new SelectOption ('Los Angeles','Los Angeles'));
                }
                if(selectcountry == 'UK')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('London','London'));
                opt1.add(new SelectOption ('Paris','Paris'));
                //opt1.add(new SelectOption ('',''));
                }
            }
        return opt1;
    }
}

 
Hi all,
I have created test class for my apex class the test class has been successfully get passed but still not showing expexted code coverage. Why is it so? Please suggest.
Any help would be highly appreciated.
Hi,
I want to write a test class for my visualforce controller hear is the code of my visualforce page and controller



-----------------------visualforce page--------------------------------------
<apex:page showHeader="false" controller="insertController1">
  <apex:form id="formId">
   <apex:PageBlock >
     <apex:pageBlockSection >
     
     <apex:inputField value="{!prpty.Name}"/>
     <apex:inputField value="{!prpty.Address__c}"/>
     
    
     </apex:pageBlockSection>     
       <apex:commandButton value="Save" action="{!addNewprpty}"/>
   </apex:PageBlock>
  </apex:form>
</apex:page>

------------------------------ Controller---------------------

public class insertController1 {

    public Property_Name__c prpty { get; set; }

    // Here initialize the prpty object
    public insertController1() {
        prpty = new Property_Name__c();
    }

    public PageReference addNewprpty() {
        insert prpty;
        
                pagereference ref = new pagereference('/apex/tenant');
        return ref;
    }
}

Any help would appreciable

public class insertController1 {    
 public Property_Name__c prpty { get; set; }     
    public insertController1() {
        prpty = new Property_Name__c();     }     
public PageReference addNewprpty() {
          insert prpty;                         
 pagereference ref = new pagereference('/apex/tenant');     
     return ref;      }
}
Hi all,

I want to display try catch block exception in a Popup window.
How can i Achieve these.If anybody know the solution plese let me know

Thanks
public with sharing class controller_for_page {
    
    public List<accountWrapper> display_list {get; set;} //list for all Account records and a row counter
    public List<String> current_list = new List<String>(); //list for holding many record Ids
    public List<String> next_list = new List<String>(); //list for holding record Ids that are after the current records
    public List<String> previous_list = new List<String>(); //list for holding record Ids that are before the current records
    Integer list_size = 50; //number of records to display on the page
    
    //initiates the controller and displays some initial data when the page loads
    public controller_for_page() {
        Integer record_counter = 0; //counter
        for (Account a : [SELECT Id FROM Account ORDER BY Name LIMIT 10000]) { //for a bunch of accounts
            if (record_counter < list_size) { //if we have not yet reached our maximum list size
                current_list.add(a.Id); //add the Id of the record to our current list
            } else { //otherwise, we reached our list size maximum
                next_list.add(a.Id); //add the Id to our next_list
            }
            record_counter++;
        }
    }
    
    public List<accountWrapper> getRecordsToDisplay() {
        Set<String> record_ids = new Set<String>(); //set for holding distinct Ids
        Boolean records_added = record_ids.addAll(current_list); //add all the records from our current_list list
        display_list = new List<accountWrapper>(); //set the display_list object to a new accountWrapper List
        Integer counter = 1; //row counter variable
        for (Account a : [SELECT AccountNumber, Id, Name, OwnerId, Phone, Site, Type FROM Account WHERE Id in : record_ids ORDER BY Name]) { //query for the details of the records you want to display
            display_list.add(new accountWrapper(a, counter)); //add the account and counter to our list
            counter++; //increment the counter
        }
        return display_list; //return the list of full records plus their row counter
    }
    
    public class accountWrapper {
        public Account act {get; set;} //Account object
        public Integer numberOfRow {get; set;} //row counter variable
        
        public accountWrapper(Account a, Integer rowCounter) {
            this.act = a; //assign account
            this.numberOfRow = rowCounter; //assign row counter
        }
    }
    
    public Integer getCurrentSize() {
        return current_list.size(); //number of record in current_list
    }
    
    public Integer getPrevSize() {
        return previous_list.size(); //number of record in previous_list
    }
    
    public Integer getNextSize() {
        return next_list.size(); //number of record in next_list
    }

}
Here is my class:
public class dependcustompicklist {

    public String selectcity { get; set; }

    public String selectcountry { get; set; }
    
    public Boolean test {get;set;}
    
    public dependcustompicklist(){
    }
    
    public void testFunction(){
        test = true;
    }
    
    public list <SelectOption> getcountry()
    {
        list <SelectOption> opt = new list <SelectOption> ();
        opt.add(new SelectOption ('','Select'));
        opt.add(new SelectOption ('India','India'));
        opt.add(new SelectOption ('US','US'));
        opt.add(new SelectOption ('UK','UK'));
        return opt;
    }
    
        public list <SelectOption> getcity()
    {
        list <SelectOption> opt1 = new list <SelectOption> ();
        if(selectcountry != null && test != false)
            {
                if(selectcountry == 'India')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('Kanpur','Kanpur',true));
                opt1.add(new SelectOption ('Ghaziabad','Ghaziabad'));
                opt1.add(new SelectOption ('Noida','Noida'));
                }
                if(selectcountry == 'US')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('Washington DC','Washington DC'));
                opt1.add(new SelectOption ('New York','New York'));
                opt1.add(new SelectOption ('Los Angeles','Los Angeles'));
                }
                if(selectcountry == 'UK')
                {
                opt1.add(new SelectOption ('','Select'));
                opt1.add(new SelectOption ('London','London'));
                opt1.add(new SelectOption ('Paris','Paris'));
                //opt1.add(new SelectOption ('',''));
                }
            }
        return opt1;
    }
}

 
Hi,
I want to write a test class for my visualforce controller hear is the code of my visualforce page and controller



-----------------------visualforce page--------------------------------------
<apex:page showHeader="false" controller="insertController1">
  <apex:form id="formId">
   <apex:PageBlock >
     <apex:pageBlockSection >
     
     <apex:inputField value="{!prpty.Name}"/>
     <apex:inputField value="{!prpty.Address__c}"/>
     
    
     </apex:pageBlockSection>     
       <apex:commandButton value="Save" action="{!addNewprpty}"/>
   </apex:PageBlock>
  </apex:form>
</apex:page>

------------------------------ Controller---------------------

public class insertController1 {

    public Property_Name__c prpty { get; set; }

    // Here initialize the prpty object
    public insertController1() {
        prpty = new Property_Name__c();
    }

    public PageReference addNewprpty() {
        insert prpty;
        
                pagereference ref = new pagereference('/apex/tenant');
        return ref;
    }
}

Any help would appreciable