+ Start a Discussion
azhar khasimazhar khasim 

Had a Long TextArea Field in Custom object and want to display the data in that field on Visualforce Page

I Had a Field (Allotment Summary) Long TextArea Field in Bren Updates(Custom Object).
I need to display the data which was in Allotment Summary in the Visualforce Page.

I have tried it using <apex:outputField>
But still i was not getting the data to show in Visualforce page.

My Visualforce Page:

<apex:page controller="BookingLinkQuestionary" showHeader="false" sidebar="false">
    
    <style>
        body {
        background-image: url("https://www.bren.com/residential/images/home-banner11.jpg");
        
        
        }
        input[type="text"] {
        background: transparent;
        
        }        
    </style>  
    
    <apex:form >
        
        <style>
            body .bPageBlock .pbBody .fontcolor .pbSubheader h3{
            color:#ffffff;
            
            
            }
            body .bPageBlock .pbBody .blue .pbSubheader{
            background-color:#02a3d6;
            font-style:Aparajita;
            }
        </style>
       
        <apex:sectionHeader title="Bren Online Booking Form" />
       
        <apex:pageBlock >
        
             <center>
                <apex:image url="https://bren--partial--c.cs31.visual.force.com/resource/1523623530000/BrenLogo"/>
            </center>
            
            <apex:pageBlockButtons location="bottom" style="float:left;" >  
                
                <font size="4" style="color:red; float:left;" face="Ancillary Bold"><b>NOTE:Please click on 'Accepting Terms and Conditions ' checkbox before submitting the data to Bren Corporation.</b> </font>
                <br/>
                <center>
                    <apex:commandButton style="color:white; background-color:green; background-image:none; width:150px; height:35px" action="{!Submit}" value="Submit"  />
                    <apex:commandButton style="color:white; background-color:red; background-image:none; width:150px; height:35px" action="{!cancel}" value="Cancel"  />  
                </center>
            </apex:pageBlockButtons>
            
               
            <center>
                <font size="5" style="color:blue" face="Foobar Pro Bold" ><b>Welcome to Bren Online Booking Portal</b> </font>
            </center>
            
            <center>
                <font size="4" style="color:red" face="Foobar Pro"><b>Bren Terms of Allotment.</b> </font>
            </center>
             <br/><br/>
            <apex:outputPanel styleClass="blue" layout="block" >
                
                <apex:pageBlockSection title="Allotment Summary" collapsible="false"  columns="1">
                      
                 <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Allotment Summary" for="AllSum" style="font-family:Ancillary Bold; font-size:15px" />
                     <apex:outputField value="{!brenup.Allotment__c}" id="AllSum" />
                   <!--    <apex:inputfield value="{!booking.Allotment_Summary__c}" id="AllSum" html-disabled="true" />  -->
                 <!--   <apex:inputTextarea richtext="true" value="{!booking.Allotment_Summary__c}"  id="AllSum" readonly="true" cols="60" rows="15"/>  -->
                  <!--   <apex:inputTextarea richtext="true" value="{!brenup.Allotment_Summary__c}"  id="AllSum" readonly="true" cols="60" rows="15"/>  -->
                           
                    </apex:pageBlockSectionItem>   
                                    
                </apex:pageBlockSection>
            
            <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q1. What is the full name of Bren corporation?</b> </font>
              
                <br/><br/><br/><br/>
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q2. What is the full name of Bren corporation?</b> </font>
                
                <br/><br/><br/><br/>
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q3. What is the full name of Bren corporation?</b> </font>
              
                <br/><br/><br/><br/>
                
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q4. What is the full name of Bren corporation?</b> </font> 
              
                <br/><br/><br/><br/>
 
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q5. What is the full name of Bren corporation?</b> </font>         
                
                <br/><br/><br/><br/>
 
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q6. What is the full name of Bren corporation?</b> </font>
              
                <br/><br/><br/><br/>
 
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q7. What is the full name of Bren corporation?</b> </font>
               
                <br/><br/><br/><br/>
 
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q8. What is the full name of Bren corporation?</b> </font>
              
                <br/><br/><br/><br/>
 
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q9. What is the full name of Bren corporation?</b> </font>
              
                <br/><br/><br/><br/>
 
                 <font size="4" style="color:black; float:left;" face="Ancillary Bold"><b>Q10. What is the full name of Bren corporation?</b> </font>
                 
                <br/><br/><br/><br/>
                
                 <br/>
              <apex:inputCheckbox style="color:black; width:20px; height:20px" required="true" value="{!isboolean}"/>  
           <!--     <apex:inputField style="color:black; width:25px; height:25px" required="true" value="{!booking.I_Accept__c}"/> -->
            <font size="4.5" style="color:red" face="Foobar Pro Bold" ><b>Accepting Terms and Conditions</b> </font>

                 <br/>  <br/>  
            <font size="3" style="font-family:Ancillary Bold; color:blue"><b>DECLARATION :
                
                I / WE the Applicant/s do hereby declare that the above-mentioned particulars / information given by me / us are true and genuine to my / our best knowledge and the same are irrevocable. 
                I / WE also declare the booking terms referred to above at SL.No.1 to 14 are read over to me / us and I / WE, after understanding the said conditions are willing to book the Apartment noted above.
                
                
                </b></font>   
            
            </apex:outputPanel>
        
        </apex:pageBlock>
    </apex:form>
