You need to sign in to do that
Don't have an account?

Pass value to visualforce component
Hi,
I am trying to pass parameters to a VF component, and build UI details when the controller is initialised. In my research I see that you cannot access component attributes in the constructor, and I have tried lots of ways to get around this. Currently trying to make actionSupport work but it is not firing.
I don't really care what method I use as long as it works
Here is my component
And here is the controller
Any assistance greatly appreciated
I am trying to pass parameters to a VF component, and build UI details when the controller is initialised. In my research I see that you cannot access component attributes in the constructor, and I have tried lots of ways to get around this. Currently trying to make actionSupport work but it is not firing.
I don't really care what method I use as long as it works
Here is my component
<apex:component controller="NamedVotesController"> <!-- Attribute Definitions --> <apex:attribute name="meetId" assignTo="{!meetingId}" description="This is the meeting item ID" type="Id" required="true"/> <apex:attribute name="meetItemId" assignTo="{!meetingItemId}" description="This is the meeting item ID" type="Id" required="true"/> <!-- Component Definition --> <apex:actionFunction name="buildDetails" action="{!buildVoterDetails}"/> <apex:dataTable value="{!voters}" var="voter" id="voterTable" styleClass="tableClass"> <apex:column > <apex:facet name="header"> <apex:outputText value="{!$ObjectType.Meeting_Item_Vote__c.fields.Voter_Name__c.label}" /> </apex:facet> <apex:outputField value="{!voter.Attendee__c}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputText value="{!$ObjectType.Meeting_Item_Vote__c.fields.Voter_Name__c.label}" /> </apex:facet> <apex:outputField value="{!voter.Voter_Name__c}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputText value="{!$ObjectType.Meeting_Item_Vote__c.fields.Proposed__c.label}" /> </apex:facet> <apex:inputField value="{!voter.Proposed__c}" /> </apex:column> </apex:dataTable> </apex:component>
And here is the controller
public with sharing class NamedVotesController { // IDs - passed into controller using Attribute in NamedVotes component public ID meetingId; public ID meetingItemId {get; set;} private id meetId; public NamedVotesController() { DO SOMETHING } public pageRreference buildVoterDetails() { system.debug('----------- In buildVoterDetails, MeetingID: ' + meetingId); system.debug('----------- In buildVoterDetails, theID: ' + theID); meetID = meetingId; return null; } }
Any assistance greatly appreciated
Essentially run a one-time initialisation after all of the attributes are populated.