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
DevelopersDevelopers 

How to display whole text of the long text area field on VF Page?

Hi,

 

I created one custom field called Casenotes which is LongTextArea and given the value for #Visible Lines: 5 at the time of field creation. I have used this field in my VF Page to display the case details.

In my code, i used <apex:outputField value="{!case.CaseNotes__c}"/> to display the text for that field. But, it doesnot display the whole text in the vf page. I have entered the text of around 15 lines. But, on the page, it doesnot display the whole text.

 

I tried to use of apex:outputText to display the text. But, it doesnot display the text how i entered.

 

Can anyone please support to fix this issue.

 

Thanks in advance.

 

Regards,

kumar

gautam_singhgautam_singh

Hi ,

 

Try the piece of code below , it works perfectly for me. It is showing more lines , the number of lines visible is still 5 for me in this case .

Visualforce Page

<apex:page standardController="Case" extensions="checkLongArea">
<apex:form >
  <apex:outputField value="{!myCase.LongTextAreA__c}" label="Text Area"/>
</apex:form>
</apex:page>


-------------------------------------------------------------

Apex Class 


public class checkLongArea {
    
    public String CaseId{get;set;}
    public Case myCase{get;set;}


    public checkLongArea(ApexPages.StandardController cont){
    CaseId = ApexPages.CurrentPage().getParameters().get('id');
    myCase = [SELECT id , LongTextAreA__c FROM Case WHERE id =: CaseId];
    system.debug('##' + myCase );
    

}

}

 

 

Important :

Hit Kudos [Star Icon ] if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You
-

DevelopersDevelopers

Hi Gautam,

 

Thanks for your response.

 

I used this VF Page as one of the section in one of the standard page layouts of Case object. While i tried out u r code, i am getting the exception like:

 

"List has no rows for assignment to SObject".

 

Kindly check and suggest me.

 

Thanks,

Kumar

gautam_singhgautam_singh

Hi,

 

You can see that in the Constructor , ID Field is taken from the parameters . So , during every page load this will take a Case ID from the Parameter.

Try this URL of this type  for running your page and checking the above functionality which I have explained .

https://c.ap1.visual.force.com/apex/checkLongTextArea?id=5009000000AIhqw

Where c.api = Instance of your Organization
 and 5009000000AIhqw = is any random Case ID.

Please HIT KuDos , If this was helpful for you and mark it as a solution , if this was the thing which you were looking for.

Important :

Hit Kudos [Star Icon ] if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You
-


DevelopersDevelopers

Hi Gautam,

 

I checked that one it is working fine. But,we need to pass the id value. But, in my project, We used the vf page for entering the case details as a form and displaying the results in that page layout. In that case, it is throwing the exception.

 

Kindly suggest me how to fix this issue.

 

Regards,

kumar

gautam_singhgautam_singh

Hi,

Take this process flow  which I believe could be very much helpful

Method #1

1. There is a form in which Case Information is Feeded as a Form and then Save Button is Clicked.

2. When the Save Button is clicked , You can pass the parameter of the Case which have just been created to the Next Page using PageRefernce Class .

3. On the Page to which we have redirected , We can get the parameter from URL and use Output Lable to show the Details of the Case Record which have been created.


Method #2

We create a single page and a controller in which 'isEditMode' Boolean decides the page is Detail Page or it is an Edit Page.

1. We first keep isEditMode = True as the User will enter the information, We will have a Save button there click on which will Save the Case Record . We use inputFields and inputText to get the information from the users.

2. Once It is clicked on Save , isEditMode becomes False and Now you render the Page to show the 2nd part of the code which takes the ID of the above created case and shows everything with OutPut FIeld and OutPutLabel.


With the above 2 Methods you can Create the requirement Successfully ! It will surely help.


Important :

Hit Kudos [Star Icon ] if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You


DevelopersDevelopers

Hi Gautam,

 

We implemented the method #2. In that, we used the apex:outputField to show the long text area field. But, it does not show the entire value on the page.

 

I tried to use of apex:OutputText instead of apex:OutputField. For that, it shows the data in a continues text.

 

How to display the whole text of the long text area field on the page after clicking save.

 

Kindly suggest me to fix this issue.

 

Thanks,

kumar

 

 

DevelopersDevelopers

Hi Gautam,

 

Kindly look into my issue and support me to fix the issue. We implemented the method #2 which u explained in the previous post. We used <apex:outputField> to display the long text area field. But, it is not showing the whole text in the vf page.

 

Kindly support me. Please help me.

 

Thanks in advance.

 

Regards,

kumar

Ajay_SFDCAjay_SFDC

Hi there ,

 

I have used  <apex:outputText> to display the Long text from object .

 

Further you can use  

1. <apex:outputText value=""  escape="false"/>

 

2. To keep the spaces or any such as it is appearing in record you can use : 

 <apex:outputText value="Your Value"  style="white-space:pre;" />

 

Thanks 

Ajay