</apex:page>




My Controller Class:

public class BookingLinkQuestionary {
    
     public Booking_Link__c booking {get;set;}
    public Boolean isboolean {get;set;}
    public string BrenUpdateId{get;set;}
    public Bren_Update__c brenup {get;set;}
   // public Boolean isboolean {get;set;}
    
     public BookingLinkQuestionary(){
        booking = new Booking_Link__c();
       
    }
  //  public checkLongArea(ApexPages.Controller cont){
  //  BrenUpdateId = ApexPages.CurrentPage().getParameters().get('id');
  //  brenup = [SELECT id , LongTextAreA__c FROM Bren_Update__c WHERE id =: BrenUpdateId];
  //  system.debug('##' + brenup);
    

//}
    public void Submit(){
        try{
            if(isboolean){
                INSERT brenup;
            } else{
                Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,''+'No records to Display"'));
            }
        }catch (Exception e) {
            ApexPages.addMessages (e);
           
        }
        
    }
     public void cancel(){
        booking = new Booking_Link__c();
    }

}


Please help me out from this...

Any help is highly appriciated.

Thanks and Regards,
Azhar Khasim.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Azhar,

Greetings to you!

Try like this:
<apex:outputText value="{!HTMLENCODE(item.LongTextArea__c)}" 
  style="white-space:pre;" escape="false"/>

Please refer to the below links which might help you further with the above requirement.

https://sfdcfanboy.com/2017/08/26/a-tip-a-day-8-display-line-breaks-of-long-text-area-in-vf-page/

https://salesforce.stackexchange.com/questions/34482/outputfield-long-textarea-field-and-unwanted-spaces

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi Azhar,
I have understood your requirement, You can use these snippets of codes below-
Codes for BookingLink__c Object-

  <apex:outputField value="{!mybookingLink .LongTextAreaFieldName__c }"      label="Text Area"/>



Apex Class -------------


public class checkLongArea {
    
    public String BookingLinkId {get;set;}
    public BookingLink__c mybookingLink {get;set;}


    public checkLongArea(ApexPages.StandardController cont){
    BookingLinkId = ApexPages.CurrentPage().getParameters().get('id');
    mybookingLink = [SELECT id , LongTextAreaFieldName__c FROM BookingLink__c WHERE id =: BookingLinkId ];
    system.debug('##' + mybookingLink );
    

}

}



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
 
azhar khasimazhar khasim
Hello Khan Anas,

I have done the same thing as you have suggested me.

But i was getting a new error in Below 

( Incorrect parameter type for function 'not()'. Expected Boolean, received Text )

