I am trying to develop a custom visualforce component that accepts an attribute from a visual strength page. I need to access this attribute in the Constructor controller so that I can fetch some records from the database, and I need to map these records to Component. But the problem is that I am not getting the Attribute value in the controller.
See the code below to clearly understand the problem.
Controller:
public with sharing class AdditionalQuestionController { public String CRFType {get;set;} public AdditionalQuestionController () { system.debug('CRFType : '+CRFType); List<AdditoinalQuestion__c> lstAddQues = [Select AddQues__c from AdditoinalQuestion__c wehre CRFType = :CRFType]; system.debug('lstAddQue : '+lstAddQue); } }
Component:
<apex:component controller="AdditionalQuestionController" allowDML="true"> <apex:attribute name="CRFType" description="This is CRF Type." type="String" required="true" assignTo="{!CRFType}" /> <apex:repeat value="{!lstAddQue}" var="que"> {!que}<br /> </apex:repeat> </apex:component>
VisualForce Page:
<apex:page > <c:AdditionalQuestionComponent CRFType="STE" /> </apex:page>
Thanks, Vivec
Vivek source share