You need to sign in to do that
Don't have an account?
Boolean from VFP to Class, to another class?
I'm having trouble wrapping my head around passing a variable to an extension, which calls to another extension and the variable has to actually be used in that 2nd extension.
What I'm trying to do is allow for my search page to have a "toggle". If a boolean is ticked, to include an entire list of (specific) Accounts to be returned (REVOS_Status__c = "Shared") and if it's not toggled, to exclude that list. I'm not really sure how best to approach this.
The business scenario is that we are querying a list of Accounts and Contacts - Let's say Account 1 has a status of "Shared", it should be included in this query if {!vendorPanel} boolean is ticked.
If Account 2 has a status of "Shared 2", and the related toggle (Example: {!shared2}) on the VFpage is toggled, the query would need to incldue al ist of all Accounts with that status.
Ideally, if the boolean is true on the VFpage, it's to be included in the final query. Does this use case make sense?
Here's the rub.
Visualforce Page, extensions="ProposalExtension"
<apex:pageBlockSection title="Vendor Panel Option"> <apex:pageBlockSectionItem > <apex:outputLabel for="civasPanel" value="Enable VMS Panel"/> <apex:inputCheckbox id="civasPanel" value="{!vendorPanel}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection>
ProposalExtension: (trimmed to relevent code)
public with sharing class ProposalExtension { public String rfpId = ApexPages.currentPage().getParameters().get('rfpId'); public String vendorId = ApexPages.currentPage().getParameters().get('vendorId'); public String orderId = ApexPages.currentPage().getParameters().get('orderId'); public String orderType = ApexPages.currentPage().getParameters().get('orderType'); public Integer radius {get; set;} //Set the radius for the Vendor Search public Boolean vendorPanel {get; set;} //Experimenting with vPanel toggle //this is what i want to pass to VendorSearch private final Proposal__c p; //Constructor for ProposalExtension public ProposalExtension(ApexPages.StandardController pCon) { this.p = (Proposal__c)pCon.getRecord(); } //Used to create lookup fields for Vendor Search Contact con; public Contact getCon() { if(con == null) con = new Contact(); con.RecordTypeId = '012A00000007dJ4'; //Set the Record Type to "Vendor" return con; } //Create a Wrapper/Container class for Vendors to be used in implementing a checkbox list public class checkedVendor{ public Contact ven {get;set;} public Boolean checked {get;set;} //Constructor method for checkedVendors class public checkedVendor(Contact v){ ven = v; checked = false; } } //Create a list of new wrapper class/container object checkedVendors public List<checkedVendor> vendorList {get;set;} //Create a PageReference to execute the Vendor Search public PageReference vendorSearch() { try { vendorList = new List<checkedVendor>(); //Check to see if Radius is 0 and set to 1 if(radius == 0) { radius = 1; } //Creates an instance of Vendor Search VendorSearch vs = new VendorSearch(); //Query for Vendors within the selected Radius, matching Type, and Primary Specialty for(Contact v : vs.searchVendors(con.Primary_County__c, radius, con.Type__c, con.Primary_Specialty__c)){ //Add a checkbox to each Vendor that is returned in the search vendorList.add(new checkedVendor(v)); } } //Catch any query exceptions catch(QueryException q) { } return null; } }
VendorSearch (trimmed to relevant code)
public with sharing class VendorSearch { public Id countyId; //County to be used as starting point public Integer radius = 1; //Desired radius in miles from starting point public String vType; //Desired Vendor Type public String specialty; //Desired Vendor Specialty public String noSpecialty; //No Vendor Specialty place holder public Boolean vendorPanel = false; //testing - do not keep false in... //Not sure how to get this from the ProposalExtension public Double lat; //Latitude for starting point public Double lon; //Longitude for starting point //Constructor for ContactRadiusSearch public VendorSearch() { } //Create a list of Contacts to hold available Vendors public List<Contact> searchVendors(Id startingCounty, Integer searchRadius, String vendorType, String vendorSpecialty) { countyId = startingCounty; radius = searchRadius; vType = vendorType; specialty = vendorSpecialty; //Used to return Vendors with or without Primay Specialties noSpecialty = vendorSpecialty; if(noSpecialty == NULL){ noSpecialty = '%'; } lat = double.valueOf([SELECT Latitude__c FROM County__c WHERE Id = :countyId].Latitude__c); lon = double.valueOf([SELECT Longitude__c FROM County__c WHERE Id = :countyId].Longitude__c); List<Contact> vendors; if(vendorPanel = true){ try { //Get the County Ids from the map and create Set for the search query Set<Id> radiusSet = radiusMap().keySet(); //Query for Vendors within the selected vendors = (List<Contact>)[SELECT Id, Name, Account.Name, Account.Revos_Status__c, Designation__c, Phone, Email, FROM Contact WHERE Primary_County__c IN :radiusSet AND Account.Revos_Status__c = 'Shared' //Trying to get different list AND Type__c INCLUDES (:vType) ORDER BY Status_Sort__c ASC, Overall_Rating__c DESC]; } catch(QueryException q) { } }else if(vendorPanel = false){ try{ Set<Id> radiusSet = radiusMap().keySet(); vendors = (List<Contact>)[SELECT Id, Name, Account.Name, Account.Revos_Status__c, Designation__c, Phone, Email, FROM Contact WHERE Primary_County__c IN :radiusSet AND Account.Revos_Status__c = 'Private' //trying to get different list AND Type__c INCLUDES (:vType) ORDER BY Status_Sort__c ASC, Overall_Rating__c DESC]; } catch(QueryException q) { } } return vendors; }
Better thread here: http://boards.developerforce.com/t5/Visualforce-Development/Dynamic-queries-from-booleans-Advice/m-p/428043/highlight/false#M49209