My Area of which your its not getting.

       
                 <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Allotment Summary" for="AllSum" style="font-family:Ancillary Bold; font-size:15px" />
                     <apex:outputText value="{!HTMLENCODE(!brenup.Allotment_Summary__c)}" style="white-space:pre;" escape="false"/>
                 <!--    <apex:outputField value="{!brenup.Allotment__c}" id="AllSum" /> -->
                 <!--    <apex:inputfield value="{!brenup.Allotment_Summary__c}" id="AllSum" html-disabled="true" />  -->
                 <!--    <apex:inputTextarea richtext="true" value="{!brenup.Allotment_Summary__c}"  id="AllSum" readonly="true" cols="60" rows="15"/>  -->
                           
                    </apex:pageBlockSectionItem>  



Please help me out in thisss.,,,

Do i need to add anything in Controller Class for thiss.



public class BookingLinkQuestionary {
    
    
    public Boolean isboolean {get;set;}
    public string BrenUpdateId{get;set;}
    public Bren_Update__c brenup {get;set;}
   
    
     public BookingLinkQuestionary(){
      
       brenup = new Bren_Update__c();
    }
   // public checkLongArea(ApexPages.Controller cont){
   // BrenUpdateId = ApexPages.CurrentPage().getParameters().get('id');
   // brenup = [SELECT id , LongTextAreA__c FROM Bren_Update__c WHERE id =: BrenUpdateId];
   // system.debug('##' + brenup);
    

//}
    public void Submit(){
        try{
            if(isboolean){
                INSERT brenup;
            } else{
                Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,''+'No records to Display"'));
            }
        }catch (Exception e) {
            ApexPages.addMessages (e);
           
        }
        
    }
     public void cancel(){
      
    }

}


Help me out Khan Anas
Azar Khasim.
Khan AnasKhan Anas (Salesforce Developers) 
Use this:
<apex:outputText value="{!HTMLENCODE(brenup.Allotment_Summary__c)}" style="white-space:pre;" escape="false"/>

 
azhar khasimazhar khasim
Hello Khan Anas,

I have treid as you have mentioned as the same but it was not even showing.

This is my requirement in Skeleton mode.

User-added image

Please have a look and help me from this

Thanks and Regards,
Azar Khasim.
 
azhar khasimazhar khasim
Hello Khan Anas,

This is my stuff till now.

<apex:pageBlockSection title="Allotment Summary" collapsible="false"  columns="1">   
  <apex:pageBlockSectionItem >
           <apex:outputLabel value="Allotment Summary" for="AllSum" style="font-family:Ancillary Bold; font-size:15px" />
   <!--  <apex:outputField value="{!brenup.Allotment__c}" id="a0Wp0000003JTYb" /> --> 
           <apex:outputText value="{!HTMLENCODE(brenup.Allotment_Summary__c)}" style="white-space:pre;" escape="false"/>
   <!--  <apex:inputfield value="{!brenup.Allotment_Summary__c}" id="AllSum" html-disabled="true" /> -->
   <!--  <apex:inputTextarea richtext="true" value="{!brenup.Allotment_Summary__c}"  id="AllSum" readonly="true" cols="60" rows="15"/>  -->
   <!--  <apex:inputTextarea richtext="true" value="{!booking.Allotment_Summary__c}"  id="AllSum" readonly="true" cols="60" rows="15"/> - ->           
   </apex:pageBlockSectionItem>          
</apex:pageBlockSection>

                
I want to show the text data which was there in Long TextArea Field API(Allotment_Summary__c) So please help me to show the data in Visualforce Page and it should be in Readonly Mode.

After that i need to save this Text data which was shown in VF page to another object named BookingLink which contains the same type of Long TextArea Field in BookingLink Object.

Please give me a better way to get out from this..

Thanks and Regards,
Azar Khasim.
azhar khasimazhar khasim
Hello Ajay,

I have used the same snippets of the code you gave but getting errors for it in Controller Class Saying that

Error:

Invalid constructor name: checkLongArea

And i was not getting the data in Visualforce Page



Please help me out from this 

Thanks and Regards,
Azar Khasim