• JosephD
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies

I'm tyring to create a VF page that displays a table for form input.  Table has 4 columns and 6 rows.  The first column is the labe/instruction.  Columns, 2,3,4 are Input Field values.  Each cell in columns 2-4 are different Input Fields.  I'm having trouble acutally creeating a table to display the rows.  pageBlock doesn't seem to be the right apex function to use.  Table would look something like this:

 

Label                  Percent                    Id Number               Reference

Prevalence         5                              12345                      Page 5, Section 3

Test Population  25                             89999                     Page 6, Section 2

 

Any help would be appreciated.

Hi.  I am not an application developer.  I have experience with writing SQL stored procedure codes.  I have begun using force.com and built an app.  It's simple - no vf pages, no triggers, no APEX at all.

 

I want to learn APEX and am thinking of taking the Intro to Object Oriented Programming that salesforce.com offers. I'm wondering if anyone would recommend this instead of the DEV-401 class, based on my experience.

 

Thanks!

Joe

Hi.  I am brand new to APEX, and well, programming in general.  I create a VF page to search my custom tabe, Facilities__c.    I am trying to create test code for the APEX class but am not making any progress.


Here is a start at my test code which is incomplete and probably incorrect:

***********************************

@isTest
private class TestFacilitySearch {

static testMethod void testFacilitySearchController() {
   Facilities__c dcname;
   ApexPages.StandardController sc;
   FacilitySearchController fsc;
   
   Facilities__c facname = new Facilities__c(name= 'DCTest', Agency_Name__c = 'Joe 1');
   insert facname;
   

   fsc.searchText = '';
   fsc.search();
   }

}

***********************************

 

Here is my APEX class.  The interface works fine on the VF page.

***********************************

public class FacilitySearchController {
 
    // the results from the search. do not init the results or a blank rows show up initially on page load
    public List<FacilityWrapper> searchResults {get;set;}
    // the categories that were checked/selected.
    public List<FacilityWrapper> selectedCategories {
        get {
            if (selectedCategories == null) selectedCategories = new List<FacilityWrapper>();
            return selectedCategories;
        }
        set;
    }      
 
    // the text in the search box
    public string searchText {
        get {
            if (searchText == null) searchText = ''; // prefill the serach box for ease of use
            return searchText;
        }
        set;
    }
 
    // constructor
    public FacilitySearchController() {}
 
    // fired when the search button is clicked
    public PageReference search() {
 
        if (searchResults == null) {
            searchResults = new List<FacilityWrapper>(); // init the list if it is null
        } else {
            searchResults.clear(); // clear out the current results if they exist
        }
        // Note: you could have achieved the same results as above by just using:
        // searchResults = new List<FacilityWrapper>();
 
        // dynamic soql for fun
        String qry = 'Select c.Name, c.Agency_Name__c, c.Component_Name__c From Facilities__c c Where c.Name LIKE \'%'+searchText+'%\' Order By c.Name';
        // may need to modify for governor limits??
        for(Facilities__c c : Database.query(qry)) {
            // create a new wrapper by passing it the category in the constructor
            FacilityWrapper cw = new FacilityWrapper(c);
            // add the wrapper to the results
            searchResults.add(cw);
        }
        return null;
    }   
 
    public PageReference next() {
 
        // clear out the currently selected categories
        selectedCategories.clear();
 
        // add the selected categories to a new List
        for (FacilityWrapper cw : searchResults) {
            if (cw.checked)
                selectedCategories.add(new FacilityWrapper(cw.cat));
        }
 
        // ensure they selected at least one category or show an error message.
        if (selectedCategories.size() > 0) {
            return Page.FacilityResults;
        } else {
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Facility.'));
            return null;
        }       
 
    }       
 
    // fired when the back button is clicked
    public PageReference back() {
        return Page.FacilitySearch;
    }       
 
}

***********************************

 

 

 

Thanks for any help!  I greatly appreciate it.

I'm tyring to create a VF page that displays a table for form input.  Table has 4 columns and 6 rows.  The first column is the labe/instruction.  Columns, 2,3,4 are Input Field values.  Each cell in columns 2-4 are different Input Fields.  I'm having trouble acutally creeating a table to display the rows.  pageBlock doesn't seem to be the right apex function to use.  Table would look something like this:

 

Label                  Percent                    Id Number               Reference

Prevalence         5                              12345                      Page 5, Section 3

Test Population  25                             89999                     Page 6, Section 2

 

Any help would be appreciated.