You need to sign in to do that
Don't have an account?
rossco
How to Pass selectlist value to another Visualforce Page
Hi
I am struggling to pass the value of a selectlist (single) from one visualforce page to another. I can pass the eventid but not the Account ID selected:-
Here is my VF page (controller follows):-
<apex:page Controller="TrainingConfirmation" sidebar="false" showheader="false"> <apex:form > <apex:pageblock > <apex:pageBlockSection title="Training Confirmation - Select Company" columns="1"> <apex:pageblocksectionItem > <apex:selectList value="{!accountId}" size="1" id="accountId"> <apex:selectOptions value="{!accounts}"/> </apex:selectList> </apex:pageblocksectionItem> </apex:pageblocksection> </apex:pageblock> <apex:outputlink value="/apex/atrainingfconfirmation2"> Click here to Generate Training Confirmation <apex:param name="company" value="{!accountId}"/> <apex:param name="eventid" value="{!event.id}"/></apex:outputlink> </apex:form> </apex:page>
Here is my Controller:
public class TrainingConfirmation{ private Account account; public List<CQS_Delegate__c> delegate = new List<CQS_Delegate__c>(); private CQS_Event__c event; public Id eventid; public TrainingConfirmation(){ eventid='a0FR0000006pk4o'; system.debug('delegate id: '+accountid); event= [SELECT Id, Name,Start_Date__c,Venue__r.Name,Venue__r.Address__c FROM CQS_Event__c WHERE Id = :eventid limit 1]; } public CQS_Event__c getevent(){ return event; } public List<CQS_Delegate__c> getdelegates(){ delegate = [SELECT Contact__c,No_of_Delegates__c,Contact__r.Name,Dietary_Requirement__c,Account__r.Name,Payment_Status__c from CQS_Delegate__c WHERE Event__c =:eventid ]; return delegate; } public ID AccountID {get; set;} public List<SelectOption> accounts { get { if (accounts == null) { accounts = new List<SelectOption>(); List<Account> citylist = new List<Account>(); citylist = [Select Id, Name from Account where ID IN (Select Account__c from CQS_Delegate__C where Event__C =:eventid) ]; for (Integer j=0;j<citylist.size();j++) { accounts.add(new SelectOption(citylist[j].ID,citylist[j].Name)); } } return accounts; } set; } }
The problem is that the outputlink is rendered with the initial value of accountId - i.e. empty.
The fact that the user selects a value from the selectlist won't have any impact on accountId unless you submit the form back.
There's a number of different ways to solve this, but a command link is a straightforward option:
Page:
Controller: