function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
iKnowSFDCiKnowSFDC 

Trouble rendering rich text field in VF Component.

I have a VF Component that I need to include in a tabbed page - the name of the tab refers to the attribute I'm passing to the component to determine which record I want displayed in the panel.  

 

My component controller has a getter and setter for the component attribute and has a getter for the record but no data is being passed back unless I hard code the attribute value in the controller. 

 

Here is the controller: 

public class fcrCompetencyController{

  public Competency__c comp{get;set;}
  public String compType{get;set;}
  
  public fcrCompetencyController(){
      comp=[SELECT id, Description__c, Competency_Type__c, Name 
                      FROM Competency__c 
                      WHERE Active__c = True];
   }
 
  public Competency__c getComp() {
    return comp;
  } 
 
  public void setCompType(String s){
      compType = s;
      }
        
  public String getCompType(){
      return compType;
      }

}

 And my component is: 

<apex:component controller="fcrCompetencyController">
    <apex:attribute name="competency" assignTo="{!compType}" type="String" description="Compentency Displayed"/>
    <apex:outputField value="{!comp.Name}"/>
    <apex:outputField value="{!comp.Description__c}"/>
</apex:component>

 

This is the test page I'm using to try to get it displayed, the actual page is much longer: 

<apex:page controller="fcrCompetencyController">
<apex:pageBlock title="{!comp}">
<apex:outputText value="comptype is {!compType}"/>
<c:competencyDisplay competency="Pre/Post Call Analysis"/>
</apex:pageBlock>
</apex:page>

 I'm not sure where to go next, every example I can find and all the documentation I've found it seems I have everything covered, but am unable to get this working. 

 

I need to display the Description__c field as a field, not text as it is a rich text field on the object and needs to be displayed as created. 

 

Any ideas?

 

Thanks!

mcrosbymcrosby

Do you know what version of the Salesforce API the Visualforce page is set?  From the documentation:

 

<apex:outputField>

The Rich Text Area data type can only be used with this component on pages running Salesforce.com API versions greater than 18.0.

 To determine the API version, open the <ComponentName>.component-meta.xml file

 

Alternatively, try using:

<apex:outputText value="{!comp.Description__c}" escape="false"/>

 

iKnowSFDCiKnowSFDC

I'm definitely using API 27.0. I just built this page this week so am using the latest API version.   

 

The escape="False" does allow me to display the value of the field  - however, I'm stil having an issue getting the CompType string passed into the controller.  Either I get all the values and a list of the records, or I get no values returned. I've updated my controller to the following and still not getting the information I need.  (I took the definition of the Compentency__c comp = out of the constructor and put into a setComp statement that takes the string CompType as an arguement - but no records being returnd).

 

public class fcrCompetencyController{

  public Competency__c comp{get;set;}
  public String compType{get;set;}
 
  public Competency__c getComp() {
    return [SELECT id, Description__c, Competency_Type__c, Name 
                      FROM Competency__c 
                      WHERE Active__c = True
                      AND Competency_Type__c = :compType];
  } 
 
  public void setCompType(String s){
      compType = s;
      }
        
  public String getCompType(){
      return compType;
      }
}