0

http://blogforce9.blogspot.com/2015/04/custom-rich-textarea-taking-it-further.html#comment-form

I've been looking for a solution to refreshing rich text field but haven't made much progress. This link looks promising but it's not specific enough for me to understand how it works and I haven't been able to figure it out yet.

I've gone to the github page and clicked deploy to salesforce, and included the static resource in my visualforce page, but it's not working.

Can anyone describe to me how I would use the tool mentioned in the above link, or know another way to get around rich text fields not rendering besides replacing them with non-rich text? Thanks!

1

The link has a sample Visualforce page code

<apex:page standardStylesheets="true" docType="html-5.0" sidebar="false">
  <apex:form >
    <c:customrtf targetclass="mytextarea" toolbar="Full"/>
    <apex:inputTextarea styleClass="mytextarea" richText="false"/>
  </apex:form>
</apex:page>

You don't have to include any static resource components into your code because it's already done in the Visualforce Component named customrtf, deployed with the package. <c:customrtf targetclass="mytextarea" toolbar="Full"/> is referencing this component in the sample code. Here you can read more about Visualforce components, also known as custom components

  • I tried this code but it only shows a text field, not a rich text field with the toolbar. – Monty Killough Apr 13 '16 at 14:26
  • I installed and tested right before the answer - was working for me. What browser and version do you use? Also, make sure you don't have any browser add-ons that could block it, or whitelist salesforce.com domain. – o-lexi Apr 13 '16 at 16:30
  • 1
    Hm I'm not sure what exactly I was doing wrong to begin with, but I got it working eventually. Initially I was having problems refreshing it correctly so it would just render a normal text area. Then I was having problems using it with lists of values from a controller. Thanks for your answer because if I hadn't gotten it I wouldn't have reinvestigated this pretty cool tool. I'll post some of my working code below just in case anyone else is interested in doing something similar. – Monty Killough Apr 15 '16 at 17:57
1

Thanks to Oleksiy assuring me the tool works, here is a sample of how you would use it with lists of objects from a controller.

This example shows the rich text fields User_Story__c, Acceptance_Criteria__c, and Assumptions__c from a list of Story__c custom objects. Now they can be reRendered!

<apex:page standardStylesheets="true" docType="html-5.0" sidebar="false" controller="StoryGetterClass" tabStyle="Story__c">
     <apex:form >
         <apex:pageBlock >
              <apex:pageBlockButtons>
                   <apex:commandButton value="Refresh the Panel" reRender="richPanel"></apex:commandButton>
              </apex:pageBlockButtons>

              <apex:outputPanel id="richPanel">
              <apex:repeat value="{!StoryList}" var="story">
                <apex:pageBlockSection columns="3" title="{!story.Name}">
                    <apex:actionRegion >
                        <p style=" font-size: 11.5px; color: rgb(75,75,75); font-weight: bold; ">
                            User Story
                            <apex:inputTextarea styleClass="mytextarea" richText="false" value="{!story.User_Story__c}"></apex:inputTextarea>
                        </p>
                    </apex:actionRegion>
                    <apex:actionRegion >
                        <p style=" font-size: 11.5px; color: rgb(75,75,75); font-weight: bold; ">
                            Acceptance Criteria
                            <apex:inputTextarea styleClass="mytextarea" richText="false" value="{!story.Acceptance_Criteria__c}"></apex:inputTextarea>
                        </p>
                    </apex:actionRegion>
                    <apex:actionRegion >
                        <p style=" font-size: 11.5px; color: rgb(75,75,75); font-weight: bold; ">
                            Assumptions
                            <apex:inputTextarea styleClass="mytextarea" richText="false" value="{!story.Assumptions__c}"></apex:inputTextarea>
                        </p>
                    </apex:actionRegion>
                </apex:pageBlockSection>
                <c:customrtf targetclass="mytextarea" toolbar="Visualforce"></c:customrtf>
              </apex:repeat>
              </apex:outputPanel>

         </apex:pageBlock>
     </apex:form>
</apex:page>

here is what this controller would look like:

     public with sharing class StoryGetterClass {
          public list<Story__c> slist{get;set;}

          public StoryGetterClass(){
               slist = new list<Story__c>();
          }

          public List<Story__c> getStoryList{
               slist = [select Name,User_Story__c,Acceptance_Criteria__c,Assumptions__c from Story__c limit 3];
               return slist;
          }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.